hqs_quantum_solver.evolution#

Implementations of time-evolution functionality for quantum systems.

Functions

evolve_adams(operator, state, t_eval, *[, ...])

Discrete time-evolution using the Adams method.

evolve_krylov(operator, state, t_eval, *[, ...])

Discrete time-evolution using a Krylov-based method.

evolve_rk45(operator, state, t_eval, *[, ...])

Discrete time-evolution using the explicit Runge-Kutta 5(4) method.

evolve_using_krylov(*args, **kwargs)

Discrete time-evolution using a Krylov-based method.

evolve_using_rk45(*args, **kwargs)

Discrete time-evolution using the explicit Runge-Kutta 5(4) method.

Classes

IntegratorResult

Result of a time integration.

class IntegratorResult#

Result of a time integration.

state#

The state vector at the final evaluation time.

Type:

ndarray

observations#

Contains the observation for each value in t_eval.

Type:

list

__init__(state: ndarray, observations: list[T_co]) None#

Method generated by attrs for class IntegratorResult.

evolve_adams(operator: SimpleOperatorProtocol, state: np.ndarray, t_eval: float | Sequence[float], *, observer: Observer[T_co] | None = None, progress: Callable[[float], Any] | None = None, rtol: float = 1e-3, atol: float = 1e-6) IntegratorResult[T_co]#

Discrete time-evolution using the Adams method.

Computes an approximation to the solution of the Schrödinger equation,

\[\mathrm{i} \hbar \frac{d}{d t} \ket{\psi(t)} = H \ket{\psi(t)} \,,\]

at times \(t_0, \dots, t_{n-1}\) given the wavefunction at \(t_0\), where we choose the units such that \(\hbar = 1\).

The solver keeps the local error estimate below \(\mathtt{atol}_i + \mathtt{rtol}_i \cdot | \braket{\mathbf{e}_i, \psi} |\).

Parameters:
  • operator (SimpleOperatorProtocol) – The linear operator \(H\).

  • state (ndarray) – The wavefunction \(\ket{\psi}\) at time \(t_0\).

  • t_eval (float | Sequence[float]) –

    The values \(t_0, \dots, t_{n-1}\) at which to evaluate the solution. Must be given in ascending order.

    Calling the function with t_eval being just a number, is equivalent to calling the function with [0, t_eval].

  • observer (Observer | None) – Called for every time step \(t_i\). The return values are collected in the observations attribute of the result.

  • progress (Callable[[float], Any] | None) – Called with the current value of t when the time-stepper advances. Can, e.g., be used to display the simulation progress.

  • rtol (float and array_like) – The relative error tolerance.

  • atol (float and array_like) – The absolute error tolerance.

Returns:

The final state and observations.

Return type:

IntegratorResult

evolve_krylov(operator: SimpleOperatorProtocol, state: np.ndarray, t_eval: float | Sequence[float], *, observer: Observer[T_co] | None = None, progress: Callable[[float], Any] | None = None, tolerance: float = 1e-8, max_krylov_dimension: int = 30, max_time_steps: int = 2**15, additional_orthogonalizations: int = 1, verbose: int = 0) IntegratorResult[T_co]#

Discrete time-evolution using a Krylov-based method.

Warning

This method is not reentrant. It is not possible to call this method from different threads at the same time.

Computes an approximation to the solution of the Schrödinger equation,

\[\mathrm{i} \hbar \frac{d}{d t} \ket{\psi(t)} = H \ket{\psi(t)} \,,\]

at times \(t_0, \dots, t_{n-1}\) given the wavefunction at \(t_0\), where we choose the units such that \(\hbar = 1\).

This function uses a Krylov-based method, which means that it computes

\[\psi \mapsto e^{- (\mathrm{i} / \hbar)\, \Delta t\, H} \psi\]

approximatively.

Parameters:
  • operator (SimpleOperatorProtocol) – The linear operator \(H\).

  • state (ndarray) – The wavefunction \(\ket{\psi}\) at time \(t_0\).

  • t_eval (float | Sequence[float]) –

    The values \(t_0, \dots, t_{n-1}\) at which to evaluate the solution. Must be given in ascending order.

    Calling the function with t_eval being just a number, is equivalent to calling the function with [0, t_eval].

  • observer (Observer | None) – Called for every time step \(t_i\). The return values are collected in the observations attribute of the result.

  • progress (Callable[[float], Any] | None) – Called with the current value of t when the time-stepper advances. Can, e.g., be used to display the simulation progress.

  • tolerance (float) – The error tolerance. The method uses a heuristic that should ensure that the error is in the order of the given tolerance.

  • max_krylov_dimension (int) – The maximal number of vectors generated for the Krylov basis.

  • max_time_steps (int) – The maximal number of intermediate time steps to compute.

  • additional_orthogonalizations (int) – The number of additional orthogonalizations to perform. Can be used to improve the orthogonality of the Krylov basis, by setting to a value of one or larger.

  • verbose (int) – The verbosity level as given by lattice_solver, \(0 \le \mathtt{verbose} \le 2\).

Returns:

The final state and observations.

Return type:

IntegratorResult

evolve_rk45(operator: SimpleOperatorProtocol, state: np.ndarray, t_eval: float | Sequence[float], *, observer: Observer[T_co] | None = None, progress: Callable[[float], Any] | None = None, rtol: float = 1e-3, atol: float = 1e-6) IntegratorResult[T_co]#

Discrete time-evolution using the explicit Runge-Kutta 5(4) method.

Computes an approximation to the solution of the Schrödinger equation,

\[\mathrm{i} \hbar \frac{d}{d t} \ket{\psi(t)} = H \ket{\psi(t)} \,,\]

at times \(t_0, \dots, t_{n-1}\) given the wavefunction at \(t_0\), where we choose the units such that \(\hbar = 1\).

The solver keeps the local error estimate below \(\mathtt{atol}_i + \mathtt{rtol}_i \cdot | \braket{\mathbf{e}_i, \psi} |\).

Parameters:
  • operator (SimpleOperatorProtocol) – The linear operator \(H\).

  • state (ndarray) – The wavefunction \(\ket{\psi}\) at time \(t_0\).

  • t_eval (float | Sequence[float]) –

    The values \(t_0, \dots, t_{n-1}\) at which to evaluate the solution. Must be given in ascending order.

    Calling the function with t_eval being just a number, is equivalent to calling the function with [0, t_eval].

  • observer (Observer | None) – Called for every time step \(t_i\). The return values are collected in the observations attribute of the result.

  • progress (Callable[[float], Any] | None) – Called with the current value of t when the time-stepper advances. Can, e.g., be used to display the simulation progress.

  • rtol (float and array_like) – The relative error tolerance.

  • atol (float and array_like) – The absolute error tolerance.

Returns:

The final state and observations.

Return type:

IntegratorResult

evolve_using_krylov(*args, **kwargs) ndarray#

Discrete time-evolution using a Krylov-based method.

Compatibility wrapper for evolve_krylov().

Warning

This method is deprected. Use evolve_krylov() instead.

Parameters:
Returns:

The wavefunction after time evolution.

Return type:

ndarray

evolve_using_rk45(*args, **kwargs) ndarray#

Discrete time-evolution using the explicit Runge-Kutta 5(4) method.

Compatibility wrapper for evolve_rk45().

Warning

This method is deprected. Use evolve_rk45() instead.

Parameters:
Returns:

The wavefunction after time evolution.

Return type:

ndarray