Skip to content

Commit d143aa9

Browse files
committed
make the output correlation Matrix align with QuTiP
1 parent 256bd63 commit d143aa9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

docs/src/users_guide/two_time_corr_func.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ fig
136136
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``).
137137

138138
```@example correlation_and_spectrum
139-
tlist = LinRange(0, 10.0, 200)
139+
t1_list = LinRange(0, 10.0, 200)
140+
t2_list = LinRange(0, 10.0, 200)
140141
141142
N = 10
142143
a = destroy(N)
@@ -148,13 +149,14 @@ c_ops = [sqrt(0.25) * a]
148149
α = 2.5
149150
ρ0 = coherent_dm(N, α)
150151
151-
corr = correlation_2op_2t(H, ρ0, tlist, tlist, c_ops, x, x; progress_bar = Val(false))
152+
corr = correlation_2op_2t(H, ρ0, t1_list, t2_list, c_ops, x, x; progress_bar = Val(false))
152153
153154
# plot by CairoMakie.jl
154155
fig = Figure(size = (500, 400))
155156
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))
157+
ax = Axis(fig[1, 1], title = L"\langle \hat{x}(t_1 + t_2) \hat{x}(t_1) \rangle", xlabel = L"Time $t_1$", ylabel = L"Time $t_2$")
158+
159+
heatmap!(ax, t1_list, t2_list, real(corr))
158160
159161
fig
160162
```

src/correlations.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ function correlation_3op_2t(
5959

6060
corr = map((t, ρ) -> mesolve(L, C * ρ * A, τlist .+ t, e_ops = [B]; kwargs...).expect[1, :], tlist, ρt)
6161

62-
return reduce(hcat, corr)
62+
# make the output correlation Matrix align with QuTiP
63+
# 1st dimension corresponds to tlist
64+
# 2nd dimension corresponds to τlist
65+
return reduce(vcat, transpose.(corr))
6366
end
6467

6568
@doc raw"""
@@ -96,7 +99,7 @@ function correlation_3op_1t(
9699
}
97100
corr = correlation_3op_2t(H, ψ0, [0], τlist, c_ops, A, B, C; kwargs...)
98101

99-
return corr[:, 1]
102+
return corr[1, :] # 1 means tlist[1] = 0
100103
end
101104

102105
@doc raw"""
@@ -179,5 +182,5 @@ function correlation_2op_1t(
179182
}
180183
corr = correlation_2op_2t(H, ψ0, [0], τlist, c_ops, A, B; reverse = reverse, kwargs...)
181184

182-
return corr[:, 1]
185+
return corr[1, :] # 1 means tlist[1] = 0
183186
end

0 commit comments

Comments
 (0)