@@ -129,25 +129,26 @@ function _DFDIncreaseReduceAffect!(integrator)
129129
130130 resize! (integrator, size (L, 1 ))
131131 copyto! (integrator. u, mat2vec (ρt))
132- integrator. p = merge (internal_params, (L = L, e_ops = e_ops2, dfd_ρt_cache = similar (integrator. u)))
132+ # By doing this, we are assuming that the system is time-independent and f is a MatrixOperator
133+ integrator. f = ODEFunction {true,FullSpecialize} (MatrixOperator (L))
134+ integrator. p = merge (internal_params, (e_ops = e_ops2, dfd_ρt_cache = similar (integrator. u)))
133135
134136 return nothing
135137end
136138
137139function dfd_mesolveProblem (
138140 H:: Function ,
139- ψ0:: QuantumObject{<:AbstractArray{T1} ,StateOpType} ,
141+ ψ0:: QuantumObject{DT1 ,StateOpType} ,
140142 t_l:: AbstractVector ,
141143 c_ops:: Function ,
142144 maxdims:: Vector{T2} ,
143145 dfd_params:: NamedTuple = NamedTuple ();
144146 alg:: OrdinaryDiffEqAlgorithm = Tsit5 (),
145- e_ops:: Function = (dim_list) -> Vector {Vector{T1}} ([]),
146- H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
147+ e_ops:: Function = (dim_list) -> Vector {Vector{DT1}} ([]),
147148 params:: NamedTuple = NamedTuple (),
148149 tol_list:: Vector{<:Number} = fill (1e-8 , length (maxdims)),
149150 kwargs... ,
150- ) where {T1 ,T2<: Integer ,StateOpType<: Union{KetQuantumObject,OperatorQuantumObject} }
151+ ) where {DT1 ,T2<: Integer ,StateOpType<: Union{KetQuantumObject,OperatorQuantumObject} }
151152 length (ψ0. dims) != length (maxdims) &&
152153 throw (DimensionMismatch (" 'dim_list' and 'maxdims' do not have the same dimension." ))
153154
@@ -158,8 +159,8 @@ function dfd_mesolveProblem(
158159
159160 dim_list_evo_times = [0.0 ]
160161 dim_list_evo = [dim_list]
161- reduce_list = MVector (ntuple (i -> false , length (dim_list)))
162- increase_list = MVector (ntuple (i -> false , length (dim_list)))
162+ reduce_list = MVector (ntuple (i -> false , Val ( length (dim_list) )))
163+ increase_list = MVector (ntuple (i -> false , Val ( length (dim_list) )))
163164 pillow_list = _dfd_set_pillow .(dim_list)
164165
165166 params2 = merge (
@@ -187,7 +188,7 @@ function dfd_mesolveProblem(
187188 haskey (kwargs2, :callback ) ? merge (kwargs2, (callback = CallbackSet (cb_dfd, kwargs2. callback),)) :
188189 merge (kwargs2, (callback = cb_dfd,))
189190
190- return mesolveProblem (H₀, ψ0, t_l, c_ops₀; e_ops = e_ops₀, alg = alg, H_t = H_t, params = params2, kwargs2... )
191+ return mesolveProblem (H₀, ψ0, t_l, c_ops₀; e_ops = e_ops₀, alg = alg, params = params2, kwargs2... )
191192end
192193
193194@doc raw """
196197 dfd_params::NamedTuple=NamedTuple();
197198 alg::OrdinaryDiffEqAlgorithm=Tsit5(),
198199 e_ops::Function=(dim_list) -> Vector{Vector{T1}}([]),
199- H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
200200 params::NamedTuple=NamedTuple(),
201201 tol_list::Vector{<:Number}=fill(1e-8, length(maxdims)),
202202 kwargs...)
@@ -216,7 +216,6 @@ function dfd_mesolve(
216216 dfd_params:: NamedTuple = NamedTuple ();
217217 alg:: OrdinaryDiffEqAlgorithm = Tsit5 (),
218218 e_ops:: Function = (dim_list) -> Vector {Vector{T1}} ([]),
219- H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
220219 params:: NamedTuple = NamedTuple (),
221220 tol_list:: Vector{<:Number} = fill (1e-8 , length (maxdims)),
222221 kwargs... ,
@@ -230,7 +229,6 @@ function dfd_mesolve(
230229 dfd_params;
231230 alg = alg,
232231 e_ops = e_ops,
233- H_t = H_t,
234232 params = params,
235233 tol_list = tol_list,
236234 kwargs... ,
@@ -335,7 +333,9 @@ function _DSF_mesolve_Affect!(integrator)
335333 e_ops2 = e_ops (op_l2, dsf_params)
336334 _mat2vec_data = op -> mat2vec (get_data (op)' )
337335 @. e_ops_vec = _mat2vec_data (e_ops2)
338- return copyto! (internal_params. L, liouvillian (H (op_l2, dsf_params), c_ops (op_l2, dsf_params), dsf_identity). data)
336+ # By doing this, we are assuming that the system is time-independent and f is a MatrixOperator
337+ copyto! (integrator. f. f. A, liouvillian (H (op_l2, dsf_params), c_ops (op_l2, dsf_params), dsf_identity). data)
338+ return u_modified! (integrator, true )
339339end
340340
341341function dsf_mesolveProblem (
@@ -348,7 +348,6 @@ function dsf_mesolveProblem(
348348 dsf_params:: NamedTuple = NamedTuple ();
349349 alg:: OrdinaryDiffEqAlgorithm = Tsit5 (),
350350 e_ops:: Function = (op_list, p) -> Vector {TOl} ([]),
351- H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
352351 params:: NamedTuple = NamedTuple (),
353352 δα_list:: Vector{<:Real} = fill (0.2 , length (op_list)),
354353 krylov_dim:: Int = max (6 , min (10 , cld (length (ket2dm (ψ0). data), 4 ))),
@@ -403,7 +402,7 @@ function dsf_mesolveProblem(
403402 haskey (kwargs2, :callback ) ? merge (kwargs2, (callback = CallbackSet (cb_dsf, kwargs2. callback),)) :
404403 merge (kwargs2, (callback = cb_dsf,))
405404
406- return mesolveProblem (H₀, ψ0, t_l, c_ops₀; e_ops = e_ops₀, alg = alg, H_t = H_t, params = params2, kwargs2... )
405+ return mesolveProblem (H₀, ψ0, t_l, c_ops₀; e_ops = e_ops₀, alg = alg, params = params2, kwargs2... )
407406end
408407
409408@doc raw """
415414 dsf_params::NamedTuple=NamedTuple();
416415 alg::OrdinaryDiffEqAlgorithm=Tsit5(),
417416 e_ops::Function=(op_list,p) -> Vector{TOl}([]),
418- H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
419417 params::NamedTuple=NamedTuple(),
420418 δα_list::Vector{<:Number}=fill(0.2, length(op_list)),
421419 krylov_dim::Int=max(6, min(10, cld(length(ket2dm(ψ0).data), 4))),
@@ -437,7 +435,6 @@ function dsf_mesolve(
437435 dsf_params:: NamedTuple = NamedTuple ();
438436 alg:: OrdinaryDiffEqAlgorithm = Tsit5 (),
439437 e_ops:: Function = (op_list, p) -> Vector {TOl} ([]),
440- H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
441438 params:: NamedTuple = NamedTuple (),
442439 δα_list:: Vector{<:Real} = fill (0.2 , length (op_list)),
443440 krylov_dim:: Int = max (6 , min (10 , cld (length (ket2dm (ψ0). data), 4 ))),
@@ -453,7 +450,6 @@ function dsf_mesolve(
453450 dsf_params;
454451 alg = alg,
455452 e_ops = e_ops,
456- H_t = H_t,
457453 params = params,
458454 δα_list = δα_list,
459455 krylov_dim = krylov_dim,
@@ -472,7 +468,6 @@ function dsf_mesolve(
472468 dsf_params:: NamedTuple = NamedTuple ();
473469 alg:: OrdinaryDiffEqAlgorithm = Tsit5 (),
474470 e_ops:: Function = (op_list, p) -> Vector {TOl} ([]),
475- H_t:: Union{Nothing,Function,TimeDependentOperatorSum} = nothing ,
476471 params:: NamedTuple = NamedTuple (),
477472 δα_list:: Vector{<:Real} = fill (0.2 , length (op_list)),
478473 krylov_dim:: Int = max (6 , min (10 , cld (length (ket2dm (ψ0). data), 4 ))),
@@ -489,7 +484,6 @@ function dsf_mesolve(
489484 dsf_params;
490485 alg = alg,
491486 e_ops = e_ops,
492- H_t = H_t,
493487 params = params,
494488 δα_list = δα_list,
495489 krylov_dim = krylov_dim,
@@ -745,5 +739,5 @@ function dsf_mcsolve(
745739 kwargs... ,
746740 )
747741
748- return mcsolve (ens_prob_mc, t_l ; alg = alg, ntraj = ntraj, ensemble_method = ensemble_method)
742+ return mcsolve (ens_prob_mc; alg = alg, ntraj = ntraj, ensemble_method = ensemble_method)
749743end
0 commit comments