schr.qed package

Submodules

Module contents

Quantum Electrodynamics (QED) module for schr package.

This module provides a simplified QED implementation based on minimal coupling between electrons and quantized electromagnetic fields.

class schr.qed.CoupledQEDSystem(electron_hamiltonian: ~schr.core.base.Hamiltonian, photon_field: ~schr.qed.field.PhotonField, coupling_strength: float = 0.1, hbar: float = 1.0, dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)[source]

Bases: object

Coupled electron-photon system with minimal coupling.

This class manages the joint evolution of an electron wavefunction and a quantized photon field, including their mutual interaction.

The total Hamiltonian is: H = H_electron + H_field + H_interaction

where H_interaction couples the electron to the photon modes.

electron_hamiltonian

Hamiltonian for the electron.

photon_field

Quantized photon field.

coupling_strength

Strength of electron-photon coupling.

hbar

Reduced Planck constant.

evolve(psi_electron: Array, photon_state: Array, t_span: tuple[float, float], dt: float) tuple[Array, Array][source]

Evolve the coupled electron-photon system.

Uses a simplified evolution scheme that alternates between electron, photon, and interaction terms.

Parameters:
  • psi_electron – Initial electron wavefunction.

  • photon_state – Initial photon field state.

  • t_span – Time interval (t_start, t_end).

  • dt – Time step.

Returns:

Tuple (psi_electron_final, photon_state_final).

Note

This is a simplified implementation for educational purposes. Production code would use proper tensor product spaces and more sophisticated evolution algorithms.

interaction_term(psi_electron: Array, photon_state: Array, mode: int = 0) tuple[Array, Array][source]

Compute the interaction between electron and photon field.

Uses a simplified dipole interaction: H_int = g (a + a†) x̂

where g is the coupling strength, a/a† are photon operators, and x̂ is the electron position operator.

Parameters:
  • psi_electron – Electron wavefunction.

  • photon_state – Photon field state.

  • mode – Photon mode to couple to. Default is 0.

Returns:

Tuple (H_int|ψ_e⟩, H_int|ϕ⟩) acting on electron and photon states.

total_energy(psi_electron: Array, photon_state: Array, t: float, dx: float) float[source]

Compute total energy of the coupled system.

E_total = E_electron + E_photon + E_interaction

Parameters:
  • psi_electron – Electron wavefunction.

  • photon_state – Photon field state.

  • t – Current time.

  • dx – Grid spacing for electron wavefunction.

Returns:

Total energy of the system.

class schr.qed.PhotonField(n_modes: int, frequencies: ~jax.Array, max_photons: int = 10, dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)[source]

Bases: Field

Finite-mode photon field in Fock space.

Represents a quantized electromagnetic field using a finite number of photon modes. Each mode is characterized by a frequency \(\omega\) and can be in various number states \(|n\rangle\).

The field is represented as a state vector in the truncated Fock space, where each mode can have 0 to max_photons photons.

n_modes

Number of photon modes.

max_photons

Maximum photon number per mode (truncation).

frequencies

Angular frequencies of each mode (\(\omega_i\)).

state

Current state vector in Fock space.

dtype

JAX dtype for the field.

annihilation_operator(mode: int) Array[source]

Get the annihilation operator \(a\) for a given mode.

The annihilation operator decreases the photon number in mode i: \(a_i |n_i\rangle = \sqrt{n_i} |n_i - 1\rangle\).

Parameters:

mode – Mode index (0 to n_modes-1).

Returns:

Matrix representation of the annihilation operator for this mode.

Raises:

ValueError – If mode index is out of range.

creation_operator(mode: int) Array[source]

Get the creation operator \(a^\dagger\) for a given mode.

The creation operator increases the photon number in mode i: \(a^\dagger_i |n_i\rangle = \sqrt{n_i + 1} |n_i + 1\rangle\).

Parameters:

mode – Mode index (0 to n_modes-1).

Returns:

Matrix representation of the creation operator for this mode.

Raises:

ValueError – If mode index is out of range.

expectation_photon_number(mode: int) float[source]

Compute expectation value of photon number in a mode.

Computes \(\langle\psi|\hat{n}_i|\psi\rangle\) where \(\hat{n}_i = a^\dagger_i a_i\).

Parameters:

mode – Mode index.

Returns:

Expected number of photons in the specified mode.

Raises:

NotImplementedError – For multi-mode expectation (not yet implemented).

get_state() Array[source]

Get the current state of the field.

Returns:

The field state as a JAX array.

hamiltonian(hbar: float = 1.0) Array[source]

Get the free-field Hamiltonian \(H = \sum_i \hbar\omega_i (a^\dagger_i a_i + 1/2)\).

Parameters:

hbar – Reduced Planck constant (default: 1.0).

Returns:

Matrix representation of the field Hamiltonian.

Note

For multi-mode fields, this returns the sum over all modes. The zero-point energy (1/2) is included.

number_operator(mode: int) Array[source]

Get the number operator \(\hat{n} = a^\dagger a\) for a given mode.

Parameters:

mode – Mode index (0 to n_modes-1).

Returns:

Matrix representation of the number operator for this mode.

Raises:

ValueError – If mode index is out of range.

set_state(state: Array) None[source]

Set the field state.

Parameters:

state – The new field state.

Raises:

ValueError – If state shape doesn’t match expected shape.

schr.qed.minimal_coupling_hamiltonian(psi_shape: tuple, dx: float, A: ~collections.abc.Callable[[~jax.Array, float], ~jax.Array], mass: float = 1.0, charge: float = -1.0, hbar: float = 1.0, dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>) Hamiltonian[source]

Create a Hamiltonian with minimal coupling to electromagnetic field.

The minimal coupling replaces the momentum p with p - qA/c, where A is the vector potential, q is the charge, and c is the speed of light.

This gives H = (p - qA)²/(2m) + V for a particle in an EM field.

Parameters:
  • psi_shape – Shape of the electron wavefunction grid.

  • dx – Grid spacing.

  • A – Vector potential function A(x, t).

  • mass – Particle mass. Default is 1.0.

  • charge – Particle charge. Default is -1.0 (electron).

  • hbar – Reduced Planck constant. Default is 1.0.

  • dtype – JAX dtype. Default is complex64.

Returns:

A Hamiltonian object with minimal coupling.

Note

This is a simplified implementation for educational purposes. Production QED would include gauge fixing, renormalization, etc.