Skip to content

Commit 4c8edb7

Browse files
committed
remove Plots.jl
1 parent 6abfe6b commit 4c8edb7

File tree

4 files changed

+91
-64
lines changed

4 files changed

+91
-64
lines changed

HierarchicalEOM.jl/cavityQED.qmd

Lines changed: 88 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ engine: julia
1010
## Package Imports
1111
```{julia}
1212
using HierarchicalEOM
13-
using LaTeXStrings
14-
import Plots
13+
using CairoMakie
1514
```
1615

1716
## Introduction
@@ -53,22 +52,26 @@ N = 3 ## system cavity Hilbert space cutoff
5352
ωA = 2
5453
ωc = 2
5554
g = 0.1
56-
## operators
55+
56+
# operators
5757
a_c = destroy(N)
5858
I_c = qeye(N)
5959
σz_A = sigmaz()
6060
σm_A = sigmam()
6161
I_A = qeye(2)
62-
## operators in tensor-space
62+
63+
# operators in tensor-space
6364
a = tensor(a_c, I_A)
6465
σz = tensor(I_c, σz_A)
6566
σm = tensor(I_c, σm_A)
66-
## Hamiltonian
67+
68+
# Hamiltonian
6769
H_A = 0.5 * ωA * σz
6870
H_c = ωc * a' * a
6971
H_int = g * (a' * σm + a * σm')
7072
H_s = H_A + H_c + H_int
71-
## initial state
73+
74+
# initial state
7275
ψ0 = tensor(basis(N, 0), basis(2, 0));
7376
```
7477

@@ -94,13 +97,19 @@ Before incorporating the correlation function into the HEOMLS matrix, it is esse
9497
tlist_test = 0:0.1:10;
9598
Bath_test = Boson_DrudeLorentz_Pade(a + a', Γ, W, kT, 1000);
9699
Ct = correlation_function(Bath, tlist_test);
97-
Ct2 = correlation_function(Bath_test, tlist_test);
98-
Plots.plot(tlist_test, real(Ct), label = "N=20 (real part )", linestyle = :dash, linewidth = 3)
99-
Plots.plot!(tlist_test, real(Ct2), label = "N=1000 (real part)", linestyle = :solid, linewidth = 3)
100-
Plots.plot!(tlist_test, imag(Ct), label = "N=20 (imag part)", linestyle = :dash, linewidth = 3)
101-
Plots.plot!(tlist_test, imag(Ct2), label = "N=1000 (imag part)", linestyle = :solid, linewidth = 3)
102-
Plots.xaxis!("t")
103-
Plots.yaxis!("C(t)")
100+
Ct2 = correlation_function(Bath_test, tlist_test)
101+
102+
# plot
103+
fig = Figure(size = (500, 350))
104+
ax = Axis(fig[1, 1], xlabel = L"t", ylabel = L"C(t)")
105+
lines!(ax, tlist_test, real(Ct2), label = L"$N=1000$ (real part)", linestyle = :solid)
106+
lines!(ax, tlist_test, real(Ct), label = L"$N=20$ (real part)", linestyle = :dash)
107+
lines!(ax, tlist_test, imag(Ct2), label = L"$N=1000$ (imag part)", linestyle = :solid)
108+
lines!(ax, tlist_test, imag(Ct), label = L"$N=20$ (imag part)", linestyle = :dash)
109+
110+
axislegend(ax, position = :rt)
111+
112+
fig
104113
```
105114

