schr.core.base module

Abstract base classes for quantum simulations.

class schr.core.base.Field(dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)[source]

Bases: ABC

Abstract base class for field representations.

dtype

JAX dtype for field values.

abstractmethod get_state() Array[source]

Get current field state.

Returns:

Current field state as JAX array.

abstractmethod set_state(state: Array) None[source]

Set field state.

Parameters:

state – New field state.

class schr.core.base.Hamiltonian(dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)[source]

Bases: ABC

Abstract base class for quantum Hamiltonians.

Represents the quantum operator \(\hat{H}\) acting on wavefunctions \(|\psi\rangle\).

dtype

JAX dtype (complex64 or complex128).

abstractmethod apply(psi: Array, t: float) Array[source]

Apply \(\hat{H}|\psi\rangle\).

Parameters:
  • psi – Wavefunction \(|\psi\rangle\).

  • t – Time (a.u.).

Returns:

\(\hat{H}|\psi\rangle\).

energy(psi: Array, t: float) float[source]

Compute energy expectation \(\langle\psi|\hat{H}|\psi\rangle\).

Parameters:
  • psi – Normalized wavefunction.

  • t – Time (a.u.).

Returns:

Energy expectation value (a.u.).

class schr.core.base.Solver(hamiltonian: ~schr.core.base.Hamiltonian, dtype: ~numpy.dtype = <class 'jax.numpy.complex64'>)[source]

Bases: ABC

Abstract base class for time evolution solvers.

Implements numerical integration of the Schrödinger equation:

\[i\hbar\frac{\partial|\psi\rangle}{\partial t} = \hat{H}|\psi\rangle\]
hamiltonian

Hamiltonian operator.

dtype

JAX dtype for computations.

evolve(psi0: Array, t_span: tuple[float, float], dt: float, callback: Callable[[Array, float], Any] | None = None) Array[source]

Evolve wavefunction over time interval.

Parameters:
  • psi0 – Initial wavefunction.

  • t_span – Time interval (t_start, t_end) in a.u.

  • dt – Time step (a.u.).

  • callback – Optional function called at each step with (psi, t).

Returns:

Final wavefunction at t_end.

Raises:

ValueError – If t_end <= t_start or dt <= 0.

abstractmethod step(psi: Array, t: float, dt: float) Array[source]

Perform single time step \(|\psi(t)\rangle \to |\psi(t+dt)\rangle\).

Parameters:
  • psi – Wavefunction at time \(t\).

  • t – Current time (a.u.).

  • dt – Time step (a.u.).

Returns:

Wavefunction at time \(t + dt\).