Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
OpenQuantumSim

Getting Started

  • Quick Start
  • Example Gallery

Reference

  • API Reference
    • Hilbert Spaces
    • Operators and States
    • Solvers
    • Correlations
    • Phase Space
    • Plotting
    • Parameter Sweeps
    • System Builders
    • Results
    • Observables
    • Time-Dependent Hamiltonians
  • Tutorial Notebooks
    • Qubit Decay in Five Minutes
    • Qubit Decay with mesolve
    • Restartable Parameter Sweeps
    • Wigner and Husimi-Q Functions
    • State Metrics and Solver Diagnostics
    • Dicke Synchronization with a Collective Spin Ensemble
  • Result HDF5 Schema

Background

  • Theory Notes
  • Validation Gallery
  • Performance Benchmarks
  • Case Studies
Back to top
View this page

Validation Gallery¶

OpenQuantumSim should earn trust by matching simple analytic limits and established reference implementations. The current validation gallery covers a closed-form qubit decay problem, a damped Jaynes-Cummings comparison against QuTiP, and the command used for direct QuTiP speed comparisons.

Analytic Qubit Decay¶

A two-level atom with spontaneous emission has excited-state population

\[P_e(t) = \exp(-\gamma t).\]

The corresponding OpenQuantumSim model is intentionally small enough to inspect line by line:

import numpy as np
import openquantumsim as oqs

gamma = 0.35
atom = oqs.SpinSpace(0.5, label="atom")
H = 0.0 * oqs.sigmaz(atom)
collapse = np.sqrt(gamma) * oqs.sigmam(atom)
excited = oqs.basis(atom, "up")
rho0 = oqs.ket2dm(excited)
P_excited = oqs.Operator(oqs.ket2dm(excited), atom, "P_excited")
times = np.linspace(0.0, 6.0, 61)

result = oqs.mesolve(
    H,
    rho0,
    times,
    c_ops=[collapse],
    e_ops=[P_excited],
    options=oqs.Options(rtol=1e-9, atol=1e-11),
)

expected = np.exp(-gamma * times)
max_error = np.max(np.abs(result.expect[0].real - expected))

This case is covered by tests/physics/test_qubit_decay.py.

Jaynes-Cummings Against QuTiP¶

The Jaynes-Cummings validation uses the same cavity-atom Hamiltonian and collapse operators in OpenQuantumSim and QuTiP, then compares cavity photon number and atomic excited-state population.

Install the optional validation dependency, then run:

python -m pip install -e ".[validation]"
python scripts/validate_jaynes_cummings_qutip.py \
    --cavity-dim 5 \
    --time-points 81 \
    --t-final 8.0 \
    --tolerance 5e-7 \
    --output-csv runs/jaynes_cummings_qutip_validation.csv

The script exits nonzero if either observable exceeds the requested tolerance. A typical successful run prints:

max photon-number delta: ...
max excited-population delta: ...
tolerance: 5.000e-07
Jaynes-Cummings QuTiP validation: passed

This case is covered by tests/physics/test_jaynes_cummings_qutip.py when QuTiP is installed.

QuTiP Speed Benchmark¶

Use the benchmark harness to compare OpenQuantumSim and QuTiP on the same models and time grids:

python benchmarks/bench_vs_qutip.py \
    --case qubit \
    --case jc5 \
    --time-points 101 \
    --t-final 6.0 \
    --repeats 3 \
    --output-json runs/bench_vs_qutip.json

The report includes median wall time, minimum wall time, speedup relative to QuTiP, and the maximum expectation-value deviation from the QuTiP reference. For reproducible benchmark numbers, record the CPU model, Julia thread count, Python version, Julia version, OpenQuantumSim commit, and QuTiP version next to the generated JSON.

The current published benchmark snapshot is in Performance Benchmarks.

Next
Performance Benchmarks
Previous
Theory Notes
Copyright © 2026, Mohammad Jafari
Made with Sphinx and @pradyunsg's Furo
On this page
  • Validation Gallery
    • Analytic Qubit Decay
    • Jaynes-Cummings Against QuTiP
    • QuTiP Speed Benchmark