Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased](https://github.com/qutip/QuantumToolbox.jl/tree/main)

- 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])
- Simplify type structure for time evolution solutions. ([#572])

## [v0.37.0]
Release date: 2025-10-12
Expand Down Expand Up @@ -339,3 +340,4 @@ Release date: 2024-11-13
[#555]: https://github.com/qutip/QuantumToolbox.jl/issues/555
[#557]: https://github.com/qutip/QuantumToolbox.jl/issues/557
[#565]: https://github.com/qutip/QuantumToolbox.jl/issues/565
[#572]: https://github.com/qutip/QuantumToolbox.jl/issues/572
14 changes: 6 additions & 8 deletions src/time_evolution/lr_mesolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,24 @@ A structure storing the results and some information from solving low-rank maste
- `B::Vector{QuantumObject}`: The `B` matrix of the low-rank algorithm at each time point.
"""
struct TimeEvolutionLRSol{
TT1<:AbstractVector{<:Real},
TT2<:AbstractVector{<:Real},
TT<:AbstractVector{<:Real},
TS<:AbstractVector,
TE<:Matrix{ComplexF64},
RetT<:Enum,
AlgT<:OrdinaryDiffEqAlgorithm,
AT<:Real,
RT<:Real,
TolT<:Real,
TSZB<:AbstractVector,
TM<:Vector{<:Integer},
}
times::TT1
times_states::TT2
times::TT
times_states::TT
states::TS
expect::TE
fexpect::TE
retcode::RetT
alg::AlgT
abstol::AT
reltol::RT
abstol::TolT
reltol::TolT
z::TSZB
B::TSZB
M::TM
Expand Down
56 changes: 25 additions & 31 deletions src/time_evolution/time_evolution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,21 @@ A structure storing the results and some information from solving time evolution
- `reltol::Real`: The relative tolerance which is used during the solving process.
"""
struct TimeEvolutionSol{
TT1<:AbstractVector{<:Real},
TT2<:AbstractVector{<:Real},
TT<:AbstractVector{<:Real},
TS<:AbstractVector,
TE<:Union{AbstractMatrix,Nothing},
RETT<:Enum,
AlgT<:OrdinaryDiffEqAlgorithm,
AT<:Real,
RT<:Real,
TolT<:Real,
}
times::TT1
times_states::TT2
times::TT
times_states::TT
states::TS
expect::TE
retcode::RETT
alg::AlgT
abstol::AT
reltol::RT
abstol::TolT
reltol::TolT
end

function Base.show(io::IO, sol::TimeEvolutionSol)
Expand Down Expand Up @@ -133,27 +131,25 @@ We also provide the following functions for statistical analysis of multi-trajec
- [`std_expect`](@ref)
"""
struct TimeEvolutionMCSol{
TT1<:AbstractVector{<:Real},
TT2<:AbstractVector{<:Real},
TT<:AbstractVector{<:Real},
TS<:AbstractVecOrMat,
TE<:Union{AbstractArray,Nothing},
TJT<:Vector{<:Vector{<:Real}},
TJW<:Vector{<:Vector{<:Integer}},
AlgT<:OrdinaryDiffEqAlgorithm,
AT<:Real,
RT<:Real,
TolT<:Real,
} <: TimeEvolutionMultiTrajSol{TS,TE}
ntraj::Int
times::TT1
times_states::TT2
times::TT
times_states::TT
states::TS
expect::TE
col_times::TJT
col_which::TJW
converged::Bool
alg::AlgT
abstol::AT
reltol::RT
abstol::TolT
reltol::TolT
end

function Base.show(io::IO, sol::TimeEvolutionMCSol)
Expand Down Expand Up @@ -209,25 +205,23 @@ We also provide the following functions for statistical analysis of multi-trajec
- [`std_expect`](@ref)
"""
struct TimeEvolutionStochasticSol{
TT1<:AbstractVector{<:Real},
TT2<:AbstractVector{<:Real},
TT<:AbstractVector{<:Real},
TS<:AbstractVecOrMat,
TE<:Union{AbstractArray,Nothing},
TEM<:Union{AbstractArray,Nothing},
AlgT<:StochasticDiffEqAlgorithm,
AT<:Real,
RT<:Real,
TolT<:Real,
} <: TimeEvolutionMultiTrajSol{TS,TE}
ntraj::Int
times::TT1
times_states::TT2
times::TT
times_states::TT
states::TS
expect::TE
measurement::TEM
converged::Bool
alg::AlgT
abstol::AT
reltol::RT
abstol::TolT
reltol::TolT
end

function Base.show(io::IO, sol::TimeEvolutionStochasticSol)
Expand Down Expand Up @@ -406,33 +400,33 @@ 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,
) where {ET<:Union{EnsembleSplitThreads,EnsembleDistributed}}
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

Expand Down
Loading