@@ -64,6 +64,7 @@ _sesolve_make_U_QobjEvo(H) = QobjEvo(H, -1im)
6464 e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
6565 params::NamedTuple = NamedTuple(),
6666 progress_bar::Union{Val,Bool} = Val(true),
67+ inplace::Union{Val,Bool} = Val(true),
6768 kwargs...,
6869 )
6970
@@ -81,6 +82,7 @@ Generate the ODEProblem for the Schrödinger time evolution of a quantum system:
8182- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
8283- `params`: `NamedTuple` of parameters to pass to the solver.
8384- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
85+ - `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
8486- `kwargs`: The keyword arguments for the ODEProblem.
8587
8688# Notes
@@ -101,6 +103,7 @@ function sesolveProblem(
101103 e_ops:: Union{Nothing,AbstractVector,Tuple} = nothing ,
102104 params:: NamedTuple = NamedTuple (),
103105 progress_bar:: Union{Val,Bool} = Val (true ),
106+ inplace:: Union{Val,Bool} = Val (true ),
104107 kwargs... ,
105108) where {DT1,DT2}
106109 haskey (kwargs, :save_idxs ) &&
@@ -133,7 +136,7 @@ function sesolveProblem(
133136 kwargs3 = _generate_sesolve_kwargs (e_ops, makeVal (progress_bar), tlist, kwargs2)
134137
135138 tspan = (tlist[1 ], tlist[end ])
136- prob = ODEProblem {true ,FullSpecialize} (U, ψ0, tspan, p; kwargs3... )
139+ prob = ODEProblem {getVal(inplace) ,FullSpecialize} (U, ψ0, tspan, p; kwargs3... )
137140
138141 return QuantumTimeEvoProblem (prob, tlist, H_evo. dims)
139142end
147150 e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
148151 params::NamedTuple = NamedTuple(),
149152 progress_bar::Union{Val,Bool} = Val(true),
153+ inplace::Union{Val,Bool} = Val(true),
150154 kwargs...,
151155 )
152156
@@ -165,6 +169,7 @@ Time evolution of a closed quantum system using the Schrödinger equation:
165169- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
166170- `params`: `NamedTuple` of parameters to pass to the solver.
167171- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
172+ - `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
168173- `kwargs`: The keyword arguments for the ODEProblem.
169174
170175# Notes
@@ -187,9 +192,10 @@ function sesolve(
187192 e_ops:: Union{Nothing,AbstractVector,Tuple} = nothing ,
188193 params:: NamedTuple = NamedTuple (),
189194 progress_bar:: Union{Val,Bool} = Val (true ),
195+ inplace:: Union{Val,Bool} = Val (true ),
190196 kwargs... ,
191197) where {DT1,DT2}
192- prob = sesolveProblem (H, ψ0, tlist; e_ops = e_ops, params = params, progress_bar = progress_bar, kwargs... )
198+ prob = sesolveProblem (H, ψ0, tlist; e_ops = e_ops, params = params, progress_bar = progress_bar, inplace = inplace, kwargs... )
193199
194200 return sesolve (prob, alg)
195201end
0 commit comments