Site Tools


qutip-mesolve

Mesolve (Master Equation Solver)

Mesolve is QuTiP's main solver for the master equation. Given a Hamiltonian, collapse operators, initial state, and time points, it integrates the Lindblad equation and returns the state or expectation values at each time.

Mesolve uses adaptive ODE solvers (IDA, dopri5) for efficiency and accuracy. It handles large systems (up to hundreds of qubits for classical simulation) and time-dependent Hamiltonians.

from qutip import *
import numpy as np
 
# Damped qubit
H = 0.5 * sigmaz()
gamma = 0.1
c_ops = [np.sqrt(gamma) * sigmam()]
 
# Time points
times = np.linspace(0, 20, 100)
 
# Initial state
psi0 = basis(2, 1)  # Excited state
 
# Solve
result = mesolve(H, psi0, times, c_ops, [sigmaz()])
 
# Access results
print(result.expect[0])      # <σ_z>(t)
print(result.states)        # ρ(t) at each time
print(result.times)         # Time points (may differ from input)

Time-Dependent Hamiltonians

For time-dependent systems, pass a list of [H0, [H1, f1], [H2, f2], ...] where f_i(t) is a coefficient function:

# Rabi drive: H(t) = 0.5*σ_z + Ω(t)*σ_x
def rabi_pulse(t, args):
    return np.exp(-(t - 5)**2 / 2)  # Gaussian pulse
 
H = [0.5 * sigmaz(), [sigmax(), rabi_pulse]]
result = mesolve(H, psi0, times, c_ops, [sigmaz()])

Output Modes

  • Default: result.expect contains expectation values
  • States: Set options=Options(store_states=True) to get result.states
  • Diagnostics: result.solver contains solver information

Mesolve is the workhorse for simulating realistic quantum systems with decay and noise.

qutip-mesolve.md · Last modified: by 127.0.0.1