Skip to content

Commit a29e91c

Browse files
Minor changes
1 parent aa30237 commit a29e91c

File tree

4 files changed

+36
-33
lines changed

4 files changed

+36
-33
lines changed

src/QuantumToolbox.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ import DiffEqBase: get_tstops
3434
import DiffEqCallbacks: PeriodicCallback, PresetTimeCallback, TerminateSteadyState
3535
import OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm
3636
import OrdinaryDiffEqTsit5: Tsit5
37-
38-
using StochasticDiffEq
37+
import SciMLBase: SDEProblem # add this one above
38+
import StochasticDiffEq: StochasticDiffEqAlgorithm, SRA1
39+
import DiffEqNoiseProcess: RealWienerProcess, RealWienerProcess!
3940

4041
# other dependencies (in alphabetical order)
4142
import ArrayInterface: allowed_getindex, allowed_setindex!
42-
import DiffEqNoiseProcess: RealWienerProcess, RealWienerProcess!
4343
import FFTW: fft, fftshift
4444
import Graphs: connected_components, DiGraph
4545
import IncompleteLU: ilu

src/time_evolution/ssesolve.jl

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ end
6666
ψ0::QuantumObject,
6767
tlist::AbstractVector;
6868
sc_ops::Union{Nothing,AbstractVector}=nothing;
69-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm=SRA1()
69+
alg::StochasticDiffEqAlgorithm=SRA1()
7070
e_ops::Union{Nothing,AbstractVector} = nothing,
7171
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
7272
params::NamedTuple=NamedTuple(),
@@ -100,18 +100,20 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
100100
- `ψ0::QuantumObject`: The initial state of the system ``|\psi(0)\rangle``.
101101
- `tlist::AbstractVector`: The time list of the evolution.
102102
- `sc_ops::Union{Nothing,AbstractVector}=nothing`: List of stochastic collapse operators ``\{\hat{C}_n\}_n``.
103-
- `alg::StochasticDiffEq.StochasticDiffEqAlgorithm`: The algorithm used for the time evolution.
103+
- `alg::StochasticDiffEqAlgorithm`: The algorithm used for the time evolution.
104104
- `e_ops::Union{Nothing,AbstractVector}=nothing`: The list of operators to be evaluated during the evolution.
105105
- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: The time-dependent Hamiltonian of the system. If `nothing`, the Hamiltonian is time-independent.
106106
- `params::NamedTuple`: The parameters of the system.
107107
- `progress_bar::Union{Val,Bool}`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
108-
- `kwargs...`: The keyword arguments passed to the `ODEProblem` constructor.
108+
- `kwargs...`: The keyword arguments passed to the `SDEProblem` constructor.
109109
110110
# Notes
111111
112112
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
113113
- If `e_ops` is specified, the default value of `saveat=[tlist[end]]` (only save the final state), otherwise, `saveat=tlist` (saving the states corresponding to `tlist`). You can also specify `e_ops` and `saveat` separately.
114-
- For more details about `alg` and extra `kwargs`, please refer to [`DifferentialEquations.jl`](https://diffeq.sciml.ai/stable/)
114+
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
115+
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
116+
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
115117
116118
# Returns
117119
@@ -122,7 +124,7 @@ function ssesolveProblem(
122124
ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
123125
tlist::AbstractVector,
124126
sc_ops::Union{Nothing,AbstractVector} = nothing;
125-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm = SRA1(),
127+
alg::StochasticDiffEqAlgorithm = SRA1(),
126128
e_ops::Union{Nothing,AbstractVector} = nothing,
127129
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
128130
params::NamedTuple = NamedTuple(),
@@ -205,7 +207,7 @@ end
205207
ψ0::QuantumObject,
206208
tlist::AbstractVector;
207209
sc_ops::Union{Nothing,AbstractVector} = nothing;
208-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm=SRA1()
210+
alg::StochasticDiffEqAlgorithm=SRA1()
209211
e_ops::Union{Nothing,AbstractVector} = nothing,
210212
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
211213
params::NamedTuple=NamedTuple(),
@@ -240,19 +242,21 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
240242
- `ψ0::QuantumObject`: The initial state of the system ``|\psi(0)\rangle``.
241243
- `tlist::AbstractVector`: The time list of the evolution.
242244
- `sc_ops::Union{Nothing,AbstractVector}=nothing`: List of stochastic collapse operators ``\{\hat{C}_n\}_n``.
243-
- `alg::StochasticDiffEq.StochasticDiffEqAlgorithm`: The algorithm used for the time evolution.
245+
- `alg::StochasticDiffEqAlgorithm`: The algorithm used for the time evolution.
244246
- `e_ops::Union{Nothing,AbstractVector}=nothing`: The list of operators to be evaluated during the evolution.
245247
- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: The time-dependent Hamiltonian of the system. If `nothing`, the Hamiltonian is time-independent.
246248
- `params::NamedTuple`: The parameters of the system.
247249
- `prob_func::Function`: Function to use for generating the SDEProblem.
248250
- `output_func::Function`: Function to use for generating the output of a single trajectory.
249-
- `kwargs...`: The keyword arguments passed to the `ODEProblem` constructor.
251+
- `kwargs...`: The keyword arguments passed to the `SDEProblem` constructor.
250252
251253
# Notes
252254
253255
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
254256
- If `e_ops` is specified, the default value of `saveat=[tlist[end]]` (only save the final state), otherwise, `saveat=tlist` (saving the states corresponding to `tlist`). You can also specify `e_ops` and `saveat` separately.
255-
- For more details about `alg` and extra `kwargs`, please refer to [`DifferentialEquations.jl`](https://diffeq.sciml.ai/stable/)
257+
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
258+
- For more details about `alg` please refer to [`DifferentialEquations.jl` (SDE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/)
259+
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
256260
257261
# Returns
258262
@@ -263,7 +267,7 @@ function ssesolveEnsembleProblem(
263267
ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
264268
tlist::AbstractVector,
265269
sc_ops::Union{Nothing,AbstractVector} = nothing;
266-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm = SRA1(),
270+
alg::StochasticDiffEqAlgorithm = SRA1(),
267271
e_ops::Union{Nothing,AbstractVector} = nothing,
268272
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
269273
params::NamedTuple = NamedTuple(),
@@ -283,7 +287,7 @@ end
283287
ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
284288
tlist::AbstractVector,
285289
sc_ops::Union{Nothing, AbstractVector}=nothing;
286-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm=SRA1(),
290+
alg::StochasticDiffEqAlgorithm=SRA1(),
287291
e_ops::Union{Nothing,AbstractVector}=nothing,
288292
H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
289293
params::NamedTuple=NamedTuple(),
@@ -323,7 +327,7 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
323327
- `ψ0::QuantumObject`: Initial state of the system ``|\psi(0)\rangle``.
324328
- `tlist::AbstractVector`: List of times at which to save the state of the system.
325329
- `sc_ops::Union{Nothing,AbstractVector}=nothing`: List of stochastic collapse operators ``\{\hat{C}_n\}_n``.
326-
- `alg::StochasticDiffEq.StochasticDiffEqAlgorithm`: Algorithm to use for the time evolution.
330+
- `alg::StochasticDiffEqAlgorithm`: Algorithm to use for the time evolution.
327331
- `e_ops::Union{Nothing,AbstractVector}`: List of operators for which to calculate expectation values.
328332
- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
329333
- `params::NamedTuple`: Dictionary of parameters to pass to the solver.
@@ -339,8 +343,9 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
339343
- `ensemble_method` can be one of `EnsembleThreads()`, `EnsembleSerial()`, `EnsembleDistributed()`
340344
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
341345
- If `e_ops` is specified, the default value of `saveat=[tlist[end]]` (only save the final state), otherwise, `saveat=tlist` (saving the states corresponding to `tlist`). You can also specify `e_ops` and `saveat` separately.
342-
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
343-
- For more details about `alg` and extra `kwargs`, please refer to [`DifferentialEquations.jl`](https://diffeq.sciml.ai/stable/)
346+
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
347+
- For more details about `alg` please refer to [`DifferentialEquations.jl` (SDE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/)
348+
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
344349
345350
# Returns
346351
@@ -351,7 +356,7 @@ function ssesolve(
351356
ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
352357
tlist::AbstractVector,
353358
sc_ops::Union{Nothing,AbstractVector} = nothing;
354-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm = SRA1(),
359+
alg::StochasticDiffEqAlgorithm = SRA1(),
355360
e_ops::Union{Nothing,AbstractVector} = nothing,
356361
H_t::Union{Nothing,Function,TimeDependentOperatorSum} = nothing,
357362
params::NamedTuple = NamedTuple(),
@@ -380,7 +385,7 @@ end
380385

381386
function ssesolve(
382387
ens_prob::EnsembleProblem;
383-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm = SRA1(),
388+
alg::StochasticDiffEqAlgorithm = SRA1(),
384389
n_traj::Int = 1,
385390
ensemble_method = EnsembleThreads(),
386391
)

src/time_evolution/time_evolution.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct TimeEvolutionSSESol{
124124
expect::TE
125125
expect_all::TEA
126126
converged::Bool
127-
alg::StochasticDiffEq.StochasticDiffEqAlgorithm
127+
alg::StochasticDiffEqAlgorithm
128128
abstol::T1
129129
reltol::T2
130130
end

test/core-test/time_evolution.jl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,17 @@
130130
end
131131

132132
@testset "Type Inference ssesolve" begin
133-
if VERSION >= v"1.10"
134-
@inferred ssesolveEnsembleProblem(
135-
H,
136-
psi0,
137-
t_l,
138-
c_ops,
139-
n_traj = 500,
140-
e_ops = e_ops,
141-
progress_bar = Val(false),
142-
)
143-
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
144-
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, progress_bar = Val(true))
145-
end
133+
@inferred ssesolveEnsembleProblem(
134+
H,
135+
psi0,
136+
t_l,
137+
c_ops,
138+
n_traj = 500,
139+
e_ops = e_ops,
140+
progress_bar = Val(false),
141+
)
142+
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, e_ops = e_ops, progress_bar = Val(false))
143+
@inferred ssesolve(H, psi0, t_l, c_ops, n_traj = 500, progress_bar = Val(true))
146144
end
147145
end
148146

0 commit comments

Comments
 (0)