Skip to content

Commit 524e537

Browse files
Make common stochastic solution struct
1 parent 71664e8 commit 524e537

File tree

6 files changed

+14
-68
lines changed

6 files changed

+14
-68
lines changed

docs/src/resources/api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ cosm
189189
TimeEvolutionProblem
190190
TimeEvolutionSol
191191
TimeEvolutionMCSol
192-
TimeEvolutionSSESol
193-
TimeEvolutionSMESol
192+
TimeEvolutionStochasticSol
194193
sesolveProblem
195194
mesolveProblem
196195
mcsolveProblem

docs/src/users_guide/time_evolution/intro.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ The following table lists the solvers provided by `QuantumToolbox` for dynamic q
3636
| Unitary evolution, Schrödinger equation | [`sesolve`](@ref) | [`sesolveProblem`](@ref) | [`TimeEvolutionSol`](@ref) |
3737
| Lindblad master eqn. or Von Neuman eqn.| [`mesolve`](@ref) | [`mesolveProblem`](@ref) | [`TimeEvolutionSol`](@ref) |
3838
| Monte Carlo evolution | [`mcsolve`](@ref) | [`mcsolveProblem`](@ref) [`mcsolveEnsembleProblem`](@ref) | [`TimeEvolutionMCSol`](@ref) |
39-
| Stochastic Schrödinger equation | [`ssesolve`](@ref) | [`ssesolveProblem`](@ref) [`ssesolveEnsembleProblem`](@ref) | [`TimeEvolutionSSESol`](@ref) |
39+
| Stochastic Schrödinger equation | [`ssesolve`](@ref) | [`ssesolveProblem`](@ref) [`ssesolveEnsembleProblem`](@ref) | [`TimeEvolutionStochasticSol`](@ref) |
40+
| Stochastic master equation | [`smesolve`](@ref) | [`smesolveProblem`](@ref) [`smesolveEnsembleProblem`](@ref) | [`TimeEvolutionStochasticSol`](@ref) |
4041

4142
!!! note "Solving dynamics with pre-defined problems"
4243
`QuantumToolbox` provides two different methods to solve the dynamics. One can use the function calls listed above by either taking all the operators (like Hamiltonian and collapse operators, etc.) as inputs directly, or generating the `prob`lems by yourself and take it as an input of the function call, e.g., `sesolve(prob)`.

