Skip to content

Commit 024b4fd

Browse files
Make NullParameters as default for params
1 parent dddb60b commit 024b4fd

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

src/QuantumToolbox.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import SciMLBase:
2323
reinit!,
2424
remake,
2525
u_modified!,
26+
NullParameters,
2627
ODEFunction,
2728
ODEProblem,
2829
SDEProblem,

src/time_evolution/mcsolve.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ end
104104
tlist::AbstractVector,
105105
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
106106
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
107-
params = eltype(ψ0)[],
107+
params = NullParameters(),
108108
rng::AbstractRNG = default_rng(),
109109
jump_callback::TJC = ContinuousLindbladJumpCallback(),
110110
kwargs...,
@@ -151,7 +151,7 @@ If the environmental measurements register a quantum jump, the wave function und
151151
- `tlist`: List of times at which to save either the state or the expectation values of the system.
152152
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
153153
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
154-
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
154+
- `params`: Parameters to pass to the solver. This argument is usually expressed as a `NamedTuple` or `AbstractVector` of parameters. For more advanced usage, any custom struct can be used.
155155
- `rng`: Random number generator for reproducibility.
156156
- `jump_callback`: The Jump Callback type: Discrete or Continuous. The default is `ContinuousLindbladJumpCallback()`, which is more precise.
157157
- `kwargs`: The keyword arguments for the ODEProblem.
@@ -173,7 +173,7 @@ function mcsolveProblem(
173173
tlist::AbstractVector,
174174
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
175175
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
176-
params = eltype(ψ0)[],
176+
params = NullParameters(),
177177
rng::AbstractRNG = default_rng(),
178178
jump_callback::TJC = ContinuousLindbladJumpCallback(),
179179
kwargs...,
@@ -231,7 +231,7 @@ end
231231
tlist::AbstractVector,
232232
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
233233
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
234-
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
234+
params = NullParameters(),
235235
rng::AbstractRNG = default_rng(),
236236
ntraj::Int = 1,
237237
ensemble_method = EnsembleThreads(),
@@ -283,7 +283,7 @@ If the environmental measurements register a quantum jump, the wave function und
283283
- `tlist`: List of times at which to save either the state or the expectation values of the system.
284284
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
285285
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
286-
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver.
286+
- `params`: Parameters to pass to the solver. This argument is usually expressed as a `NamedTuple` or `AbstractVector` of parameters. For more advanced usage, any custom struct can be used.
287287
- `rng`: Random number generator for reproducibility.
288288
- `ntraj`: Number of trajectories to use.
289289
- `ensemble_method`: Ensemble method to use. Default to `EnsembleThreads()`.
@@ -310,7 +310,7 @@ function mcsolveEnsembleProblem(
310310
tlist::AbstractVector,
311311
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
312312
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
313-
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
313+
params = NullParameters(),
314314
rng::AbstractRNG = default_rng(),
315315
ntraj::Int = 1,
316316
ensemble_method = EnsembleThreads(),
@@ -354,7 +354,7 @@ end
354354
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
355355
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
356356
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
357-
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
357+
params = NullParameters(),
358358
rng::AbstractRNG = default_rng(),
359359
ntraj::Int = 1,
360360
ensemble_method = EnsembleThreads(),
@@ -408,7 +408,7 @@ If the environmental measurements register a quantum jump, the wave function und
408408
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
409409
- `alg`: The algorithm to use for the ODE solver. Default to `Tsit5()`.
410410
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
411-
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver.
411+
- `params`: Parameters to pass to the solver. This argument is usually expressed as a `NamedTuple` or `AbstractVector` of parameters. For more advanced usage, any custom struct can be used.
412412
- `rng`: Random number generator for reproducibility.
413413
- `ntraj`: Number of trajectories to use.
414414
- `ensemble_method`: Ensemble method to use. Default to `EnsembleThreads()`.
@@ -439,7 +439,7 @@ function mcsolve(
439439
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
440440
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
441441
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
442-
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
442+
params = NullParameters(),
443443
rng::AbstractRNG = default_rng(),
444444
ntraj::Int = 1,
445445
ensemble_method = EnsembleThreads(),

src/time_evolution/sesolve.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ _sesolve_make_U_QobjEvo(H) = QobjEvo(H, -1im)
2525
ψ0::QuantumObject{DT2,KetQuantumObject},
2626
tlist::AbstractVector;
2727
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
28-
params = eltype(ψ0)[],
28+
params = NullParameters(),
2929
progress_bar::Union{Val,Bool} = Val(true),
3030
inplace::Union{Val,Bool} = Val(true),
3131
kwargs...,
@@ -43,7 +43,7 @@ Generate the ODEProblem for the Schrödinger time evolution of a quantum system:
4343
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``.
4444
- `tlist`: List of times at which to save either the state or the expectation values of the system.
4545
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
46-
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
46+
- `params`: Parameters to pass to the solver. This argument is usually expressed as a `NamedTuple` or `AbstractVector` of parameters. For more advanced usage, any custom struct can be used.
4747
- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
4848
- `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
4949
- `kwargs`: The keyword arguments for the ODEProblem.
@@ -64,7 +64,7 @@ function sesolveProblem(
6464
ψ0::QuantumObject{DT2,KetQuantumObject},
6565
tlist::AbstractVector;
6666
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
67-
params = eltype(ψ0)[],
67+
params = NullParameters(),
6868
progress_bar::Union{Val,Bool} = Val(true),
6969
inplace::Union{Val,Bool} = Val(true),
7070
kwargs...,
@@ -102,7 +102,7 @@ end
102102
tlist::AbstractVector;
103103
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
104104
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
105-
params = eltype(ψ0)[],
105+
params = NullParameters(),
106106
progress_bar::Union{Val,Bool} = Val(true),
107107
inplace::Union{Val,Bool} = Val(true),
108108
kwargs...,
@@ -121,7 +121,7 @@ Time evolution of a closed quantum system using the Schrödinger equation:
121121
- `tlist`: List of times at which to save either the state or the expectation values of the system.
122122
- `alg`: The algorithm for the ODE solver. The default is `Tsit5()`.
123123
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
124-
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
124+
- `params`: Parameters to pass to the solver. This argument is usually expressed as a `NamedTuple` or `AbstractVector` of parameters. For more advanced usage, any custom struct can be used.
125125
- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
126126
- `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
127127
- `kwargs`: The keyword arguments for the ODEProblem.
@@ -144,7 +144,7 @@ function sesolve(
144144
tlist::AbstractVector;
145145
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
146146
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
147-
params = eltype(ψ0)[],
147+
params = NullParameters(),
148148
progress_bar::Union{Val,Bool} = Val(true),
149149
inplace::Union{Val,Bool} = Val(true),
150150
kwargs...,

src/time_evolution/time_evo_parameters.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function _vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:NamedT
4848
buffer = isempty(p.params) ? ComplexF64[] : collect(values(p.params))
4949
return (buffer, false)
5050
end
51+
_vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:NullParameters} = (ComplexF64[], false)
5152
_vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:AbstractVector} = (p.params, true)
5253

5354
function canonicalize(::Tunable, p::TimeEvolutionParameters)

0 commit comments

Comments
 (0)