Skip to content

Commit ad5f0f9

Browse files
authored
Merge pull request #4 from USCqserver/#2-change_solve_CGME_to_solve_cgme
Change solve_CGME to solve_cgme in the corresponding tutorial
2 parents 136a3f1 + 81d1548 commit ad5f0f9

File tree

10 files changed

+30
-38
lines changed

10 files changed

+30
-38
lines changed

Diff for: html/redfield/03-CGME_ULE.html

+9-9
Large diffs are not rendered by default.

Diff for: markdown/redfield/03-CGME_ULE.md

+16-24
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ coupling to an Ohmic bath via $\sigma_z$ operator. We solve the open system dyna
1616

1717
Coarse-grained ME is a completely copositive ME that can be obtained by applying an additional time coarse graining approximate to the Redfield equation. More details of CGME can be found in [Mozgunov and Lidar](https://quantum-journal.org/papers/q-2020-02-06-227/). We first solve the original Redfield equation and CGME and compare the instantaneous ground state population of both cases.
1818

19-
````julia
20-
19+
```julia
2120
using OrdinaryDiffEq, Plots, LaTeXStrings
2221
using QuantumAnnealingTools
2322

@@ -37,16 +36,15 @@ U = InplaceUnitary(U)
3736

3837
@time solr = solve_redfield(annealing, tf, U, alg=Tsit5())
3938
# we set the integration error tolerance to 1e-5 for speed
40-
@time solc = solve_CGME(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
39+
@time solc = solve_cgme(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
4140
plot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel="t (ns)", ylabel="\$P_G(t)\$", label="Redfield")
4241
plot!(solc, H, [1], 0:0.01:tf, linewidth=2, label="CGME")
43-
````
44-
42+
```
4543

46-
````
47-
0.204915 seconds (2.96 M allocations: 78.345 MiB, 9.30% gc time)
48-
37.080598 seconds (489.73 M allocations: 19.392 GiB, 7.94% gc time)
49-
````
44+
```
45+
0.326442 seconds (3.08 M allocations: 80.058 MiB, 3.56% gc time)
46+
49.815768 seconds (489.73 M allocations: 19.392 GiB, 4.21% gc time)
47+
```
5048

5149

5250
![](figures/03-CGME_ULE_1_1.png)
@@ -61,8 +59,7 @@ $$g(t)=\frac{1}{2\pi}\int_{-\infty}^{\infty} \sqrt{\gamma(\omega)} e^{i\omega t}
6159

6260
Let's first see how it looks like compared with two point correlation function $C(t)$:
6361

64-
````julia
65-
62+
```julia
6663
using QuadGK
6764

6865
g(t) = quadgk((w)->sqrt(γ(w, bath))*exp(1.0im*w*t)/2/π, -Inf, Inf)[1]
@@ -77,17 +74,15 @@ plot!(t, real.(c_value), label="Re[C(t)]", linewidth=2)
7774
plot!(t, imag.(c_value), label="Im[C(t)]", linewidth=2)
7875
xlabel!("t (ns)")
7976
ylabel!("correlation")
80-
````
81-
77+
```
8278

8379
![](figures/03-CGME_ULE_2_1.png)
8480

8581

8682

8783
From above picture, we can see that the jump correlator and two point correlation function roughly have the same time scale. To avoid recalculating the inverse Fourier transform within the solver, we can precalcuate $g(t)$ and construct interpolation from these pre-computed values. This procedure can be done by the following code:
8884

89-
````julia
90-
85+
```julia
9186
t = range(-4,4,length=2000)
9287
g_value = g.(t)
9388
gf = construct_interpolations(t, g_value, extrapolation = "flat")
@@ -98,29 +93,26 @@ plot(t, real.(g_value), label="Re[g(t)]", linewidth=2)
9893
plot!(t, imag.(g_value), label="Im[g(t)]", linewidth=2)
9994
xlabel!("t (ns)")
10095
ylabel!("fitted jump correlator")
101-
````
102-
96+
```
10397

10498
![](figures/03-CGME_ULE_3_1.png)
10599

106100

107101

108102
Finally we solve ULE and compare the result with Redfield and CGME:
109103

110-
````julia
111-
104+
```julia
112105
ubath = ULEBath(gf)
113106
annealing = Annealing(H, u0; coupling=coupling, bath=ubath)
114107
@time solu = solve_ule(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
115108
plot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel="t (ns)", ylabel="\$P_G(t)\$", label="Redfield")
116109
plot!(solc, H, [1], 0:0.01:tf, linewidth=2, label="CGME")
117110
plot!(solu, H, [1], 0:0.01:tf, linewidth=2, label="ULE")
118-
````
119-
111+
```
120112

121-
````
122-
0.304092 seconds (5.09 M allocations: 133.387 MiB, 9.74% gc time)
123-
````
113+
```
114+
0.648544 seconds (5.09 M allocations: 133.383 MiB, 3.27% gc time)
115+
```
124116

125117

126118
![](figures/03-CGME_ULE_4_1.png)

Diff for: markdown/redfield/figures/03-CGME_ULE_1_1.png

-96 Bytes
Loading

Diff for: markdown/redfield/figures/03-CGME_ULE_2_1.png

-346 Bytes
Loading

Diff for: markdown/redfield/figures/03-CGME_ULE_3_1.png

-347 Bytes
Loading

Diff for: markdown/redfield/figures/03-CGME_ULE_4_1.png

-72 Bytes
Loading

Diff for: notebook/redfield/03-CGME_ULE.ipynb

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"outputs": [],
1212
"cell_type": "code",
1313
"source": [
14-
"using OrdinaryDiffEq, Plots, LaTeXStrings\nusing QuantumAnnealingTools\n\n# Hamiltonian\nH = DenseHamiltonian([(s)->1-s, (s)->s], -[σx, σz]/2, unit=:ħ)\n# initial state\nu0 = PauliVec[1][1]\n# coupling\ncoupling = ConstantCouplings([\"Z\"], unit=:ħ)\n# bath\nbath = Ohmic(1e-4, 4, 16)\nannealing = Annealing(H, u0; coupling=coupling, bath=bath)\n\ntf = 60\nU = solve_unitary(annealing, tf, alg=Tsit5(), abstol=1e-8, reltol=1e-8)\nU = InplaceUnitary(U)\n\n@time solr = solve_redfield(annealing, tf, U, alg=Tsit5())\n# we set the integration error tolerance to 1e-5 for speed\n@time solc = solve_CGME(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)\nplot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel=\"t (ns)\", ylabel=\"\\$P_G(t)\\$\", label=\"Redfield\")\nplot!(solc, H, [1], 0:0.01:tf, linewidth=2, label=\"CGME\")"
14+
"using OrdinaryDiffEq, Plots, LaTeXStrings\nusing QuantumAnnealingTools\n\n# Hamiltonian\nH = DenseHamiltonian([(s)->1-s, (s)->s], -[σx, σz]/2, unit=:ħ)\n# initial state\nu0 = PauliVec[1][1]\n# coupling\ncoupling = ConstantCouplings([\"Z\"], unit=:ħ)\n# bath\nbath = Ohmic(1e-4, 4, 16)\nannealing = Annealing(H, u0; coupling=coupling, bath=bath)\n\ntf = 60\nU = solve_unitary(annealing, tf, alg=Tsit5(), abstol=1e-8, reltol=1e-8)\nU = InplaceUnitary(U)\n\n@time solr = solve_redfield(annealing, tf, U, alg=Tsit5())\n# we set the integration error tolerance to 1e-5 for speed\n@time solc = solve_cgme(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)\nplot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel=\"t (ns)\", ylabel=\"\\$P_G(t)\\$\", label=\"Redfield\")\nplot!(solc, H, [1], 0:0.01:tf, linewidth=2, label=\"CGME\")"
1515
],
1616
"metadata": {},
1717
"execution_count": null
@@ -71,11 +71,11 @@
7171
"file_extension": ".jl",
7272
"mimetype": "application/julia",
7373
"name": "julia",
74-
"version": "1.5.0"
74+
"version": "1.5.2"
7575
},
7676
"kernelspec": {
7777
"name": "julia-1.5",
78-
"display_name": "Julia 1.5.0",
78+
"display_name": "Julia 1.5.2",
7979
"language": "julia"
8080
}
8181
},

