-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from albertomercurio/dev/patch-3
Add more benchmarks
- Loading branch information
Showing
9 changed files
with
161 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
function benchmark_correlations_and_spectrum() | ||
N = 15 | ||
ω = 1 | ||
γ = 0.1 | ||
nth = 0.02 | ||
|
||
a = destroy(N) | ||
H = ω * a' * a | ||
c_ops = [sqrt(γ * (nth + 1)) * a, sqrt(γ * nth) * a'] | ||
|
||
ω_l = range(0, 3, length=1000) | ||
|
||
SUITE["Correlations and Spectrum"]["FFT Correlation"] = @benchmarkable spectrum($H, $ω_l, $(a'), $a, $c_ops, solver=FFTCorrelation(), progress_bar=false) | ||
|
||
SUITE["Correlations and Spectrum"]["Exponential Series"] = @benchmarkable spectrum($H, $ω_l, $(a'), $a, $c_ops) | ||
end | ||
|
||
benchmark_correlations_and_spectrum() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function H_dfd2(dims, p) | ||
Δ = p.Δ | ||
F = p.F | ||
J = p.J | ||
a = tensor(destroy(dims[1]), qeye(dims[2])) | ||
b = tensor(qeye(dims[1]), destroy(dims[2])) | ||
Δ * a' * a + F * (a + a') + Δ * b' * b + J * (a' * b + a * b') | ||
end | ||
function c_ops_dfd2(dims, p) | ||
κ = p.κ | ||
a = tensor(destroy(dims[1]), qeye(dims[2])) | ||
b = tensor(qeye(dims[1]), destroy(dims[2])) | ||
[√κ * a, √κ * b] | ||
end | ||
function e_ops_dfd2(dims, p) | ||
a = tensor(destroy(dims[1]), qeye(dims[2])) | ||
b = tensor(qeye(dims[1]), destroy(dims[2])) | ||
[a' * a, b' * b] | ||
end | ||
|
||
function benchmark_dfd() | ||
F, Δ, κ, J = 1, 0.25, 1, 0.05 | ||
maxdims = [50, 50] | ||
|
||
ψ0 = tensor(fock(3, 0), fock(20, 15)) | ||
dfd_params = (Δ=Δ, F=F, κ=κ, J=J) | ||
|
||
tlist = range(0, 15 / κ, 100) | ||
|
||
SUITE["Time Evolution"]["Dynamical Fock Dimension"] = @benchmarkable dfd_mesolve(H_dfd2, $ψ0, $tlist, c_ops_dfd2, $maxdims, $dfd_params, e_ops=e_ops_dfd2, progress_bar=false) | ||
end | ||
|
||
benchmark_dfd() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function benchmark_eigenvalues() | ||
N = 5 | ||
a = tensor(destroy(N), qeye(N)) | ||
a_d = a' | ||
b = tensor(qeye(N), destroy(N)) | ||
b_d = b' | ||
|
||
ωc = 1 | ||
ωb = 1 | ||
g = 0.2 | ||
κ = 0.01 | ||
n_thermal = 0.1 | ||
|
||
H = ωc * a_d * a + ωb * b_d * b + g * (a + a_d) * (b + b_d) | ||
c_ops = [√((1+n_thermal)*κ) * a, √κ * b, √(n_thermal*κ) * a_d] | ||
L = liouvillian(H, c_ops) | ||
|
||
SUITE["Eigenvalues"]["eigenstates"]["dense"] = @benchmarkable eigenstates($L) | ||
SUITE["Eigenvalues"]["eigenstates"]["sparse"] = @benchmarkable eigenstates($L, sparse=true, sigma=0.01, k=5) | ||
end | ||
|
||
benchmark_eigenvalues() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
using BenchmarkTools | ||
using QuantumToolbox | ||
|
||
suite = BenchmarkGroup() | ||
BLAS.set_num_threads(1) | ||
|
||
suite["steadystate"] = BenchmarkGroup(["steadystate"]) | ||
const SUITE = BenchmarkGroup() | ||
|
||
include("correlations_and_spectrum.jl") | ||
include("dynamical_fock_dimension.jl") | ||
include("eigenvalues.jl") | ||
include("steadystate.jl") | ||
include("timeevolution.jl") | ||
|
||
## steadystate ## | ||
|
||
N = 50 | ||
Δ = 0.1 | ||
F = 2 | ||
γ = 1 | ||
a = destroy(N) | ||
H = Δ * a' * a + F * (a + a') | ||
c_ops = [sqrt(γ) * a] | ||
|
||
suite["steadystate"]["driven-dissipative harmonic oscillator"] = @benchmarkable steadystate($H, $c_ops) | ||
|
||
## end ## | ||
|
||
|
||
BenchmarkTools.tune!(suite) | ||
results = run(suite, verbose = true) | ||
BenchmarkTools.tune!(SUITE) | ||
results = BenchmarkTools.run(SUITE, verbose = true) | ||
display(median(results)) | ||
|
||
BenchmarkTools.save(joinpath(@__DIR__, "benchmarks_output.json"), median(results)) | ||
BenchmarkTools.save("benchmarks_output.json", median(results)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function benchmark_steadystate() | ||
N = 50 | ||
Δ = 0.1 | ||
F = 2 | ||
γ = 1 | ||
nth = 5 | ||
|
||
a = destroy(N) | ||
H = Δ * a' * a + F * (a + a') | ||
c_ops = [sqrt(γ * (nth + 1)) * a, sqrt(γ * nth) * a'] | ||
|
||
SUITE["Steadystate"]["Direct"] = @benchmarkable steadystate($H, $c_ops) | ||
end | ||
|
||
benchmark_steadystate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function benchmark_timeevolution() | ||
ωc = 1 | ||
ωq = 1 | ||
g = 0.1 | ||
ωd = 0.99 | ||
F = 0.07 | ||
|
||
Δc = ωc - ωd | ||
Δq = ωq - ωd | ||
|
||
# Operators definition | ||
N = 20 # cutoff for the cavity Hilbert space | ||
a = tensor(destroy(N), qeye(2)) | ||
σm = tensor(qeye(N), sigmam()) | ||
σz = tensor(qeye(N), sigmaz()) | ||
|
||
# Hamiltonian | ||
H = Δc * a' * a + Δq * σz / 2 + g * (a' * σm + a * σm') + F * (a + a') | ||
|
||
e_ops = [a'*a, σz] | ||
|
||
# Initial state | ||
ψ0 = tensor(coherent(N, 0), fock(2, 1)) | ||
|
||
## sesolve ## | ||
|
||
tlist = range(0, 2π * 10 / g, 1000) | ||
|
||
SUITE["Time Evolution"]["time-independent"]["sesolve"] = @benchmarkable sesolve($H, $ψ0, $tlist, e_ops=$e_ops, progress_bar=false) | ||
|
||
## mesolve ## | ||
|
||
nth = 0.01 | ||
γ = 0.05 | ||
c_ops = [sqrt(γ * (nth + 1)) * a, sqrt(γ * nth) * a', sqrt(γ) * σm] | ||
|
||
tlist = range(0, 10/γ, 100) | ||
|
||
SUITE["Time Evolution"]["time-independent"]["mesolve"] = @benchmarkable mesolve($H, $ψ0, $tlist, $c_ops, e_ops=$e_ops, progress_bar=false) | ||
|
||
## mcsolve ## | ||
|
||
SUITE["Time Evolution"]["time-independent"]["mcsolve"]["Serial"] = @benchmarkable mcsolve($H, $ψ0, $tlist, $c_ops, n_traj=100, e_ops=$e_ops, progress_bar=false, ensemble_method=EnsembleSerial()) | ||
SUITE["Time Evolution"]["time-independent"]["mcsolve"]["Multithreaded"] = @benchmarkable mcsolve($H, $ψ0, $tlist, $c_ops, n_traj=100, e_ops=$e_ops, progress_bar=false, ensemble_method=EnsembleThreads()) | ||
end | ||
|
||
benchmark_timeevolution() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<iframe src="https://albertomercurio.github.io/QuantumToolbox.jl/benchmarks/" style="width: 100%; height: 100%; border: none;"></iframe> |