106115
## Construct HEOMLS matrix
@@ -149,83 +158,102 @@ np_steady_H = expect(a' * a, steady_H)
149158
plot results
150159

151160
```{julia}
152-
p1 = Plots.plot(
153-
t_list,
154-
[σz_evo_H, ones(length(t_list)) .* σz_steady_H],
155-
label = [L"\langle \sigma_z \rangle" L"\langle \sigma_z \rangle ~~(\textrm{steady})"],
156-
linewidth = 3,
157-
linestyle = [:solid :dash],
158-
)
159-
p2 = Plots.plot(
160-
t_list,
161-
[np_evo_H, ones(length(t_list)) .* np_steady_H],
162-
label = [L"\langle a^\dagger a \rangle" L"\langle a^\dagger a \rangle ~~(\textrm{steady})"],
163-
linewidth = 3,
164-
linestyle = [:solid :dash],
165-
)
166-
Plots.plot(p1, p2, layout = [1, 1])
167-
Plots.xaxis!("t")
161+
fig = Figure(size = (600, 350))
162+
163+
ax1 = Axis(fig[1, 1], xlabel = L"t")
164+
lines!(ax1, t_list, σz_evo_H, label = L"\langle \sigma_z \rangle", linestyle = :solid)
165+
lines!(ax1, t_list, ones(length(t_list)) .* σz_steady_H, label = L"\langle \sigma_z \rangle ~~(\textrm{steady})", linestyle = :dash)
166+
axislegend(ax1, position = :rt)
167+
168+
ax2 = Axis(fig[2, 1], xlabel = L"t")
169+
lines!(ax2, t_list, np_evo_H, label = L"\langle a^\dagger a \rangle", linestyle = :solid)
170+
lines!(ax2, t_list, ones(length(t_list)) .* np_steady_H, label = L"\langle a^\dagger a \rangle ~~(\textrm{steady})", linestyle = :dash)
171+
axislegend(ax2, position = :rt)
172+
173+
fig
168174
```
169175

170176
## Power spectrum
171177

172178
```{julia}
173179
ω_list = 1:0.01:3
174180
psd_H = PowerSpectrum(M_Heom, steady_H, a, ω_list)
175-
Plots.plot(ω_list, psd_H, linewidth = 3)
176-
Plots.xaxis!(L"\omega")
181+
182+
# plot
183+
fig = Figure(size = (500, 350))
184+
ax = Axis(fig[1, 1], xlabel = L"\omega")
185+
lines!(ax, ω_list, psd_H)
186+
187+
fig
177188
```
178189

179190
## Compare with Master Eq. approach
180191

181192
The Lindblad master equations which describes the cavity couples to an extra bosonic reservoir with [Drude-Lorentzian spectral density](https://qutip.org/HierarchicalEOM.jl/stable/bath_boson/Boson_Drude_Lorentz/#Boson-Drude-Lorentz) is given by
182193

183194
```{julia}
184-
## Drude_Lorentzian spectral density
195+
# Drude_Lorentzian spectral density
185196
Drude_Lorentz(ω, Γ, W) = 4 * Γ * W * ω / ((ω)^2 + (W)^2)
186-
## Bose-Einstein distribution
197+
198+
# Bose-Einstein distribution
187199
n_b(ω, kT) = 1 / (exp(ω / kT) - 1)
188-
## build the jump operators
189-
jump_op =
190-
[sqrt(Drude_Lorentz(ωc, Γ, W) * (n_b(ωc, kT) + 1)) * a, sqrt(Drude_Lorentz(ωc, Γ, W) * (n_b(ωc, kT))) * a', J_pump];
191-
## construct the HEOMLS matrix for master equation
200+
201+
# build the jump operators
202+
jump_op = [
203+
sqrt(Drude_Lorentz(ωc, Γ, W) * (n_b(ωc, kT) + 1)) * a,
204+
sqrt(Drude_Lorentz(ωc, Γ, W) * (n_b(ωc, kT))) * a',
205+
J_pump
206+
];
207+
208+
# construct the HEOMLS matrix for master equation
192209
M_master = M_S(H_s)
193210
M_master = addBosonDissipator(M_master, jump_op)
194-
## time evolution
211+
212+
# time evolution
195213
sol_M = HEOMsolve(M_master, ψ0, t_list; e_ops = [σz, a' * a]);
196-
## steady state
214+
215+
# steady state
197216
steady_M = steadystate(M_master);
198-
## expectation value of σz
217+
218+
# expectation value of σz
199219
σz_evo_M = real(sol_M.expect[1, :])
200220
σz_steady_M = expect(σz, steady_M)
201-
## average photon number
221+
222+
# average photon number
202223
np_evo_M = real(sol_M.expect[2, :])
203-
np_steady_M = expect(a' * a, steady_M)
204-
p1 = Plots.plot(
205-
t_list,
206-
[σz_evo_M, ones(length(t_list)) .* σz_steady_M],
207-
label = [L"\langle \sigma_z \rangle" L"\langle \sigma_z \rangle ~~(\textrm{steady})"],
208-
linewidth = 3,
209-
linestyle = [:solid :dash],
210-
)
211-
p2 = Plots.plot(
212-
t_list,
213-
[np_evo_M, ones(length(t_list)) .* np_steady_M],
214-
label = [L"\langle a^\dagger a \rangle" L"\langle a^\dagger a \rangle ~~(\textrm{steady})"],
215-
linewidth = 3,
216-
linestyle = [:solid :dash],
217-
)
218-
Plots.plot(p1, p2, layout = [1, 1])
219-
Plots.xaxis!("t")
224+
np_steady_M = expect(a' * a, steady_M);
225+
```
226+
227+
plot results
228+
229+
```{julia}
230+
fig = Figure(size = (600, 350))
231+
232+
ax1 = Axis(fig[1, 1], xlabel = L"t")
233+
lines!(ax1, t_list, σz_evo_M, label = L"\langle \sigma_z \rangle", linestyle = :solid)
234+
lines!(ax1, t_list, ones(length(t_list)) .* σz_steady_M, label = L"\langle \sigma_z \rangle ~~(\textrm{steady})", linestyle = :dash)
235+
axislegend(ax1, position = :rt)
236+
237+
ax2 = Axis(fig[2, 1], xlabel = L"t")
238+
lines!(ax2, t_list, np_evo_M, label = L"\langle a^\dagger a \rangle", linestyle = :solid)
239+
lines!(ax2, t_list, ones(length(t_list)) .* np_steady_M, label = L"\langle a^\dagger a \rangle ~~(\textrm{steady})", linestyle = :dash)
240+
axislegend(ax2, position = :rt)
241+
242+
fig
220243
```
221244

222245
We can also calculate the power spectrum
223246

224247
```{julia}
225248
ω_list = 1:0.01:3
226249
psd_M = PowerSpectrum(M_master, steady_M, a, ω_list)
227-
Plots.plot(ω_list, psd_M, linewidth = 3)
228-
Plots.xaxis!(L"\omega")
250+
251+
# plot
252+
fig = Figure(size = (500, 350))
253+
ax = Axis(fig[1, 1], xlabel = L"\omega")
254+
lines!(ax, ω_list, psd_M)
255+
256+
fig
229257
```
230258

231259
Due to the weak coupling between the system and an extra bosonic environment, the Master equation's outcome is expected to be similar to the results obtained from the HEOM method.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include _environment
66
default: help
77

88
render:
9-
${JULIA} --project=@. -e 'import Pkg; Pkg.instantiate(); Pkg.resolve(); Pkg.precompile(); using QuantumToolbox, HierarchicalEOM;'
9+
${JULIA} --project=@. -e 'import Pkg; Pkg.resolve(); Pkg.instantiate(); Pkg.precompile(); using QuantumToolbox, HierarchicalEOM;'
1010
${JULIA} --project=@. -e 'using QuantumToolbox, HierarchicalEOM;'
1111
${QUARTO} render
1212

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[deps]
22
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
33
HierarchicalEOM = "a62dbcb7-80f5-4d31-9a88-8b19fd92b128"
4-
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
5-
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
64
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
5+
QuartoNotebookRunner = "4c0109c6-14e9-4c88-93f0-2b974d3468f4"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ make render
2525
or
2626
```shell
2727
source _environment
28-
julia --project=@. -e 'import Pkg; Pkg.instantiate(); Pkg.resolve(); Pkg.precompile()'
28+
julia --project=@. -e 'import Pkg; Pkg.resolve(); Pkg.instantiate(); Pkg.precompile()'
2929
julia --project=@. -e 'using QuantumToolbox, HierarchicalEOM;'
3030
quarto render
3131
```

0 commit comments

Comments
 (0)