Skip to content

Commit 57b0b0d

Browse files
committed
update docs
1 parent f50b706 commit 57b0b0d

File tree

2 files changed

+51
-14
lines changed

2 files changed

+51
-14
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ DocMeta.setdocmeta!(QuantumToolbox, :DocTestSetup, :(using QuantumToolbox); recu
1414

1515
# some options for `makedocs`
1616
const DRAFT = false # set `true` to disable cell evaluation
17-
const DOCTEST = true # set `false` to skip doc tests
17+
const DOCTEST = false # set `false` to skip doc tests
1818

1919
# generate bibliography
2020
bib = CitationBibliography(

docs/src/users_guide/time_evolution/stochastic.md

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ The solver [`ssesolve`](@ref) will construct the operators ``\hat{K}`` and ``\ha
2929

3030
## [Stochastic master equation](@id doc-TE:Stochastic-master-equation)
3131

32-
When the initial state of the system is a density matrix ``\rho(0)``, the stochastic master equation solver [`smesolve`](@ref) must be used. The stochastic master equation is given by [Wiseman2009Quantum; section 4.4](@cite):
32+
When the initial state of the system is a density matrix ``\rho(0)``, or when additional loss channels are included, the stochastic master equation solver [`smesolve`](@ref) must be used. The stochastic master equation is given by [Wiseman2009Quantum; section 4.4](@cite):
3333

3434
```math
3535
d \rho (t) = -i [\hat{H}, \rho(t)] dt + \sum_i \mathcal{D}[\hat{C}_i] \rho(t) dt + \sum_n \mathcal{D}[\hat{S}_n] \rho(t) dt + \sum_n \mathcal{H}[\hat{S}_n] \rho(t) dW_n(t),
@@ -52,7 +52,7 @@ The above implementation takes into account 2 types of collapse operators. ``\ha
5252

5353
## [Example: Homodyne detection](@id doc-TE:Example:Homodyne-detection)
5454

55-
Below, 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 ``\kappa`` and the ``\Delta`` is the cavity detuning with respect to the driving field. The homodyne current ``J_x`` is calculated using
55+
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 ``\kappa`` and the ``\Delta`` is the cavity detuning with respect to the driving field. The homodyne current ``J_x`` is calculated using
5656

5757
```math
5858
J_x = \langle \hat{x} \rangle + dW/dt,
@@ -64,34 +64,71 @@ where ``\hat{x}`` is the operator build from the `sc_ops` as
6464
\hat{x} = \hat{S} + \hat{S}^\dagger
6565
```
6666

67-
```@setup smesolve
67+
```@setup stochastic-solve
6868
using QuantumToolbox
6969
7070
using CairoMakie
7171
CairoMakie.enable_only_mime!(MIME"image/svg+xml"())
7272
```
7373

74-
```@example smesolve
74+
```@example stochastic-solve
7575
# parameters
7676
N = 20 # Fock space dimension
7777
Δ = 5 * 2 * π # cavity detuning
7878
κ = 2 # cavity decay rate
7979
α = 4 # intensity of initial state
8080
ntraj = 500 # number of trajectories
8181
82+
tlist = 0:0.0025:1
83+
8284
# operators
8385
a = destroy(N)
8486
x = a + a'
8587
H = Δ * a' * a
86-
c_ops = nothing
87-
sc_ops = [√(κ) * a]
8888
89-
ρ0 = coherent_dm(N, √α)
90-
tlist = 0:0.0025:1
89+
# initial state
90+
ψ0 = coherent(N, √α)
9191
92-
stoc_sol = smesolve(
92+
# temperature with average of 0 excitations (absolute zero)
93+
n_th = 0
94+
# c_ops = [√(κ * n_th) * a'] -> nothing
95+
sc_ops = [√(κ * (n_th + 1)) * a]
96+
```
97+
98+
In this case, there is no additional dissipation (`c_ops = nothing`), and thus, we can use the [`ssesolve`](@ref):
99+
100+
```@example stochastic-solve
101+
sse_sol = ssesolve(
93102
H,
94-
ρ0,
103+
ψ0,
104+
tlist,
105+
sc_ops,
106+
e_ops = [x],
107+
ntraj = ntraj,
108+
)
109+
110+
# plot by CairoMakie.jl
111+
fig = Figure(size = (500, 350))
112+
ax = Axis(fig[1, 1], xlabel = "Time")
113+
#lines!(ax, tlist, real(sse_sol.xxxxxx), label = L"J_x", color = :red, linestyle = :solid) TODO: add this in the future
114+
lines!(ax, tlist, real(sse_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
115+
116+
axislegend(ax, position = :rt)
117+
118+
fig
119+
```
120+
121+
Next, we consider the same model but at a finite temperature to demonstrate [`smesolve`](@ref):
122+
123+
```@example stochastic-solve
124+
# temperature with average of 1 excitations
125+
n_th = 1
126+
c_ops = [√(κ * n_th) * a']
127+
sc_ops = [√(κ * (n_th + 1)) * a]
128+
129+
sme_sol = smesolve(
130+
H,
131+
ψ0,
95132
tlist,
96133
c_ops,
97134
sc_ops,
@@ -102,10 +139,10 @@ stoc_sol = smesolve(
102139
# plot by CairoMakie.jl
103140
fig = Figure(size = (500, 350))
104141
ax = Axis(fig[1, 1], xlabel = "Time")
105-
#lines!(ax, tlist, real(stoc_sol.xxxxxx), label = L"J_x", color = :red, linestyle = :solid) TODO: add this in the future
106-
lines!(ax, tlist, real(stoc_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
142+
#lines!(ax, tlist, real(sme_sol.xxxxxx), label = L"J_x", color = :red, linestyle = :solid) TODO: add this in the future
143+
lines!(ax, tlist, real(sme_sol.expect[1,:]), label = L"\langle x \rangle", color = :black, linestyle = :solid)
107144
108145
axislegend(ax, position = :rt)
109146
110147
fig
111-
```
148+
```

0 commit comments

Comments
 (0)