Solvers

Python solver entry points.

openquantumsim.solvers.mesolve(H, rho0, tlist, *, c_ops=None, e_ops=None, state_observables=None, options=None)[source]

Solve a Lindblad master equation.

Supports time-independent Hamiltonians and TimeDependentHamiltonian objects with scalar coefficients.

Parameters:
  • H (Operator | TimeDependentHamiltonian)

  • rho0 (ndarray[tuple[Any, ...], dtype[complex128]])

  • tlist (Sequence[float] | ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • c_ops (Sequence[Operator] | None)

  • e_ops (Sequence[Operator] | None)

  • state_observables (Mapping[str, Callable[[ndarray[tuple[Any, ...], dtype[complex128]]], Any]] | None)

  • options (Options | None)

Return type:

Result

openquantumsim.solvers.mcsolve(H, psi0, tlist, *, c_ops=None, e_ops=None, n_traj=None, state_observables=None, options=None)[source]

Run Monte Carlo wave-function trajectories.

Each trajectory uses the waiting-time algorithm: the state evolves under the non-Hermitian effective Hamiltonian with an adaptive integrator, and a quantum jump is applied at the instant the squared norm reaches a uniformly drawn threshold. Accuracy is controlled by Options.rtol and Options.atol; statistical error is reported in expect_stderr. Every trajectory has its own Xoshiro random stream derived from Options.seed, so results do not depend on n_jobs.

Built-in state_observables created by openquantumsim.state_metrics() are aggregated by the backend when they can be represented as linear expectation values or pure-trajectory constants. Arbitrary Python callbacks remain available through single_trajectory() or deterministic mesolve() runs with saved state access.

Parameters:
  • H (Operator)

  • psi0 (ndarray[tuple[Any, ...], dtype[complex128]])

  • tlist (Sequence[float] | ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • c_ops (Sequence[Operator] | None)

  • e_ops (Sequence[Operator] | None)

  • n_traj (int | None)

  • state_observables (Mapping[str, Callable[[ndarray[tuple[Any, ...], dtype[complex128]]], Any]] | None)

  • options (Options | None)

Return type:

Result

openquantumsim.solvers.single_trajectory(H, psi0, tlist, *, c_ops=None, e_ops=None, state_observables=None, options=None)[source]

Run one Monte Carlo wave-function trajectory.

Set Options(save_states=True) to return the ket at each requested time.

Parameters:
  • H (Operator)

  • psi0 (ndarray[tuple[Any, ...], dtype[complex128]])

  • tlist (Sequence[float] | ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • c_ops (Sequence[Operator] | None)

  • e_ops (Sequence[Operator] | None)

  • state_observables (Mapping[str, Callable[[ndarray[tuple[Any, ...], dtype[complex128]]], Any]] | None)

  • options (Options | None)

Return type:

Result

openquantumsim.solvers.steadystate(H, c_ops, *, method='auto', options=None, return_stats=False)[source]

Compute a Lindblad steady state.

method is "auto" (default), "direct" (sparse LU) or "iterative-gmres". "auto" uses the direct solve for Hilbert dimensions up to 128 and GMRES above that. GMRES is not preconditioned and can stagnate on larger or strongly driven systems.

The solve is checked before it is returned: a GMRES run that did not converge raises ConvergenceError, and a state whose residual |L rho| / |L| is large triggers a SolverHealthWarning.

With return_stats=True the function returns (rho, stats) where stats holds converged, residual, relative_residual, min_eigenvalue and timing information.

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[complex128]] | tuple[ndarray[tuple[Any, …], dtype[complex128]], dict[str, object]]

openquantumsim.solvers.lindblad_superoperator(H, c_ops=None)[source]

Return the dense Lindblad superoperator matrix in column-stacked form.

The returned matrix L acts on vec(rho) (column-stacked, matching NumPy’s Fortran-order reshape) as vec(L(rho)) = L @ vec(rho).

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.solvers.apply_superoperator(superoperator, rho)[source]

Apply a column-stacked superoperator to a density matrix.

Parameters:
  • superoperator (ndarray[tuple[Any, ...], dtype[complex128]])

  • rho (ndarray[tuple[Any, ...], dtype[complex128]])

Return type:

ndarray[tuple[Any, …], dtype[complex128]]

openquantumsim.solvers.brmesolve(H, rho0, tlist, *, a_ops, e_ops=None, options=None)[source]

Solve the secular Bloch-Redfield master equation.

a_ops pairs each bath-coupling operator with a spectrum callable gamma(omega) giving the dissipator weight at Bohr frequency omega = E_m - E_n of the transition |n> -> |m>. A constant weight g is equivalent to a Lindblad collapse operator sqrt(g) * A. Decay (emission) channels sit at negative frequencies, so a zero-temperature bath returns g for omega < 0 and 0 for omega > 0.

Transitions sharing a Bohr frequency are treated as a single secular channel. The Hamiltonian must be Hermitian.

Parameters:
  • H (Operator)

  • rho0 (ndarray[tuple[Any, ...], dtype[complex128]])

  • tlist (Sequence[float] | ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • a_ops (Sequence[tuple[Operator, Callable[[float], float]]])

  • e_ops (Sequence[Operator] | None)

  • options (Options | None)

Return type:

Result

openquantumsim.solvers.propagator(H, tlist, *, c_ops=None)[source]

Propagators for a time-independent system at each time in tlist.

Without collapse operators this returns the unitary propagators U(t) = exp(-i H t). With collapse operators it returns the propagator superoperators S(t) = exp(L t) built from the Lindblad generator (see lindblad_superoperator()); apply them to a density matrix with apply_superoperator().

Parameters:
  • H (Operator)

  • tlist (Sequence[float] | ndarray[tuple[Any, ...], dtype[floating[Any]]])

  • c_ops (Sequence[Operator] | None)

Return type:

list[Operator]