Skip to content

Commit 77e320c

Browse files
Change steadystate solver structure
1 parent 4943fd5 commit 77e320c

File tree

4 files changed

+56
-37
lines changed

4 files changed

+56
-37
lines changed

docs/src/resources/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,12 @@ liouvillian_generalized
212212

213213
```@docs
214214
steadystate
215-
steadystate_floquet
215+
steadystate_fourier
216216
SteadyStateDirectSolver
217217
SteadyStateEigenSolver
218218
SteadyStateLinearSolver
219219
SteadyStateODESolver
220+
SSFloquetEffectiveLiouvillian
220221
```
221222

222223
### [Dynamical Shifted Fock method](@id doc-API:Dynamical-Shifted-Fock-method)

docs/src/users_guide/steadystate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@ fig
121121

122122
## Calculate steady state for periodically driven systems
123123

124-
See the docstring of [`steadystate_floquet`](@ref) for more details.
124+
See the docstring of [`steadystate_fourier`](@ref) for more details.

src/steadystate.jl

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
export steadystate, steadystate_floquet
1+
export steadystate, steadystate_fourier, steadystate_floquet
22
export SteadyStateSolver,
33
SteadyStateDirectSolver,
44
SteadyStateEigenSolver,
55
SteadyStateLinearSolver,
66
SteadyStateODESolver,
7-
SteadyStateFloquetSolver,
8-
SSFloquetLinearSolve,
97
SSFloquetEffectiveLiouvillian
108

119
abstract type SteadyStateSolver end
12-
abstract type SteadyStateFloquetSolver end
1310

