Skip to content

Commit d7ae62e

Browse files
committed
add stochastic solvers documentation page
1 parent df287f1 commit d7ae62e

File tree

4 files changed

+118
-6
lines changed

4 files changed

+118
-6
lines changed

docs/src/users_guide/time_evolution/intro.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
- [Introduction](@ref doc-TE:Introduction)
66
- [Time Evolution Solutions](@ref doc-TE:Time-Evolution-Solutions)
77
- [Solution](@ref doc-TE:Solution)
8-
- [Multiple trajectories solution](@ref doc-TE:Multiple-trajectories-solution)
98
- [Accessing data in solutions](@ref doc-TE:Accessing-data-in-solutions)
9+
- [Multiple trajectories solution](@ref doc-TE:Multiple-trajectories-solution)
1010
- [Schrödinger Equation Solver](@ref doc-TE:Schrödinger-Equation-Solver)
1111
- [Unitary evolution](@ref doc-TE:Unitary-evolution)
1212
- [Example: Spin dynamics](@ref doc-TE:Example:Spin-dynamics)
@@ -16,8 +16,11 @@
1616
- [Example: Dissipative Spin dynamics](@ref doc-TE:Example:Dissipative-Spin-dynamics)
1717
- [Example: Harmonic oscillator in thermal bath](@ref doc-TE:Example:Harmonic-oscillator-in-thermal-bath)
1818
- [Example: Two-level atom coupled to dissipative single-mode cavity](@ref doc-TE:Example:Two-level-atom-coupled-to-dissipative-single-mode-cavity)
19-
- [Monte-Carlo Solver](@ref doc-TE:Monte-Carlo-Solver)
19+
- [Monte Carlo Solver](@ref doc-TE:Monte-Carlo-Solver)
2020
- [Stochastic Solver](@ref doc-TE:Stochastic-Solver)
21+
- [Stochastic Schrödinger equation](@ref doc-TE:Stochastic-Schrödinger-equation)
22+
- [Stochastic master equation](@ref doc-TE:Stochastic-master-equation)
23+
- [Example: Homodyne detection](@ref doc-TE:Example:Homodyne-detection)
2124
- [Solving Problems with Time-dependent Hamiltonians](@ref doc-TE:Solving-Problems-with-Time-dependent-Hamiltonians)
2225
- [Generate QobjEvo](@ref doc-TE:Generate-QobjEvo)
2326
- [QobjEvo fields (attributes)](@ref doc-TE:QobjEvo-fields-(attributes))
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# [Monte-Carlo Solver](@id doc-TE:Monte-Carlo-Solver)
1+
# [Monte Carlo Solver](@id doc-TE:Monte-Carlo-Solver)
22

33
This page is still under construction, please visit [API](@ref doc-API) first.

docs/src/users_guide/time_evolution/solution.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,7 @@ Some other solvers can have other output.
8989

9090
## [Multiple trajectories solution](@id doc-TE:Multiple-trajectories-solution)
9191

92-
This part is still under construction, please visit [API](@ref doc-API) first.
92+
This part is still under construction, please read the docstrings for the following functions first:
93+
94+
- [`TimeEvolutionMCSol`](@ref)
95+
- [`TimeEvolutionStochasticSol`](@ref)
Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,111 @@
11
# [Stochastic Solver](@id doc-TE:Stochastic-Solver)
22

3-
This page is still under construction, please visit [API](@ref doc-API) first.
3+
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.
44

