Skip to content

Commit bdedbda

Browse files
authored
Fix default value of keyword parameter saveat (#260)
* fix default value of keyword parameter `saveat` * fix typos in docstrings
1 parent 87ce64e commit bdedbda

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

docs/src/users_guide/time_evolution/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ State vectors, or density matrices, are accessed in a similar manner:
8484
sol.states
8585
```
8686

87-
Here, the solution contains only one (final) state. Because the `states` will be saved depend on the keyword argument `saveat` in `kwargs`. 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`). One can also specify `e_ops` and `saveat` separately.
87+
Here, the solution contains only one (final) state. Because the `states` will be saved depend on the keyword argument `saveat` in `kwargs`. If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). One can also specify `e_ops` and `saveat` separately.
8888

8989
Some other solvers can have other output.
9090

src/time_evolution/mcsolve.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ If the environmental measurements register a quantum jump, the wave function und
176176
# Notes
177177
178178
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
179-
- 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.
179+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
180180
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
181181
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
182182
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -216,11 +216,11 @@ function mcsolveProblem(
216216
e_ops2 = MT1[]
217217
else
218218
expvals = Array{ComplexF64}(undef, length(e_ops), length(t_l))
219-
is_empty_e_ops_mc = false
220219
e_ops2 = get_data.(e_ops)
220+
is_empty_e_ops_mc = isempty(e_ops)
221221
end
222222

223-
saveat = e_ops isa Nothing ? t_l : [t_l[end]]
223+
saveat = is_empty_e_ops_mc ? t_l : [t_l[end]]
224224
# We disable the progress bar of the sesolveProblem because we use a global progress bar for all the trajectories
225225
default_values = (DEFAULT_ODE_SOLVER_OPTIONS..., saveat = saveat, progress_bar = Val(false))
226226
kwargs2 = merge(default_values, kwargs)
@@ -373,7 +373,7 @@ If the environmental measurements register a quantum jump, the wave function und
373373
# Notes
374374
375375
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
376-
- 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.
376+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
377377
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
378378
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
379379
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -514,7 +514,7 @@ If the environmental measurements register a quantum jump, the wave function und
514514
515515
- `ensemble_method` can be one of `EnsembleThreads()`, `EnsembleSerial()`, `EnsembleDistributed()`
516516
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
517-
- 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.
517+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
518518
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
519519
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
520520
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)

src/time_evolution/mesolve.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ where
8888
# Notes
8989
9090
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
91-
- 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.
91+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
9292
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
9393
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
9494
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -154,7 +154,7 @@ function mesolveProblem(
154154
params...,
155155
)
156156

157-
saveat = e_ops isa Nothing ? t_l : [t_l[end]]
157+
saveat = is_empty_e_ops ? t_l : [t_l[end]]
158158
default_values = (DEFAULT_ODE_SOLVER_OPTIONS..., saveat = saveat)
159159
kwargs2 = merge(default_values, kwargs)
160160
kwargs3 = _generate_mesolve_kwargs(e_ops, makeVal(progress_bar), t_l, kwargs2)
@@ -205,7 +205,7 @@ where
205205
# Notes
206206
207207
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
208-
- 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.
208+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
209209
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
210210
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
211211
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)

src/time_evolution/sesolve.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Generates the ODEProblem for the Schrödinger time evolution of a quantum system
7575
# Notes
7676
7777
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
78-
- 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.
78+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
7979
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
8080
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
8181
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -131,7 +131,7 @@ function sesolveProblem(
131131
params...,
132132
)
133133

134-
saveat = e_ops isa Nothing ? t_l : [t_l[end]]
134+
saveat = is_empty_e_ops ? t_l : [t_l[end]]
135135
default_values = (DEFAULT_ODE_SOLVER_OPTIONS..., saveat = saveat)
136136
kwargs2 = merge(default_values, kwargs)
137137
kwargs3 = _generate_sesolve_kwargs(e_ops, makeVal(progress_bar), t_l, kwargs2)
@@ -174,7 +174,7 @@ Time evolution of a closed quantum system using the Schrödinger equation:
174174
# Notes
175175
176176
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
177-
- 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.
177+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
178178
- The default tolerances in `kwargs` are given as `reltol=1e-6` and `abstol=1e-8`.
179179
- For more details about `alg` please refer to [`DifferentialEquations.jl` (ODE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
180180
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)

src/time_evolution/ssesolve.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
127127
# Notes
128128
129129
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
130-
- 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.
130+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
131131
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
132132
- For more details about `alg` please refer to [`DifferentialEquations.jl` (SDE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/)
133133
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -194,7 +194,7 @@ function ssesolveProblem(
194194
params...,
195195
)
196196

197-
saveat = e_ops isa Nothing ? t_l : [t_l[end]]
197+
saveat = is_empty_e_ops ? t_l : [t_l[end]]
198198
default_values = (DEFAULT_SDE_SOLVER_OPTIONS..., saveat = saveat)
199199
kwargs2 = merge(default_values, kwargs)
200200
kwargs3 = _generate_sesolve_kwargs(e_ops, Val(false), t_l, kwargs2)
@@ -271,7 +271,7 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
271271
# Notes
272272
273273
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
274-
- 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.
274+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
275275
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
276276
- For more details about `alg` please refer to [`DifferentialEquations.jl` (SDE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/)
277277
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)
@@ -385,7 +385,7 @@ Above, `C_n` is the `n`-th collapse operator and `dW_j(t)` is the real Wiener i
385385
386386
- `ensemble_method` can be one of `EnsembleThreads()`, `EnsembleSerial()`, `EnsembleDistributed()`
387387
- The states will be saved depend on the keyword argument `saveat` in `kwargs`.
388-
- 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.
388+
- If `e_ops` is empty, the default value of `saveat=tlist` (saving the states corresponding to `tlist`), otherwise, `saveat=[tlist[end]]` (only save the final state). You can also specify `e_ops` and `saveat` separately.
389389
- The default tolerances in `kwargs` are given as `reltol=1e-2` and `abstol=1e-2`.
390390
- For more details about `alg` please refer to [`DifferentialEquations.jl` (SDE Solvers)](https://docs.sciml.ai/DiffEqDocs/stable/solvers/sde_solve/)
391391
- For more details about `kwargs` please refer to [`DifferentialEquations.jl` (Keyword Arguments)](https://docs.sciml.ai/DiffEqDocs/stable/basics/common_solver_opts/)

0 commit comments

Comments
 (0)