1411
@doc raw"""
1512
SteadyStateDirectSolver()
@@ -58,16 +55,18 @@ Base.@kwdef struct SteadyStateODESolver{MT<:OrdinaryDiffEqAlgorithm} <: SteadySt
5855
alg::MT = Tsit5()
5956
end
6057

61-
Base.@kwdef struct SSFloquetLinearSolve{
62-
MT<:Union{SciMLLinearSolveAlgorithm,Nothing},
63-
PlT<:Union{Function,Nothing},
64-
PrT<:Union{Function,Nothing},
65-
} <: SteadyStateFloquetSolver
66-
alg::MT = KrylovJL_GMRES()
67-
Pl::PlT = nothing
68-
Pr::PrT = nothing
69-
end
70-
Base.@kwdef struct SSFloquetEffectiveLiouvillian{SSST<:SteadyStateSolver} <: SteadyStateFloquetSolver
58+
@doc raw"""
59+
SSFloquetEffectiveLiouvillian(steadystate_solver = SteadyStateDirectSolver())
60+
61+
A solver which solves [`steadystate_fourier`](@ref) by first extracting an effective time-independent Liouvillian and then using the `steadystate_solver` to extract the steadystate..
62+
63+
# Parameters
64+
- `steadystate_solver::SteadyStateSolver=SteadyStateDirectSolver()`: The solver to use for the effective Liouvillian.
65+
66+
!!! note
67+
This solver is only available for [`steadystate_fourier`](@ref).
68+
"""
69+
Base.@kwdef struct SSFloquetEffectiveLiouvillian{SSST<:SteadyStateSolver} <: SteadyStateSolver
7170
steadystate_solver::SSST = SteadyStateDirectSolver()
7271
end
7372

@@ -93,6 +92,12 @@ function steadystate(
9392
solver::SteadyStateSolver = SteadyStateDirectSolver(),
9493
kwargs...,
9594
) where {OpType<:Union{OperatorQuantumObject,SuperOperatorQuantumObject}}
95+
solver isa SSFloquetEffectiveLiouvillian && throw(
96+
ArgumentError(
97+
"The solver `SSFloquetEffectiveLiouvillian` is only available for the `steadystate_fourier` function.",
98+
),
99+
)
100+
96101
L = liouvillian(H, c_ops)
97102

98103
return _steadystate(L, solver; kwargs...)
@@ -255,15 +260,15 @@ function _steadystate_ode_condition(integrator, abstol, reltol, min_t)
255260
end
256261

257262
@doc raw"""
258-
steadystate_floquet(
259-
H_0::QuantumObject{OpType1},
260-
H_p::QuantumObject{OpType2},
261-
H_m::QuantumObject{OpType3},
263+
steadystate_fourier(
264+
H_0::QuantumObject,
265+
H_p::QuantumObject,
266+
H_m::QuantumObject,
262267
ωd::Number,
263268
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
264269
n_max::Integer = 2,
265270
tol::R = 1e-8,
266-
solver::FSolver = SSFloquetLinearSolve,
271+
solver::FSolver = SteadyStateLinearSolver(),
267272
kwargs...,
268273
)
269274
@@ -273,11 +278,11 @@ Considering a monochromatic drive at frequency ``\omega_d``, we divide it into t
273278
`H_p` and `H_m`, where `H_p` oscillates
274279
as ``e^{i \omega t}`` and `H_m` oscillates as ``e^{-i \omega t}``.
275280
There are two solvers available for this function:
276-
- `SSFloquetLinearSolve`: Solves the linear system of equations.
281+
- `SteadyStateLinearSolver`: Solves the linear system of equations.
277282
- `SSFloquetEffectiveLiouvillian`: Solves the effective Liouvillian.
278283
For both cases, `n_max` is the number of Fourier components to consider, and `tol` is the tolerance for the solver.
279284
280-
In the case of `SSFloquetLinearSolve`, the full linear system is solved at once:
285+
In the case of `SteadyStateLinearSolver`, the full linear system is solved at once:
281286
282287
```math
283288
( \mathcal{L}_0 - i n \omega_d ) \hat{\rho}_n + \mathcal{L}_1 \hat{\rho}_{n-1} + \mathcal{L}_{-1} \hat{\rho}_{n+1} = 0
@@ -320,7 +325,10 @@ This will allow to simultaneously obtain all the ``\hat{\rho}_n``.
320325
In the case of `SSFloquetEffectiveLiouvillian`, instead, the effective Liouvillian is calculated using the matrix continued fraction method.
321326
322327
!!! note "different return"
323-
The two solvers returns different objects. The `SSFloquetLinearSolve` returns a list of [`QuantumObject`](@ref), containing the density matrices for each Fourier component (``\hat{\rho}_{-n}``, with ``n`` from ``0`` to ``n_\textrm{max}``), while the `SSFloquetEffectiveLiouvillian` returns only ``\hat{\rho}_0``.
328+
The two solvers returns different objects. The `SteadyStateLinearSolver` returns a list of [`QuantumObject`](@ref), containing the density matrices for each Fourier component (``\hat{\rho}_{-n}``, with ``n`` from ``0`` to ``n_\textrm{max}``), while the `SSFloquetEffectiveLiouvillian` returns only ``\hat{\rho}_0``.
329+
330+
!!! note
331+
`steadystate_floquet` is a synonym of `steadystate_fourier`.
324332
325333
## Arguments
326334
- `H_0::QuantumObject`: The Hamiltonian or the Liouvillian of the undriven system.
@@ -330,38 +338,38 @@ In the case of `SSFloquetEffectiveLiouvillian`, instead, the effective Liouvilli
330338
- `c_ops::Union{Nothing,AbstractVector} = nothing`: The optional collapse operators.
331339
- `n_max::Integer = 2`: The number of Fourier components to consider.
332340
- `tol::R = 1e-8`: The tolerance for the solver.
333-
- `solver::FSolver = SSFloquetLinearSolve`: The solver to use.
341+
- `solver::FSolver = SteadyStateLinearSolver`: The solver to use.
334342
- `kwargs...`: Additional keyword arguments to be passed to the solver.
335343
"""
336-
function steadystate_floquet(
344+
function steadystate_fourier(
337345
H_0::QuantumObject{OpType1},
338346
H_p::QuantumObject{OpType2},
339347
H_m::QuantumObject{OpType3},
340348
ωd::Number,
341349
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
342350
n_max::Integer = 2,
343351
tol::R = 1e-8,
344-
solver::FSolver = SSFloquetLinearSolve(),
352+
solver::FSolver = SteadyStateLinearSolver(),
345353
kwargs...,
346354
) where {
347355
OpType1<:Union{OperatorQuantumObject,SuperOperatorQuantumObject},
348356
OpType2<:Union{OperatorQuantumObject,SuperOperatorQuantumObject},
349357
OpType3<:Union{OperatorQuantumObject,SuperOperatorQuantumObject},
350358
R<:Real,
351-
FSolver<:SteadyStateFloquetSolver,
359+
FSolver<:SteadyStateSolver,
352360
}
353361
L_0 = liouvillian(H_0, c_ops)
354362
L_p = liouvillian(H_p)
355363
L_m = liouvillian(H_m)
356-
return _steadystate_floquet(L_0, L_p, L_m, ωd, solver; n_max = n_max, tol = tol, kwargs...)
364+
return _steadystate_fourier(L_0, L_p, L_m, ωd, solver; n_max = n_max, tol = tol, kwargs...)
357365
end
358366

359-
function _steadystate_floquet(
367+
function _steadystate_fourier(
360368
L_0::QuantumObject{SuperOperatorQuantumObject},
361369
L_p::QuantumObject{SuperOperatorQuantumObject},
362370
L_m::QuantumObject{SuperOperatorQuantumObject},
363371
ωd::Number,
364-
solver::SSFloquetLinearSolve;
372+
solver::SteadyStateLinearSolver;
365373
n_max::Integer = 1,
366374
tol::R = 1e-8,
367375
kwargs...,
@@ -426,7 +434,7 @@ function _steadystate_floquet(
426434
return ρ_list
427435
end
428436

429-
function _steadystate_floquet(
437+
function _steadystate_fourier(
430438
L_0::QuantumObject{SuperOperatorQuantumObject},
431439
L_p::QuantumObject{SuperOperatorQuantumObject},
432440
L_m::QuantumObject{SuperOperatorQuantumObject},
@@ -442,3 +450,6 @@ function _steadystate_floquet(
442450

443451
return steadystate(L_eff; solver = solver.steadystate_solver, kwargs...)
444452
end
453+
454+
# TODO: Synonym to align with QuTiP. Track https://github.com/qutip/qutip/issues/2632 when this can be removed.
455+
const steadystate_floquet = steadystate_fourier

test/core-test/steady_state.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,23 @@
6565
H_td = (H, (H_t, coeff))
6666

6767
sol_me = mesolve(H_td, psi0, t_l, c_ops, e_ops = e_ops, progress_bar = Val(false))
68-
ρ_ss1 = steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetLinearSolve())[1]
68+
ρ_ss1 = steadystate_fourier(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SteadyStateLinearSolver())[1]
6969
ρ_ss2 =
70-
steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetEffectiveLiouvillian())
70+
steadystate_fourier(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetEffectiveLiouvillian())
7171

7272
@test abs(sum(sol_me.expect[1, end-100:end]) / 101 - expect(e_ops[1], ρ_ss1)) < 1e-3
7373
@test abs(sum(sol_me.expect[1, end-100:end]) / 101 - expect(e_ops[1], ρ_ss2)) < 1e-3
7474

75-
@testset "Type Inference (steadystate_floquet)" begin
76-
@inferred steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetLinearSolve())
77-
@inferred steadystate_floquet(
75+
@testset "Type Inference (steadystate_fourier)" begin
76+
@inferred steadystate_fourier(
77+
H,
78+
-1im * 0.5 * H_t,
79+
1im * 0.5 * H_t,
80+
1,
81+
c_ops,
82+
solver = SteadyStateLinearSolver(),
83+
)
84+
@inferred steadystate_fourier(
7885
H,
7986
-1im * 0.5 * H_t,
8087
1im * 0.5 * H_t,

0 commit comments

Comments
 (0)