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
TimeDependentHamiltonianobjects with scalar coefficients.- Parameters:
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:
- 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.rtolandOptions.atol; statistical error is reported inexpect_stderr. Every trajectory has its own Xoshiro random stream derived fromOptions.seed, so results do not depend onn_jobs.Built-in
state_observablescreated byopenquantumsim.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 throughsingle_trajectory()or deterministicmesolve()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:
- 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:
- openquantumsim.solvers.steadystate(H, c_ops, *, method='auto', options=None, return_stats=False)[source]¶
Compute a Lindblad steady state.
methodis"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 aSolverHealthWarning.With
return_stats=Truethe function returns(rho, stats)wherestatsholdsconverged,residual,relative_residual,min_eigenvalueand timing information.
- openquantumsim.solvers.lindblad_superoperator(H, c_ops=None)[source]¶
Return the dense Lindblad superoperator matrix in column-stacked form.
The returned matrix
Lacts onvec(rho)(column-stacked, matching NumPy’s Fortran-order reshape) asvec(L(rho)) = L @ vec(rho).
- 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_opspairs each bath-coupling operator with a spectrum callablegamma(omega)giving the dissipator weight at Bohr frequencyomega = E_m - E_nof the transition|n> -> |m>. A constant weightgis equivalent to a Lindblad collapse operatorsqrt(g) * A. Decay (emission) channels sit at negative frequencies, so a zero-temperature bath returnsgforomega < 0and0foromega > 0.Transitions sharing a Bohr frequency are treated as a single secular channel. The Hamiltonian must be Hermitian.
- 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 superoperatorsS(t) = exp(L t)built from the Lindblad generator (seelindblad_superoperator()); apply them to a density matrix withapply_superoperator().