diff --git a/CHANGELOG.md b/CHANGELOG.md index aec3b9c0c..552418b3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Introduce new methods of `sesolve_map` and `mesolve_map` for advanced usage. Users can now customize their own `iter`ator structure, `prob_func` and `output_func`. ([#565]) - Use `ProgressMeter.jl` for progress bar rather than our in-house implementation. ([#569]) +- Simplify type structure for time evolution solutions. ([#572]) ## [v0.37.0] Release date: 2025-10-12 @@ -341,3 +342,4 @@ Release date: 2024-11-13 [#557]: https://github.com/qutip/QuantumToolbox.jl/issues/557 [#565]: https://github.com/qutip/QuantumToolbox.jl/issues/565 [#569]: https://github.com/qutip/QuantumToolbox.jl/issues/569 +[#572]: https://github.com/qutip/QuantumToolbox.jl/issues/572 diff --git a/src/time_evolution/lr_mesolve.jl b/src/time_evolution/lr_mesolve.jl index de49df963..19ae95941 100644 --- a/src/time_evolution/lr_mesolve.jl +++ b/src/time_evolution/lr_mesolve.jl @@ -26,8 +26,7 @@ struct TimeEvolutionLRSol{ TE<:Matrix{ComplexF64}, RetT<:Enum, AlgT<:OrdinaryDiffEqAlgorithm, - AT<:Real, - RT<:Real, + TolT<:Real, TSZB<:AbstractVector, TM<:Vector{<:Integer}, } @@ -38,8 +37,8 @@ struct TimeEvolutionLRSol{ fexpect::TE retcode::RetT alg::AlgT - abstol::AT - reltol::RT + abstol::TolT + reltol::TolT z::TSZB B::TSZB M::TM diff --git a/src/time_evolution/time_evolution.jl b/src/time_evolution/time_evolution.jl index d7c332e27..f7f1b70b1 100644 --- a/src/time_evolution/time_evolution.jl +++ b/src/time_evolution/time_evolution.jl @@ -66,8 +66,7 @@ struct TimeEvolutionSol{ TE<:Union{AbstractMatrix,Nothing}, RETT<:Enum, AlgT<:OrdinaryDiffEqAlgorithm, - AT<:Real, - RT<:Real, + TolT<:Real, } times::TT1 times_states::TT2 @@ -75,8 +74,8 @@ struct TimeEvolutionSol{ expect::TE retcode::RETT alg::AlgT - abstol::AT - reltol::RT + abstol::TolT + reltol::TolT end function Base.show(io::IO, sol::TimeEvolutionSol) @@ -140,8 +139,7 @@ struct TimeEvolutionMCSol{ TJT<:Vector{<:Vector{<:Real}}, TJW<:Vector{<:Vector{<:Integer}}, AlgT<:OrdinaryDiffEqAlgorithm, - AT<:Real, - RT<:Real, + TolT<:Real, } <: TimeEvolutionMultiTrajSol{TS,TE} ntraj::Int times::TT1 @@ -152,8 +150,8 @@ struct TimeEvolutionMCSol{ col_which::TJW converged::Bool alg::AlgT - abstol::AT - reltol::RT + abstol::TolT + reltol::TolT end function Base.show(io::IO, sol::TimeEvolutionMCSol) @@ -215,8 +213,7 @@ struct TimeEvolutionStochasticSol{ TE<:Union{AbstractArray,Nothing}, TEM<:Union{AbstractArray,Nothing}, AlgT<:StochasticDiffEqAlgorithm, - AT<:Real, - RT<:Real, + TolT<:Real, } <: TimeEvolutionMultiTrajSol{TS,TE} ntraj::Int times::TT1 @@ -226,8 +223,8 @@ struct TimeEvolutionStochasticSol{ measurement::TEM converged::Bool alg::AlgT - abstol::AT - reltol::RT + abstol::TolT + reltol::TolT end function Base.show(io::IO, sol::TimeEvolutionStochasticSol) @@ -408,7 +405,7 @@ function _ensemble_dispatch_prob_func(rng, ntraj, tlist, prob_func; kwargs...) end function _ensemble_dispatch_solve( - ens_prob_mc::TimeEvolutionProblem, + ens_prob::TimeEvolutionProblem, alg::Union{<:OrdinaryDiffEqAlgorithm,<:StochasticDiffEqAlgorithm}, ensemblealg::ET, ntraj::Int, @@ -416,25 +413,25 @@ function _ensemble_dispatch_solve( sol = nothing @sync begin - @async while take!(ens_prob_mc.kwargs.channel) - next!(ens_prob_mc.kwargs.progr) + @async while take!(ens_prob.kwargs.channel) + next!(ens_prob.kwargs.progr) end @async begin - sol = solve(ens_prob_mc.prob, alg, ensemblealg, trajectories = ntraj) - put!(ens_prob_mc.kwargs.channel, false) + sol = solve(ens_prob.prob, alg, ensemblealg, trajectories = ntraj) + put!(ens_prob.kwargs.channel, false) end end return sol end function _ensemble_dispatch_solve( - ens_prob_mc::TimeEvolutionProblem, + ens_prob::TimeEvolutionProblem, alg::Union{<:OrdinaryDiffEqAlgorithm,<:StochasticDiffEqAlgorithm}, ensemblealg, ntraj::Int, ) - sol = solve(ens_prob_mc.prob, alg, ensemblealg, trajectories = ntraj) + sol = solve(ens_prob.prob, alg, ensemblealg, trajectories = ntraj) return sol end