Results

The portable HDF5 layout is documented in Result HDF5 Schema.

Common result and option dataclasses.

class openquantumsim.result.QuantumSystem(H, c_ops, hilbert)[source]

Bases: object

Container for a Hamiltonian, collapse operators, and Hilbert space.

Parameters:
H: Operator
c_ops: list[Operator]
hilbert: HilbertSpace
class openquantumsim.result.Options(method='auto', ode_solver='auto', rtol=1e-08, atol=1e-10, krylov_dim=30, n_traj=500, n_jobs=-1, backend='cpu', progress=False, save_states=False, compute_entropy=False, seed=None, max_step=None, checkpoint_file=None, checkpoint_every=100, strict=True)[source]

Bases: object

Solver options shared by Python wrappers.

method selects the propagation strategy: "ode" (adaptive Runge-Kutta, the default behind "auto") or "krylov" (Krylov exponentiation between output times, time-independent problems only). ode_solver selects the integrator used by "ode": "tsit5" (default), "vern7" or "vern9" for tight tolerances. method="tsit5" is accepted as an alias for method="ode" with ode_solver="tsit5".

strict controls what happens when a solver fails: True (default) raises SolverError; False emits a SolverHealthWarning and returns the partial result, with values after the failure set to NaN.

backend names the compute backend. Only "cpu" exists today.

Monte Carlo options: seed makes a run reproducible (None draws a fresh seed, reported as solver_stats["base_seed"]); n_jobs is the number of threads (-1 for all, 1 for serial) and never changes the result; max_step optionally caps the adaptive integrator step. Trajectories are integrated to rtol/atol and jump times are located by root-finding, so no step size has to be chosen.

Parameters:
  • method (str)

  • ode_solver (str)

  • rtol (float)

  • atol (float)

  • krylov_dim (int)

  • n_traj (int)

  • n_jobs (int)

  • backend (str)

  • progress (bool)

  • save_states (bool)

  • compute_entropy (bool)

  • seed (int | None)

  • max_step (float | None)

  • checkpoint_file (str | None)

  • checkpoint_every (int)

  • strict (bool)

method: str = 'auto'
ode_solver: str = 'auto'
rtol: float = 1e-08
atol: float = 1e-10
krylov_dim: int = 30
n_traj: int = 500
n_jobs: int = -1
backend: str = 'cpu'
progress: bool = False
save_states: bool = False
compute_entropy: bool = False
seed: int | None = None
max_step: float | None = None
checkpoint_file: str | None = None
checkpoint_every: int = 100
strict: bool = True
class openquantumsim.result.Result(times, states=None, expect=<factory>, expect_std=<factory>, expect_stderr=<factory>, state_observables=<factory>, state_observables_std=<factory>, state_observables_stderr=<factory>, entropy=None, solver_stats=<factory>)[source]

Bases: object

Simulation result returned by solver wrappers.

Parameters:
  • times (ndarray[tuple[Any, ...], dtype[float64]])

  • states (list[ndarray[tuple[Any, ...], dtype[complex128]]] | None)

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

  • expect_std (list[ndarray[tuple[Any, ...], dtype[float64]]])

  • expect_stderr (list[ndarray[tuple[Any, ...], dtype[float64]]])

  • state_observables (dict[str, ndarray[tuple[Any, ...], dtype[complex128]]])

  • state_observables_std (dict[str, ndarray[tuple[Any, ...], dtype[float64]]])

  • state_observables_stderr (dict[str, ndarray[tuple[Any, ...], dtype[float64]]])

  • entropy (ndarray[tuple[Any, ...], dtype[float64]] | None)

  • solver_stats (dict[str, Any])

times: ndarray[tuple[Any, ...], dtype[float64]]
states: list[ndarray[tuple[Any, ...], dtype[complex128]]] | None = None
expect: list[ndarray[tuple[Any, ...], dtype[complex128]]]
expect_std: list[ndarray[tuple[Any, ...], dtype[float64]]]
expect_stderr: list[ndarray[tuple[Any, ...], dtype[float64]]]
state_observables: dict[str, ndarray[tuple[Any, ...], dtype[complex128]]]
state_observables_std: dict[str, ndarray[tuple[Any, ...], dtype[float64]]]
state_observables_stderr: dict[str, ndarray[tuple[Any, ...], dtype[float64]]]
entropy: ndarray[tuple[Any, ...], dtype[float64]] | None = None
solver_stats: dict[str, Any]
evaluate_state_observables(observables, *, inplace=True)[source]

Evaluate scalar callbacks on saved states and store the time series.

Parameters:
  • observables (Mapping[str, Any])

  • inplace (bool)

Return type:

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

save_hdf5(path, *, overwrite=True)[source]

Write this result to an HDF5 file.

Parameters:
  • path (str | Path)

  • overwrite (bool)

Return type:

None

classmethod load_hdf5(path)[source]

Load a solver result from an HDF5 file.

Parameters:

path (str | Path)

Return type:

Result

openquantumsim.result.load_result(path)[source]

Load a solver result saved by Result.save_hdf5().

Parameters:

path (str | Path)

Return type:

Result