Skip to content

Commit 13ef433

Browse files
Rates spectrum (#402)
* properly pass the kwarg rates to the function spectrum * typo rates test
1 parent 7e72226 commit 13ef433

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/timecorrelations.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,32 @@ function spectrum(omega_samplepoints,
132132
H::AbstractOperator, J, op;
133133
rho0=tensor(basisstate(H.basis_l, 1), dagger(basisstate(H.basis_r, 1))),
134134
tol=1e-4,
135-
rho_ss=steadystate.master(H, J; tol=tol, rho0=rho0)[end][end],
135+
rates=nothing,
136+
rho_ss=steadystate.master(H, J; rates=rates, tol=tol, rho0=rho0)[end][end],
136137
kwargs...)
137138
domega = minimum(diff(omega_samplepoints))
138139
dt = 2*pi/abs(omega_samplepoints[end] - omega_samplepoints[1])
139140
T = 2*pi/domega
140141
tspan = [0.:dt:T;]
141-
exp_values = correlation(tspan, rho_ss, H, J, dagger(op), op, kwargs...)
142+
exp_values = correlation(tspan, rho_ss, H, J, dagger(op), op; rates=rates, kwargs...)
142143
S = 2dt.*fftshift(real(fft(exp_values)))
143144
return omega_samplepoints, S
144145
end
145146

146147
function spectrum(H::AbstractOperator, J, op;
147148
rho0=tensor(basisstate(H.basis_l, 1), dagger(basisstate(H.basis_r, 1))),
148149
tol=1e-4,
149-
rho_ss=steadystate.master(H, J; tol=tol)[end][end],
150+
rates=nothing,
151+
rho_ss=steadystate.master(H, J; rates=rates, tol=tol)[end][end],
150152
kwargs...)
151-
tspan, exp_values = correlation(rho_ss, H, J, dagger(op), op, tol=tol, kwargs...)
153+
tspan, exp_values = correlation(rho_ss, H, J, dagger(op), op; rates=rates, tol=tol, kwargs...)
152154
dtmin = minimum(diff(tspan))
153155
T = tspan[end] - tspan[1]
154156
tspan = Float64[0.:dtmin:T;]
155157
n = length(tspan)
156158
omega = mod(n, 2) == 0 ? [-n/2:n/2-1;] : [-(n-1)/2:(n-1)/2;]
157159
omega .*= 2pi/T
158-
return spectrum(omega, H, J, op; tol=tol, rho_ss=rho_ss, kwargs...)
160+
return spectrum(omega, H, J, op; tol=tol, rates=rates, rho_ss=rho_ss, kwargs...)
159161
end
160162

161163

test/test_timecorrelations.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using Test
22
using QuantumOptics
33
using LinearAlgebra
44

5-
@testset "timecorrelations" begin
5+
# @testset "timecorrelations" begin
66

77
ωc = 1.2
88
ωa = 0.9
@@ -72,4 +72,16 @@ omegaFFT, SFFT = timecorrelations.correlation2spectrum(tspan, exp_values)
7272
tspan[5] = tspan[4]
7373
@test_throws ArgumentError timecorrelations.correlation2spectrum(tspan, exp_values)
7474

75-
end # testset
75+
# tests kwarg rates
76+
J5 = [embed(basis, 1, sm), embed(basis, 1, sp), embed(basis, 2, destroy(fockbasis))]
77+
rates5 = [γ, 0.5γ, κ]
78+
exp_values5 = timecorrelations.correlation(tspan, ρ₀, H, J5, dagger(op), op; rates=rates5)
79+
@test abs(exp_values[end] - exp_values5[end] ) < 1e-8
80+
81+
omega5, S5 = timecorrelations.spectrum(omega_sample, H, J5, op; rho_ss=ρ₀, rates=rates5)
82+
@test abs(sum(S .- S5)) < 1e-8
83+
84+
omega5_2, S5_2 = timecorrelations.spectrum(H, J5, op; rates=rates5, tol=1e-3)
85+
@test abs(sum(S2 .- S5_2)) < 1e-8
86+
87+
# end # testset

0 commit comments

Comments
 (0)