101101 mcsolveProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
102102 ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
103103 tlist::AbstractVector,
104- c_ops::Vector{QuantumObject{Tc, OperatorQuantumObject}}=QuantumObject{Matrix, OperatorQuantumObject}[] ;
104+ c_ops::Union{Nothing,AbstractVector}=nothing ;
105105 alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm=Tsit5(),
106106 e_ops::Union{Nothing,AbstractVector}=nothing,
107107 H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
@@ -148,7 +148,7 @@ If the environmental measurements register a quantum jump, the wave function und
148148- `H::QuantumObject`: Hamiltonian of the system ``\h at{H}``.
149149- `ψ0::QuantumObject`: Initial state of the system ``|\p si(0)\r angle``.
150150- `tlist::AbstractVector`: List of times at which to save the state of the system.
151- - `c_ops::Vector `: List of collapse operators ``\{\h at{C}_n\} _n``.
151+ - `c_ops::Union{Nothing,AbstractVector} `: List of collapse operators ``\{\h at{C}_n\} _n``.
152152- `alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm`: Algorithm to use for the time evolution.
153153- `e_ops::Union{Nothing,AbstractVector}`: List of operators for which to calculate expectation values.
154154- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
@@ -170,25 +170,28 @@ If the environmental measurements register a quantum jump, the wave function und
170170"""
171171function mcsolveProblem (
172172 H:: QuantumObject{MT1,OperatorQuantumObject} ,
173- ψ0:: QuantumObject{<:AbstractArray{T2} ,KetQuantumObject} ,
173+ ψ0:: QuantumObject{<:AbstractArray,KetQuantumObject} ,
174174 tlist:: AbstractVector ,
175- c_ops:: Vector{QuantumObject{Tc,OperatorQuantumObject}} = QuantumObject{MT1,OperatorQuantumObject}[] ;
175+ c_ops:: Union{Nothing,AbstractVector} = nothing ;
176176 alg:: OrdinaryDiffEq.OrdinaryDiffEqAlgorithm = Tsit5 (),
177177 e_ops:: Union{Nothing,AbstractVector} = nothing ,
178178 H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
179179 params:: NamedTuple = NamedTuple (),
180180 seeds:: Union{Nothing,Vector{Int}} = nothing ,
181181 jump_callback:: TJC = ContinuousLindbladJumpCallback (),
182182 kwargs... ,
183- ) where {MT1<: AbstractMatrix ,T2,Tc <: AbstractMatrix , TJC<: LindbladJumpCallbackType }
183+ ) where {MT1<: AbstractMatrix ,TJC<: LindbladJumpCallbackType }
184184 H. dims != ψ0. dims && throw (DimensionMismatch (" The two quantum objects are not of the same Hilbert dimension." ))
185185
186186 haskey (kwargs, :save_idxs ) &&
187187 throw (ArgumentError (" The keyword argument \" save_idxs\" is not supported in QuantumToolbox." ))
188188
189+ c_ops isa Nothing &&
190+ throw (ArgumentError (" The list of collapse operators must be provided. Use sesolveProblem instead." ))
191+
189192 t_l = convert (Vector{Float64}, tlist) # Convert it into Float64 to avoid type instabilities for OrdinaryDiffEq.jl
190193
191- H_eff = H - T2 ( 0.5im ) * mapreduce (op -> op' * op, + , c_ops)
194+ H_eff = H - 1im * mapreduce (op -> op' * op, + , c_ops) / 2
192195
193196 if e_ops isa Nothing
194197 expvals = Array {ComplexF64} (undef, 0 , length (t_l))
@@ -254,15 +257,15 @@ function mcsolveProblem(
254257end
255258
256259function mcsolveProblem (
257- H_eff:: QuantumObject{<:AbstractArray{T1} ,OperatorQuantumObject} ,
258- ψ0:: QuantumObject{<:AbstractArray{T2} ,KetQuantumObject} ,
260+ H_eff:: QuantumObject{<:AbstractArray,OperatorQuantumObject} ,
261+ ψ0:: QuantumObject{<:AbstractArray,KetQuantumObject} ,
259262 t_l:: AbstractVector ,
260263 alg:: OrdinaryDiffEq.OrdinaryDiffEqAlgorithm ,
261264 H_t:: Union{Nothing,Function,TimeDependentOperatorSum} ,
262265 params:: NamedTuple ,
263266 jump_callback:: ContinuousLindbladJumpCallback ;
264267 kwargs... ,
265- ) where {T1,T2}
268+ )
266269 cb1 = ContinuousCallback (
267270 LindbladJumpContinuousCondition,
268271 LindbladJumpAffect!,
283286 mcsolveEnsembleProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
284287 ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
285288 tlist::AbstractVector,
286- c_ops::Vector{QuantumObject{Tc, OperatorQuantumObject}}=QuantumObject{Matrix, OperatorQuantumObject}[] ;
289+ c_ops::Union{Nothing,AbstractVector}=nothing ;
287290 alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm=Tsit5(),
288- e_ops::Vector{QuantumObject{Te, OperatorQuantumObject}}=QuantumObject{Matrix, OperatorQuantumObject}[] ,
291+ e_ops::Union{Nothing,AbstractVector}=nothing ,
289292 H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
290293 params::NamedTuple=NamedTuple(),
291294 jump_callback::TJC=ContinuousLindbladJumpCallback(),
@@ -332,9 +335,9 @@ If the environmental measurements register a quantum jump, the wave function und
332335- `H::QuantumObject`: Hamiltonian of the system ``\h at{H}``.
333336- `ψ0::QuantumObject`: Initial state of the system ``|\p si(0)\r angle``.
334337- `tlist::AbstractVector`: List of times at which to save the state of the system.
335- - `c_ops::Vector `: List of collapse operators ``\{\h at{C}_n\} _n``.
338+ - `c_ops::Union{Nothing,AbstractVector} `: List of collapse operators ``\{\h at{C}_n\} _n``.
336339- `alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm`: Algorithm to use for the time evolution.
337- - `e_ops::Vector `: List of operators for which to calculate expectation values.
340+ - `e_ops::Union{Nothing,AbstractVector} `: List of operators for which to calculate expectation values.
338341- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
339342- `params::NamedTuple`: Dictionary of parameters to pass to the solver.
340343- `seeds::Union{Nothing, Vector{Int}}`: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
@@ -358,17 +361,17 @@ function mcsolveEnsembleProblem(
358361 H:: QuantumObject{MT1,OperatorQuantumObject} ,
359362 ψ0:: QuantumObject{<:AbstractArray{T2},KetQuantumObject} ,
360363 tlist:: AbstractVector ,
361- c_ops:: Vector{QuantumObject{Tc,OperatorQuantumObject}} = QuantumObject{MT1,OperatorQuantumObject}[] ;
364+ c_ops:: Union{Nothing,AbstractVector} = nothing ;
362365 alg:: OrdinaryDiffEq.OrdinaryDiffEqAlgorithm = Tsit5 (),
363- e_ops:: Vector{QuantumObject{Te,OperatorQuantumObject}} = QuantumObject{MT1,OperatorQuantumObject}[] ,
366+ e_ops:: Union{Nothing,AbstractVector} = nothing ,
364367 H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
365368 params:: NamedTuple = NamedTuple (),
366369 jump_callback:: TJC = ContinuousLindbladJumpCallback (),
367370 seeds:: Union{Nothing,Vector{Int}} = nothing ,
368371 prob_func:: Function = _mcsolve_prob_func,
369372 output_func:: Function = _mcsolve_output_func,
370373 kwargs... ,
371- ) where {MT1<: AbstractMatrix ,T2,Tc <: AbstractMatrix ,Te <: AbstractMatrix , TJC<: LindbladJumpCallbackType }
374+ ) where {MT1<: AbstractMatrix ,T2,TJC<: LindbladJumpCallbackType }
372375 prob_mc = mcsolveProblem (
373376 H,
374377 ψ0,
392395 mcsolve(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
393396 ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
394397 tlist::AbstractVector,
395- c_ops::Vector{QuantumObject{Tc, OperatorQuantumObject}}=QuantumObject{Matrix, OperatorQuantumObject}[] ;
398+ c_ops::Union{Nothing,AbstractVector}=nothing ;
396399 alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm=Tsit5(),
397- e_ops::Vector{QuantumObject{Te, OperatorQuantumObject}}=QuantumObject{Matrix, OperatorQuantumObject}[] ,
400+ e_ops::Union{Nothing,AbstractVector}=nothing ,
398401 H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
399402 params::NamedTuple=NamedTuple(),
400403 n_traj::Int=1,
@@ -441,9 +444,9 @@ If the environmental measurements register a quantum jump, the wave function und
441444- `H::QuantumObject`: Hamiltonian of the system ``\h at{H}``.
442445- `ψ0::QuantumObject`: Initial state of the system ``|\p si(0)\r angle``.
443446- `tlist::AbstractVector`: List of times at which to save the state of the system.
444- - `c_ops::Vector `: List of collapse operators ``\{\h at{C}_n\} _n``.
447+ - `c_ops::Union{Nothing,AbstractVector} `: List of collapse operators ``\{\h at{C}_n\} _n``.
445448- `alg::OrdinaryDiffEq.OrdinaryDiffEqAlgorithm`: Algorithm to use for the time evolution.
446- - `e_ops::Vector `: List of operators for which to calculate expectation values.
449+ - `e_ops::Union{Nothing,AbstractVector} `: List of operators for which to calculate expectation values.
447450- `H_t::Union{Nothing,Function,TimeDependentOperatorSum}`: Time-dependent part of the Hamiltonian.
448451- `params::NamedTuple`: Dictionary of parameters to pass to the solver.
449452- `seeds::Union{Nothing, Vector{Int}}`: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
@@ -470,9 +473,9 @@ function mcsolve(
470473 H:: QuantumObject{MT1,OperatorQuantumObject} ,
471474 ψ0:: QuantumObject{<:AbstractArray{T2},KetQuantumObject} ,
472475 tlist:: AbstractVector ,
473- c_ops:: Vector{QuantumObject{Tc,OperatorQuantumObject}} = QuantumObject{MT1,OperatorQuantumObject}[] ;
476+ c_ops:: Union{Nothing,AbstractVector} = nothing ;
474477 alg:: OrdinaryDiffEq.OrdinaryDiffEqAlgorithm = Tsit5 (),
475- e_ops:: Vector{QuantumObject{Te,OperatorQuantumObject}} = QuantumObject{MT1,OperatorQuantumObject}[] ,
478+ e_ops:: Union{Nothing,AbstractVector} = nothing ,
476479 H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
477480 params:: NamedTuple = NamedTuple (),
478481 seeds:: Union{Nothing,Vector{Int}} = nothing ,
@@ -482,7 +485,7 @@ function mcsolve(
482485 prob_func:: Function = _mcsolve_prob_func,
483486 output_func:: Function = _mcsolve_output_func,
484487 kwargs... ,
485- ) where {MT1<: AbstractMatrix ,T2,Tc <: AbstractMatrix ,Te <: AbstractMatrix , TJC<: LindbladJumpCallbackType }
488+ ) where {MT1<: AbstractMatrix ,T2,TJC<: LindbladJumpCallbackType }
486489 if ! isnothing (seeds) && length (seeds) != n_traj
487490 throw (ArgumentError (" Length of seeds must match n_traj ($n_traj ), but got $(length (seeds)) " ))
488491 end
0 commit comments