5-
## Stochastic Schrodinger equation
5+
## [Stochastic Schrödinger equation](@id doc-TE:Stochastic-Schrödinger-equation)
6+
7+
The stochastic Schrödinger time evolution of a quantum system is defined by the following stochastic differential equation [Wiseman2009Quantum; section 4.4](@cite):
8+
9+
```math
10+
d|\psi(t)\rangle = -i \hat{K} |\psi(t)\rangle dt + \sum_n \hat{M}_n |\psi(t)\rangle dW_n(t)
11+
```
12+
13+
where
14+
15+
```math
16+
\hat{K} = \hat{H} + i \sum_n \left(\frac{e_n}{2} \hat{S}_n - \frac{1}{2} \hat{S}_n^\dagger \hat{S}_n - \frac{e_n^2}{8}\right),
17+
```
18+
```math
19+
\hat{M}_n = \hat{S}_n - \frac{e_n}{2},
20+
```
21+
and
22+
```math
23+
e_n = \langle \psi(t) | \hat{S}_n + \hat{S}_n^\dagger | \psi(t) \rangle.
24+
```
25+
26+
Above, ``\hat{H}`` is the Hamiltonian, ``\hat{S}_n`` are the stochastic collapse operators, and ``dW_n(t)`` is the real Wiener increment (associated to ``\hat{S}_n``) which has the expectation values of ``E[dW_n]=0`` and ``E[dW_n^2]=dt``.
27+
28+
The solver [`ssesolve`](@ref) will construct the operators ``\hat{K}`` and ``\hat{M}_n``. Once the user passes the Hamiltonian (``\hat{H}``) and the stochastic collapse operators list (`sc_ops`; ``\{\hat{S}_n\}_n``). As with the [`mcsolve`](@ref), the number of trajectories and the random number generator for the noise realization can be fixed using the arguments: `ntraj` and `rng`, respectively.
29+
30+
## [Stochastic master equation](@id doc-TE:Stochastic-master-equation)
31+
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):
33+
34+
```math
35+
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),
36+
```
37+
38+
where
39+
40+
```math
41+
\mathcal{D}[\hat{O}] \rho = \hat{O} \rho \hat{O}^\dagger - \frac{1}{2} \{\hat{O}^\dagger \hat{O}, \rho\},
42+
```
43+
44+
is the Lindblad superoperator, and
45+
46+
```math
47+
\mathcal{H}[\hat{O}] \rho = \hat{O} \rho + \rho \hat{O}^\dagger - \mathrm{Tr}[\hat{O} \rho + \rho \hat{O}^\dagger] \rho,
48+
```
49+
50+
The above implementation takes into account 2 types of collapse operators. ``\hat{C}_i`` (`c_ops`) represent the collapse operators related to pure dissipation, while ``\hat{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 ``\hat{C}_i`` and ``\hat{S}_n``. The last term (``\mathcal{H}[\hat{S}_n] \rho(t)``) is the stochastic part given solely by the operators ``\hat{S}_n``.
51+
52+
53+
## [Example: Homodyne detection](@id doc-TE:Example:Homodyne-detection)
54+
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
56+
57+
```math
58+
J_x = \langle \hat{x} \rangle + dW/dt,
59+
```
60+
61+
where ``\hat{x}`` is the operator build from the `sc_ops` as
62+
63+
```math
64+
\hat{x} = \hat{S} + \hat{S}^\dagger
65+
```
66+
67+
```@setup smesolve
68+
using QuantumToolbox
69+
70+
using CairoMakie
71+
CairoMakie.enable_only_mime!(MIME"image/svg+xml"())
72+
```
73+
74+
```@example smesolve
75+
# parameters
76+
N = 20 # Fock space dimension
77+
Δ = 5 * 2 * π # cavity detuning
78+
κ = 2 # cavity decay rate
79+
α = 4 # intensity of initial state
80+
ntraj = 500 # number of trajectories
81+
82+
# operators
83+
a = destroy(N)
84+
x = a + a'
85+
H = Δ * a' * a
86+
c_ops = nothing
87+
sc_ops = [√(κ) * a]
88+
89+
ρ0 = coherent_dm(N, √α)
90+
tlist = 0:0.0025:1
91+
92+
stoc_sol = smesolve(
93+
H,
94+
ρ0,
95+
tlist,
96+
c_ops,
97+
sc_ops,
98+
e_ops = [x],
99+
ntraj = ntraj,
100+
)
101+
102+
# plot by CairoMakie.jl
103+
fig = Figure(size = (500, 350))
104+
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)
107+
108+
axislegend(ax, position = :rt)
109+
110+
fig
111+
```

0 commit comments

Comments
 (0)