Skip to content

Commit

Permalink
Change default method to direct solver and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoFioroni committed May 30, 2024
1 parent ef0090a commit 120369b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/steadystate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end

function steadystate(
L::QuantumObject{<:AbstractArray{T},SuperOperatorQuantumObject};
solver::SteadyStateSolver = SteadyStateLinearSolver(),
solver::SteadyStateSolver = SteadyStateDirectSolver(),
kwargs...,
) where {T}
return _steadystate(L, solver; kwargs...)
Expand All @@ -22,7 +22,7 @@ end
function steadystate(
H::QuantumObject{<:AbstractArray{T},OpType},
c_ops::AbstractVector;
solver::SteadyStateSolver = SteadyStateLinearSolver(),
solver::SteadyStateSolver = SteadyStateDirectSolver(),
kwargs...,
) where {T,OpType<:Union{OperatorQuantumObject,SuperOperatorQuantumObject}}
L = liouvillian(H, c_ops)
Expand Down
19 changes: 17 additions & 2 deletions test/steady_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,23 @@
psi0 = fock(N, 3)
t_l = LinRange(0, 200, 1000)
sol_me = mesolve(H, psi0, t_l, c_ops, e_ops = e_ops, progress_bar = false)
ρ_ss = steadystate(H, c_ops)
@test abs(sol_me.expect[1, end] - expect(e_ops[1], ρ_ss)) < 1e-3
rho_me = sol_me.states[end]

solver = SteadyStateDirectSolver()
ρ_ss = steadystate(H, c_ops, solver = solver)
@test tracedist(rho_me, ρ_ss) < 1e-4

solver = SteadyStateLinearSolver()
ρ_ss = steadystate(H, c_ops, solver = solver)
@test tracedist(rho_me, ρ_ss) < 1e-4

solver = SteadyStateLinearSolver(alg=KrylovJL_GMRES())
ρ_ss = steadystate(H, c_ops, solver = solver)
@test tracedist(rho_me, ρ_ss) < 1e-4

solver = SteadyStateEigenSolver()
ρ_ss = steadystate(H, c_ops, solver = solver)
@test tracedist(rho_me, ρ_ss) < 1e-4

H = a_d * a
H_t = 0.1 * (a + a_d)
Expand Down

0 comments on commit 120369b

Please sign in to comment.