Skip to content

Commit eeb4adf

Browse files
Change the abstol and reltol handling
1 parent 3dd6488 commit eeb4adf

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/steadystate.jl

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ end
4747
alg = Tsit5(),
4848
ψ0 = nothing,
4949
tmax = Inf,
50-
reltol = 1.0e-6,
51-
abstol = 1.0e-8,
5250
)
5351
5452
An ordinary differential equation (ODE) solver for solving [`steadystate`](@ref).
@@ -71,18 +69,14 @@ or
7169
- `alg::OrdinaryDiffEqAlgorithm=Tsit5()`: The algorithm to solve the ODE.
7270
- `ψ0::Union{Nothing,QuantumObject}=nothing`: The initial state of the system. If not specified, a random pure state will be generated.
7371
- `tmax::Real=Inf`: The final time step for the steady state problem.
74-
- `reltol::Real=1.0e-6`: Relative tolerance in steady state terminate condition. It can be different from the integrator's tolerance.
75-
- `abstol::Real=1.0e-8`: Absolute tolerance in steady state terminate condition. It can be different from the integrator's tolerance.
7672
7773
For more details about the solvers, please refer to [`OrdinaryDiffEq.jl`](https://docs.sciml.ai/OrdinaryDiffEq/stable/).
7874
"""
79-
Base.@kwdef struct SteadyStateODESolver{MT<:OrdinaryDiffEqAlgorithm,ST<:Union{Nothing,QuantumObject}} <:
75+
Base.@kwdef struct SteadyStateODESolver{MT<:OrdinaryDiffEqAlgorithm,ST<:Union{Nothing,QuantumObject},T<:Real} <:
8076
SteadyStateSolver
8177
alg::MT = Tsit5()
8278
ψ0::ST = nothing
83-
tmax::Float64 = Inf
84-
reltol::Float64 = 1.0e-4
85-
abstol::Float64 = 1.0e-6
79+
tmax::T = Inf
8680
end
8781

8882
@doc raw"""
@@ -207,10 +201,10 @@ end
207201

208202
function _steadystate(L::QuantumObject{SuperOperatorQuantumObject}, solver::SteadyStateODESolver; kwargs...)
209203
tmax = solver.tmax
210-
abstol = solver.abstol
211-
reltol = solver.reltol
212204

213205
ψ0 = isnothing(solver.ψ0) ? rand_ket(L.dimensions) : solver.ψ0
206+
abstol = haskey(kwargs, :abstol) ? kwargs[:abstol] : DEFAULT_ODE_SOLVER_OPTIONS.abstol
207+
reltol = haskey(kwargs, :reltol) ? kwargs[:reltol] : DEFAULT_ODE_SOLVER_OPTIONS.reltol
214208

215209
ftype = _FType(ψ0)
216210
_terminate_func = SteadyStateODECondition(similar(mat2vec(ket2dm(ψ0)).data))

0 commit comments

Comments
 (0)