Skip to content

Stochastic Solver

When a quantum system is subjected to continuous measurement, through homodyne detection for example, it is possible to simulate the conditional quantum state using stochastic Schrödinger and master equations. The solution of these stochastic equations are quantum trajectories, which represent the conditioned evolution of the system given a specific measurement record.

Stochastic Schrödinger equation

The stochastic Schrödinger time evolution of a quantum system is defined by the following stochastic differential equation (Wiseman and Milburn, 2009; section 4.4):

d|ψ(t)=iK^|ψ(t)dt+nM^n|ψ(t)dWn(t)

where

K^=H^+in(en2S^n12S^nS^nen28),M^n=S^nen2,

and

en=ψ(t)|S^n+S^n|ψ(t).

Above, H^ is the Hamiltonian, S^n are the stochastic collapse operators, and dWn(t) is the real Wiener increment (associated to S^n) which has the expectation values of E[dWn]=0 and E[dWn2]=dt.

The solver ssesolve will construct the operators K^ and M^n. Once the user passes the Hamiltonian (H^) and the stochastic collapse operators list (sc_ops; {S^n}n). As with the mcsolve, the number of trajectories and the random number generator for the noise realization can be fixed using the arguments: ntraj and rng, respectively.

Stochastic master equation

When the initial state of the system is a density matrix ρ(0), or when additional loss channels are included, the stochastic master equation solver smesolve must be used. The stochastic master equation is given by (Wiseman and Milburn, 2009; section 4.4):

dρ(t)=i[H^,ρ(t)]dt+iD[C^i]ρ(t)dt+nD[S^n]ρ(t)dt+nH[S^n]ρ(t)dWn(t),

where

D[O^]ρ=O^ρO^12{O^O^,ρ},

is the Lindblad superoperator, and

H[O^]ρ=O^ρ+ρO^Tr[O^ρ+ρO^]ρ,

The above implementation takes into account 2 types of collapse operators. C^i (c_ops) represent the collapse operators related to pure dissipation, while S^n (sc_ops) are the stochastic collapse operators. The first three terms on the right-hand side of the above equation is the deterministic part of the evolution which takes into account all operators C^i and S^n. The last term (H[S^n]ρ(t)) is the stochastic part given solely by the operators S^n.

Example: Homodyne detection

First, we solve the dynamics for an optical cavity at absolute zero (0K) whose output is monitored using homodyne detection. The cavity decay rate is given by κ and the Δ is the cavity detuning with respect to the driving field. The homodyne current Jx is calculated using

Jx=x^+dW/dt,

where x^ is the operator build from the sc_ops as

x^=S^+S^
julia
# parameters
N = 20         # Fock space dimension
Δ = 5 * 2 * π  # cavity detuning
κ = 2          # cavity decay rate
α = 4          # intensity of initial state
ntraj = 500    # number of trajectories

tlist = 0:0.0025:1

# operators
a = destroy(N)
x = a + a'
H = Δ * a' * a

# initial state
ψ0 = coherent(N, α)

# temperature with average of 0 excitations (absolute zero)
n_th = 0
# c_ops  = [√(κ * n_th) * a'] -> nothing
sc_ops = [* (n_th + 1)) * a]
1-element Vector{QuantumObject{OperatorQuantumObject, Dimensions{1, Tuple{Space}}, SparseMatrixCSC{ComplexF64, Int64}}}:
 
Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
⎡⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀⎤
⎢⠀⠀⠈⠢⡀⠀⠀⠀⠀⠀⎥
⎢⠀⠀⠀⠀⠈⠢⡀⠀⠀⠀⎥
⎢⠀⠀⠀⠀⠀⠀⠈⠢⡀⠀⎥
⎣⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⎦

In this case, there is no additional dissipation (c_ops = nothing), and thus, we can use the ssesolve:

julia
sse_sol = ssesolve(
    H,
    ψ0,
    tlist,
    sc_ops,
    e_ops = [x],
    ntraj = ntraj,
    store_measurement = Val(true),
)

measurement_avg = sum(sse_sol.measurement, dims=2) / size(sse_sol.measurement, 2)
measurement_avg = dropdims(measurement_avg, dims=2)

# plot by CairoMakie.jl
fig = Figure(size = (500, 350))
ax = Axis(fig[1, 1], xlabel = "Time")
lines!(ax, tlist[1:end-1], real(measurement_avg[1,:]), label = L"J_x", color = :red, linestyle = :solid)
lines!(ax, tlist, real(sse_sol.expect[1,:]),  label = L"\langle x \rangle", color = :black, linestyle = :solid)

axislegend(ax, position = :rt)

fig

Next, we consider the same model but at a finite temperature to demonstrate smesolve:

julia
# temperature with average of 1 excitations
n_th = 1
c_ops  = [* n_th) * a']
sc_ops = [* (n_th + 1)) * a]

sme_sol = smesolve(
    H,
    ψ0,
    tlist,
    c_ops,
    sc_ops,
    e_ops = [x],
    ntraj = ntraj,
    store_measurement = Val(true),
)

measurement_avg = sum(sme_sol.measurement, dims=2) / size(sme_sol.measurement, 2)
measurement_avg = dropdims(measurement_avg, dims=2)

# plot by CairoMakie.jl
fig = Figure(size = (500, 350))
ax = Axis(fig[1, 1], xlabel = "Time")
lines!(ax, tlist[1:end-1], real(measurement_avg[1,:]), label = L"J_x", color = :red, linestyle = :solid)
lines!(ax, tlist, real(sme_sol.expect[1,:]),  label = L"\langle x \rangle", color = :black, linestyle = :solid)

axislegend(ax, position = :rt)

fig