Skip to content

Commit

Permalink
Make NullParameters as default for params
Browse files Browse the repository at this point in the history
  • Loading branch information
albertomercurio committed Nov 17, 2024
1 parent dddb60b commit 024b4fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/QuantumToolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import SciMLBase:
reinit!,
remake,
u_modified!,
NullParameters,
ODEFunction,
ODEProblem,
SDEProblem,
Expand Down
18 changes: 9 additions & 9 deletions src/time_evolution/mcsolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ end
tlist::AbstractVector,
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
jump_callback::TJC = ContinuousLindbladJumpCallback(),
kwargs...,
Expand Down Expand Up @@ -151,7 +151,7 @@ If the environmental measurements register a quantum jump, the wave function und
- `tlist`: List of times at which to save either the state or the expectation values of the system.
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
- `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.
- `rng`: Random number generator for reproducibility.
- `jump_callback`: The Jump Callback type: Discrete or Continuous. The default is `ContinuousLindbladJumpCallback()`, which is more precise.
- `kwargs`: The keyword arguments for the ODEProblem.
Expand All @@ -173,7 +173,7 @@ function mcsolveProblem(
tlist::AbstractVector,
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
jump_callback::TJC = ContinuousLindbladJumpCallback(),
kwargs...,
Expand Down Expand Up @@ -231,7 +231,7 @@ end
tlist::AbstractVector,
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
ntraj::Int = 1,
ensemble_method = EnsembleThreads(),
Expand Down Expand Up @@ -283,7 +283,7 @@ If the environmental measurements register a quantum jump, the wave function und
- `tlist`: List of times at which to save either the state or the expectation values of the system.
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver.
- `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.
- `rng`: Random number generator for reproducibility.
- `ntraj`: Number of trajectories to use.
- `ensemble_method`: Ensemble method to use. Default to `EnsembleThreads()`.
Expand All @@ -310,7 +310,7 @@ function mcsolveEnsembleProblem(
tlist::AbstractVector,
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
ntraj::Int = 1,
ensemble_method = EnsembleThreads(),
Expand Down Expand Up @@ -354,7 +354,7 @@ end
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
ntraj::Int = 1,
ensemble_method = EnsembleThreads(),
Expand Down Expand Up @@ -408,7 +408,7 @@ If the environmental measurements register a quantum jump, the wave function und
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
- `alg`: The algorithm to use for the ODE solver. Default to `Tsit5()`.
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver.
- `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.
- `rng`: Random number generator for reproducibility.
- `ntraj`: Number of trajectories to use.
- `ensemble_method`: Ensemble method to use. Default to `EnsembleThreads()`.
Expand Down Expand Up @@ -439,7 +439,7 @@ function mcsolve(
c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params::Union{NamedTuple,AbstractVector} = eltype(ψ0)[],
params = NullParameters(),
rng::AbstractRNG = default_rng(),
ntraj::Int = 1,
ensemble_method = EnsembleThreads(),
Expand Down
12 changes: 6 additions & 6 deletions src/time_evolution/sesolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ _sesolve_make_U_QobjEvo(H) = QobjEvo(H, -1im)
ψ0::QuantumObject{DT2,KetQuantumObject},
tlist::AbstractVector;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
progress_bar::Union{Val,Bool} = Val(true),
inplace::Union{Val,Bool} = Val(true),
kwargs...,
Expand All @@ -43,7 +43,7 @@ Generate the ODEProblem for the Schrödinger time evolution of a quantum system:
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``.
- `tlist`: List of times at which to save either the state or the expectation values of the system.
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
- `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.
- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
- `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
- `kwargs`: The keyword arguments for the ODEProblem.
Expand All @@ -64,7 +64,7 @@ function sesolveProblem(
ψ0::QuantumObject{DT2,KetQuantumObject},
tlist::AbstractVector;
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
progress_bar::Union{Val,Bool} = Val(true),
inplace::Union{Val,Bool} = Val(true),
kwargs...,
Expand Down Expand Up @@ -102,7 +102,7 @@ end
tlist::AbstractVector;
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
progress_bar::Union{Val,Bool} = Val(true),
inplace::Union{Val,Bool} = Val(true),
kwargs...,
Expand All @@ -121,7 +121,7 @@ Time evolution of a closed quantum system using the Schrödinger equation:
- `tlist`: List of times at which to save either the state or the expectation values of the system.
- `alg`: The algorithm for the ODE solver. The default is `Tsit5()`.
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `params`: `NamedTuple` or `AbstractVector` of parameters to pass to the solver. For more advanced usage, any custom struct can be used.
- `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.
- `progress_bar`: Whether to show the progress bar. Using non-`Val` types might lead to type instabilities.
- `inplace`: Whether to use the inplace version of the ODEProblem. The default is `Val(true)`.
- `kwargs`: The keyword arguments for the ODEProblem.
Expand All @@ -144,7 +144,7 @@ function sesolve(
tlist::AbstractVector;
alg::OrdinaryDiffEqAlgorithm = Tsit5(),
e_ops::Union{Nothing,AbstractVector,Tuple} = nothing,
params = eltype(ψ0)[],
params = NullParameters(),
progress_bar::Union{Val,Bool} = Val(true),
inplace::Union{Val,Bool} = Val(true),
kwargs...,
Expand Down
1 change: 1 addition & 0 deletions src/time_evolution/time_evo_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function _vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:NamedT
buffer = isempty(p.params) ? ComplexF64[] : collect(values(p.params))
return (buffer, false)
end
_vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:NullParameters} = (ComplexF64[], false)
_vectorize_params(p::TimeEvolutionParameters{ParT}) where {ParT<:AbstractVector} = (p.params, true)

function canonicalize(::Tunable, p::TimeEvolutionParameters)
Expand Down

0 comments on commit 024b4fd

Please sign in to comment.