src/time_evolution/smesolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Above, ``\hat{C}_n`` represent the operators related to pure dissipation, while
301301
302302
# Returns
303303
304-
- `sol::TimeEvolutionSMESol`: The solution of the time evolution. See also [`TimeEvolutionSMESol`](@ref).
304+
- `sol::TimeEvolutionStochasticSol`: The solution of the time evolution. See [`TimeEvolutionStochasticSol`](@ref).
305305
"""
306306
function smesolve(
307307
H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple},
@@ -361,7 +361,7 @@ function smesolve(
361361
_se_me_sse_get_expvals(_sol_1) isa Nothing ? nothing :
362362
dropdims(sum(expvals_all, dims = 3), dims = 3) ./ length(sol)
363363

364-
return TimeEvolutionSMESol(
364+
return TimeEvolutionStochasticSol(
365365
ntraj,
366366
ens_prob.times,
367367
states,

src/time_evolution/ssesolve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ Above, ``\hat{C}_n`` is the `n`-th collapse operator and ``dW_n(t)`` is the real
390390
391391
# Returns
392392
393-
- `sol::TimeEvolutionSSESol`: The solution of the time evolution. See also [`TimeEvolutionSSESol`](@ref).
393+
- `sol::TimeEvolutionStochasticSol`: The solution of the time evolution. See [`TimeEvolutionStochasticSol`](@ref).
394394
"""
395395
function ssesolve(
396396
H::Union{AbstractQuantumObject{OperatorQuantumObject},Tuple},
@@ -455,7 +455,7 @@ function ssesolve(
455455
_se_me_sse_get_expvals(_sol_1) isa Nothing ? nothing :
456456
dropdims(sum(expvals_all, dims = 3), dims = 3) ./ length(sol)
457457

458-
return TimeEvolutionSSESol(
458+
return TimeEvolutionStochasticSol(
459459
ntraj,
460460
_sol_1.prob.p.times,
461461
states,

src/time_evolution/time_evolution.jl

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export TimeEvolutionSol, TimeEvolutionMCSol, TimeEvolutionSSESol
1+
export TimeEvolutionSol, TimeEvolutionMCSol, TimeEvolutionStochasticSol
22

33
export liouvillian_floquet, liouvillian_generalized
44

@@ -149,61 +149,7 @@ function Base.show(io::IO, sol::TimeEvolutionMCSol)
149149
end
150150

151151
@doc raw"""
152-
struct TimeEvolutionSSESol
153-
154-
A structure storing the results and some information from solving trajectories of the Stochastic Shrodinger equation time evolution.
155-
156-
# Fields (Attributes)
157-
158-
- `ntraj::Int`: Number of trajectories
159-
- `times::AbstractVector`: The time list of the evolution.
160-
- `states::Vector{Vector{QuantumObject}}`: The list of result states in each trajectory.
161-
- `expect::Union{AbstractMatrix,Nothing}`: The expectation values (averaging all trajectories) corresponding to each time point in `times`.
162-
- `expect_all::Union{AbstractArray,Nothing}`: The expectation values corresponding to each trajectory and each time point in `times`
163-
- `converged::Bool`: Whether the solution is converged or not.
164-
- `alg`: The algorithm which is used during the solving process.
165-
- `abstol::Real`: The absolute tolerance which is used during the solving process.
166-
- `reltol::Real`: The relative tolerance which is used during the solving process.
167-
"""
168-
struct TimeEvolutionSSESol{
169-
TT<:AbstractVector{<:Real},
170-
TS<:AbstractVector,
171-
TE<:Union{AbstractMatrix,Nothing},
172-
TEA<:Union{AbstractArray,Nothing},
173-
AlgT<:StochasticDiffEqAlgorithm,
174-
AT<:Real,
175-
RT<:Real,
176-
}
177-
ntraj::Int
178-
times::TT
179-
states::TS
180-
expect::TE
181-
expect_all::TEA
182-
converged::Bool
183-
alg::AlgT
184-
abstol::AT
185-
reltol::RT
186-
end
187-
188-
function Base.show(io::IO, sol::TimeEvolutionSSESol)
189-
print(io, "Solution of quantum trajectories\n")
190-
print(io, "(converged: $(sol.converged))\n")
191-
print(io, "--------------------------------\n")
192-
print(io, "num_trajectories = $(sol.ntraj)\n")
193-
print(io, "num_states = $(length(sol.states[1]))\n")
194-
if sol.expect isa Nothing
195-
print(io, "num_expect = 0\n")
196-
else
197-
print(io, "num_expect = $(size(sol.expect, 1))\n")
198-
end
199-
print(io, "SDE alg.: $(sol.alg)\n")
200-
print(io, "abstol = $(sol.abstol)\n")
201-
print(io, "reltol = $(sol.reltol)\n")
202-
return nothing
203-
end
204-
205-
@doc raw"""
206-
struct TimeEvolutionSMESol
152+
struct TimeEvolutionStochasticSol
207153
208154
A structure storing the results and some information from solving trajectories of the Stochastic Master Equation time evolution.
209155
@@ -219,7 +165,7 @@ A structure storing the results and some information from solving trajectories o
219165
- `abstol::Real`: The absolute tolerance which is used during the solving process.
220166
- `reltol::Real`: The relative tolerance which is used during the solving process.
221167
"""
222-
struct TimeEvolutionSMESol{
168+
struct TimeEvolutionStochasticSol{
223169
TT<:AbstractVector{<:Real},
224170
TS<:AbstractVector,
225171
TE<:Union{AbstractMatrix,Nothing},
@@ -239,8 +185,8 @@ struct TimeEvolutionSMESol{
239185
reltol::RT
240186
end
241187

242-
function Base.show(io::IO, sol::TimeEvolutionSMESol)
243-
print(io, "Solution of quantum trajectories\n")
188+
function Base.show(io::IO, sol::TimeEvolutionStochasticSol)
189+
print(io, "Solution of stochastic quantum trajectories\n")
244190
print(io, "(converged: $(sol.converged))\n")
245191
print(io, "--------------------------------\n")
246192
print(io, "num_trajectories = $(sol.ntraj)\n")

test/core-test/time_evolution.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198
"abstol = $(sol_mc_states.abstol)\n" *
199199
"reltol = $(sol_mc_states.reltol)\n"
200200
@test sol_sse_string ==
201-
"Solution of quantum trajectories\n" *
201+
"Solution of stochastic quantum trajectories\n" *
202202
"(converged: $(sol_sse.converged))\n" *
203203
"--------------------------------\n" *
204204
"num_trajectories = $(sol_sse.ntraj)\n" *
@@ -208,7 +208,7 @@
208208
"abstol = $(sol_sse.abstol)\n" *
209209
"reltol = $(sol_sse.reltol)\n"
210210
@test sol_sme_string ==
211-
"Solution of quantum trajectories\n" *
211+
"Solution of stochastic quantum trajectories\n" *
212212
"(converged: $(sol_sme.converged))\n" *
213213
"--------------------------------\n" *
214214
"num_trajectories = $(sol_sme.ntraj)\n" *

0 commit comments

Comments
 (0)