Diff for: pdf/redfield/03-CGME_ULE.pdf

-1.26 KB
Binary file not shown.

Diff for: script/redfield/03-CGME_ULE.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ U = InplaceUnitary(U)
1818

1919
@time solr = solve_redfield(annealing, tf, U, alg=Tsit5())
2020
# we set the integration error tolerance to 1e-5 for speed
21-
@time solc = solve_CGME(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
21+
@time solc = solve_cgme(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
2222
plot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel="t (ns)", ylabel="\$P_G(t)\$", label="Redfield")
2323
plot!(solc, H, [1], 0:0.01:tf, linewidth=2, label="CGME")
2424

Diff for: tutorials/redfield/03-CGME_ULE.jmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ U = InplaceUnitary(U)
3535

3636
@time solr = solve_redfield(annealing, tf, U, alg=Tsit5())
3737
# we set the integration error tolerance to 1e-5 for speed
38-
@time solc = solve_CGME(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
38+
@time solc = solve_cgme(annealing, tf, U, alg=Tsit5(), int_atol=1e-5, int_rtol=1e-5)
3939
plot(solr, H, [1], 0:0.01:tf, linewidth=2, xlabel="t (ns)", ylabel="\$P_G(t)\$", label="Redfield")
4040
plot!(solc, H, [1], 0:0.01:tf, linewidth=2, label="CGME")
4141
```

0 commit comments

Comments
 (0)