Skip to content

Commit 256bd63

Browse files
committed
update doc page of two-time correlation functions
1 parent b7801ee commit 256bd63

File tree

2 files changed

+127
-4
lines changed

2 files changed

+127
-4
lines changed

docs/make.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ const PAGES = [
5050
"Solving Problems with Time-dependent Hamiltonians" => "users_guide/time_evolution/time_dependent.md",
5151
],
5252
"Solving for Steady-State Solutions" => "users_guide/steadystate.md",
53-
"Symmetries" => [],
5453
"Two-time correlation functions" => "users_guide/two_time_corr_func.md",
5554
"Extensions" => [
5655
"users_guide/extensions/cuda.md",

docs/src/users_guide/two_time_corr_func.md

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ With the `QuantumToolbox.jl` time-evolution function [`mesolve`](@ref), a state
99
```
1010
where ``\mathcal{G}(t, t_0)\{\cdot\}`` is the propagator defined by the equation of motion. The resulting density matrix can then be used to evaluate the expectation values of arbitrary combinations of same-time operators.
1111

12-
To calculate two-time correlation functions on the form ``\left\langle \hat{A}(t+\tau) \hat{B}(t) \right\rangle``, we can use the quantum regression theorem (see, e.g., [Gardiner-Zoller2004](@cite)) to write
12+
To calculate two-time correlation functions on the form ``\left\langle \hat{A}(t+\tau) \hat{B}(t) \right\rangle``, we can use the quantum regression theorem [see, e.g., [Gardiner-Zoller2004](@cite)] to write
1313

1414
```math
1515
\left\langle \hat{A}(t+\tau) \hat{B}(t) \right\rangle = \textrm{Tr} \left[\hat{A} \mathcal{G}(t+\tau, t)\{\hat{B}\hat{\rho}(t)\} \right] = \textrm{Tr} \left[\hat{A} \mathcal{G}(t+\tau, t)\{\hat{B} \mathcal{G}(t, 0)\{\hat{\rho}(0)\}\} \right],
@@ -71,7 +71,7 @@ fig
7171

7272
## Emission spectrum
7373

74-
Given a correlation function ``\langle \hat{A}(\tau) \hat{B}(0) \rangle``, we can define the corresponding power spectrum as
74+
Given a correlation function ``\left\langle \hat{A}(\tau) \hat{B}(0) \right\rangle``, we can define the corresponding power spectrum as
7575

7676
```math
7777
S(\omega) = \int_{-\infty}^\infty \left\langle \hat{A}(\tau) \hat{B}(0) \right\rangle e^{-i \omega \tau} d \tau
@@ -133,8 +133,132 @@ fig
133133

134134
## Non-steadystate correlation function
135135

136-
The following part of this page is still under construction, please visit [API](@ref doc-API) first.
136+
More generally, we can also calculate correlation functions of the kind ``\left\langle \hat{A}(t_1 + t_2) \hat{B}(t_1) \right\rangle``, i.e., the correlation function of a system that is not in its steady state. In `QuantumToolbox.jl`, we can evaluate such correlation functions using the function [`correlation_2op_2t`](@ref). The default behavior of this function is to return a matrix with the correlations as a function of the two time coordinates (``t_1`` and ``t_2``).
137+
138+
```@example correlation_and_spectrum
139+
tlist = LinRange(0, 10.0, 200)
140+
141+
N = 10
142+
a = destroy(N)
143+
x = a' + a
144+
H = a' * a
145+
146+
c_ops = [sqrt(0.25) * a]
147+
148+
α = 2.5
149+
ρ0 = coherent_dm(N, α)
150+
151+
corr = correlation_2op_2t(H, ρ0, tlist, tlist, c_ops, x, x; progress_bar = Val(false))
152+
153+
# plot by CairoMakie.jl
154+
fig = Figure(size = (500, 400))
155+
156+
ax = Axis(fig[1, 1], title = L"\langle \hat{x}(t_1 + t_2) \hat{x}(t_1) \rangle", xlabel = L"Time $t_2$", ylabel = L"Time $t_1$")
157+
heatmap!(ax, tlist, tlist, real.(corr))
158+
159+
fig
160+
```
137161

138162
### Example: first-order optical coherence function
139163

164+
This example demonstrates how to calculate a correlation function on the form ``\left\langle \hat{A}(\tau) \hat{B}(0) \right\rangle`` for a non-steady initial state. Consider an oscillator that is interacting with a thermal environment. If the oscillator initially is in a coherent state, it will gradually decay to a thermal (incoherent) state. The amount of coherence can be quantified using the first-order optical coherence function
165+
166+
```math
167+
g^{(1)}(\tau) = \frac{\left\langle \hat{a}^\dagger(\tau) \hat{a}(0) \right\rangle}{\sqrt{\left\langle \hat{a}^\dagger(\tau) \hat{a}(\tau) \right\rangle \left\langle \hat{a}^\dagger(0) \hat{a}(0)\right\rangle}}.
168+
```
169+
For a coherent state ``\vert g^{(1)}(\tau) \vert = 1``, and for a completely incoherent (thermal) state ``g^{(1)}(\tau) = 0``. The following code calculates and plots ``g^{(1)}(\tau)`` as a function of ``\tau``:
170+
171+
```@example correlation_and_spectrum
172+
τlist = LinRange(0, 10, 200)
173+
174+
# Hamiltonian
175+
N = 15
176+
a = destroy(N)
177+
H = 2 * π * a' * a
178+
179+
# collapse operator
180+
G1 = 0.75
181+
n_th = 2.00 # bath temperature in terms of excitation number
182+
c_ops = [
183+
sqrt(G1 * (1 + n_th)) * a,
184+
sqrt(G1 * n_th) * a'
185+
]
186+
187+
# start with a coherent state of α = 2.0
188+
ρ0 = coherent_dm(N, 2.0)
189+
190+
# first calculate the occupation number as a function of time
191+
n = mesolve(H, ρ0, τlist, c_ops, e_ops = [a' * a], progress_bar = Val(false)).expect[1,:]
192+
n0 = n[1] # occupation number at τ = 0
193+
194+
# calculate the correlation function G1 and normalize with n to obtain g1
195+
g1 = correlation_2op_1t(H, ρ0, τlist, c_ops, a', a, progress_bar = Val(false))
196+
g1 = g1 ./ sqrt.(n .* n0)
197+
198+
# plot by CairoMakie.jl
199+
fig = Figure(size = (500, 350))
200+
ax = Axis(fig[1, 1], title = "Decay of a coherent state to an incoherent (thermal) state", xlabel = L"Time $\tau$")
201+
lines!(ax, τlist, real(g1), label = L"g^{(1)}(\tau)", linestyle = :solid)
202+
lines!(ax, τlist, real(n), label = L"n(\tau)", linestyle = :dash)
203+
204+
axislegend(ax, position = :rt)
205+
206+
fig
207+
```
208+
140209
### Example: second-order optical coherence function
210+
211+
The second-order optical coherence function, with time-delay ``\tau``, is defined as
212+
213+
```math
214+
g^{(2)}(\tau) = \frac{\left\langle \hat{a}^\dagger(0) \hat{a}^\dagger(\tau) \hat{a}(\tau) \hat{a}(0) \right\rangle}{\left\langle \hat{a}^\dagger(0) \hat{a}(0) \right\rangle^2}.
215+
```
216+
217+
For a coherent state ``g^{(2)}(\tau) = 1``, for a thermal state ``g^{(2)}(\tau = 0) = 2`` and it decreases as a function of time (bunched photons, they tend to appear together), and for a Fock state with ``n``-photons ``g^{(2)}(\tau = 0) = n(n-1)/n^2 < 1`` and it increases with time (anti-bunched photons, more likely to arrive separated in time).
218+
219+
To calculate this type of correlation function with `QuantumToolbox.jl`, we can use [`correlation_3op_1t`](@ref), which computes a correlation function on the form ``\left\langle \hat{A}(0) \hat{B}(\tau) \hat{C}(0) \right\rangle`` (three operators and one delay-time vector). We first have to combine the central two operators into one single one as they are evaluated at the same time, e.g. here we do ``\hat{B}(\tau) = \hat{a}^\dagger(\tau) \hat{a}(\tau) = (\hat{a}^\dagger\hat{a})(\tau)``.
220+
221+
The following code calculates and plots ``g^{(2)}(\tau)`` as a function of ``\tau`` for a coherent, thermal and Fock state:
222+
223+
```@example correlation_and_spectrum
224+
τlist = LinRange(0, 25, 200)
225+
226+
# Hamiltonian
227+
N = 25
228+
a = destroy(N)
229+
H = 2 * π * a' * a
230+
231+
κ = 0.25
232+
n_th = 2.0 # bath temperature in terms of excitation number
233+
c_ops = [
234+
sqrt(κ * (1 + n_th)) * a,
235+
sqrt(κ * n_th) * a'
236+
]
237+
238+
cases = [
239+
Dict("state" => coherent_dm(N, sqrt(2)), "label" => "coherent state", "lstyle" => :solid),
240+
Dict("state" => thermal_dm(N, 2), "label" => "thermal state", "lstyle" => :dash),
241+
Dict("state" => fock_dm(N, 2), "label" => "Fock state", "lstyle" => :dashdot),
242+
]
243+
244+
# plot by CairoMakie.jl
245+
fig = Figure(size = (500, 350))
246+
ax = Axis(fig[1, 1], xlabel = L"Time $\tau$", ylabel = L"g^{(2)}(\tau)")
247+
248+
for case in cases
249+
ρ0 = case["state"]
250+
251+
# calculate the occupation number at τ = 0
252+
n0 = expect(a' * a, ρ0)
253+
254+
# calculate the correlation function g2
255+
g2 = correlation_3op_1t(H, ρ0, τlist, c_ops, a', a' * a, a, progress_bar = Val(false))
256+
g2 = g2 ./ n0^2
257+
258+
lines!(ax, τlist, real(g2), label = case["label"], linestyle = case["lstyle"])
259+
end
260+
261+
axislegend(ax, position = :rt)
262+
263+
fig
264+
```

0 commit comments

Comments
 (0)