You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/time_evolution/mesolve.jl
+16-7Lines changed: 16 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ where
33
33
# Arguments
34
34
35
35
- `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs.
36
-
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref)or a [`Operator`](@ref).
36
+
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref), [`Operator`](@ref) or [`OperatorKet`](@ref).
37
37
- `tlist`: List of times at which to save either the state or the expectation values of the system.
38
38
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
39
39
- `e_ops`: List of operators for which to calculate expectation values. It can be either a `Vector` or a `Tuple`.
- `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs.
120
-
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref)or a [`Operator`](@ref).
124
+
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref), [`Operator`](@ref) or [`OperatorKet`](@ref).
121
125
- `tlist`: List of times at which to save either the state or the expectation values of the system.
122
126
- `c_ops`: List of collapse operators ``\{\hat{C}_n\}_n``. It can be either a `Vector` or a `Tuple`.
123
127
- `alg`: The algorithm for the ODE solver. The default value is `Tsit5()`.
@@ -47,7 +48,7 @@ Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipatio
47
48
# Arguments
48
49
49
50
- `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs.
50
-
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref)or a [`Operator`](@ref).
51
+
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref), [`Operator`](@ref) or [`OperatorKet`](@ref).
51
52
- `tlist`: List of times at which to save either the state or the expectation values of the system.
52
53
- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`.
53
54
- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector`, a `Tuple` or a [`AbstractQuantumObject`](@ref). It is recommended to use the last case when only one operator is provided.
@@ -84,7 +85,7 @@ function smesolveProblem(
84
85
progress_bar::Union{Val,Bool}=Val(true),
85
86
store_measurement::Union{Val,Bool}=Val(false),
86
87
kwargs...,
87
-
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}}
88
+
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject,OperatorKetQuantumObject}}
88
89
haskey(kwargs, :save_idxs) &&
89
90
throw(ArgumentError("The keyword argument \"save_idxs\" is not supported in QuantumToolbox."))
90
91
@@ -100,7 +101,11 @@ function smesolveProblem(
100
101
dims = L_evo.dimensions
101
102
102
103
T = Base.promote_eltype(L_evo, ψ0)
103
-
ρ0 =to_dense(_CType(T), mat2vec(ket2dm(ψ0).data)) # Convert it to dense vector with complex element type
104
+
ρ0 =ifisoperket(ψ0) # Convert it to dense vector with complex element type
@@ -188,7 +193,7 @@ Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipatio
188
193
# Arguments
189
194
190
195
- `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs.
191
-
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref)or a [`Operator`](@ref).
196
+
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref), [`Operator`](@ref) or [`OperatorKet`](@ref).
192
197
- `tlist`: List of times at which to save either the state or the expectation values of the system.
193
198
- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`.
194
199
- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector`, a `Tuple` or a [`AbstractQuantumObject`](@ref). It is recommended to use the last case when only one operator is provided.
@@ -233,7 +238,7 @@ function smesolveEnsembleProblem(
233
238
progress_bar::Union{Val,Bool}=Val(true),
234
239
store_measurement::Union{Val,Bool}=Val(false),
235
240
kwargs...,
236
-
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}}
241
+
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject,OperatorKetQuantumObject}}
237
242
_prob_func =
238
243
isnothing(prob_func) ?
239
244
_ensemble_dispatch_prob_func(
@@ -266,7 +271,7 @@ function smesolveEnsembleProblem(
@@ -315,7 +320,7 @@ Above, ``\hat{C}_i`` represent the collapse operators related to pure dissipatio
315
320
# Arguments
316
321
317
322
- `H`: Hamiltonian of the system ``\hat{H}``. It can be either a [`QuantumObject`](@ref), a [`QuantumObjectEvolution`](@ref), or a `Tuple` of operator-function pairs.
318
-
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref)or a [`Operator`](@ref).
323
+
- `ψ0`: Initial state of the system ``|\psi(0)\rangle``. It can be either a [`Ket`](@ref), [`Operator`](@ref) or [`OperatorKet`](@ref).
319
324
- `tlist`: List of times at which to save either the state or the expectation values of the system.
320
325
- `c_ops`: List of collapse operators ``\{\hat{C}_i\}_i``. It can be either a `Vector` or a `Tuple`.
321
326
- `sc_ops`: List of stochastic collapse operators ``\{\hat{S}_n\}_n``. It can be either a `Vector`, a `Tuple` or a [`AbstractQuantumObject`](@ref). It is recommended to use the last case when only one operator is provided.
@@ -362,7 +367,7 @@ function smesolve(
362
367
progress_bar::Union{Val,Bool}=Val(true),
363
368
store_measurement::Union{Val,Bool}=Val(false),
364
369
kwargs...,
365
-
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject}}
370
+
) where {StateOpType<:Union{KetQuantumObject,OperatorQuantumObject,OperatorKetQuantumObject}}
366
371
ensemble_prob =smesolveEnsembleProblem(
367
372
H,
368
373
ψ0,
@@ -406,7 +411,8 @@ function smesolve(
406
411
_expvals_all =
407
412
_expvals_sol_1 isa Nothing ?nothing:map(i ->_get_expvals(sol[:, i], SaveFuncMESolve), eachindex(sol))
408
413
expvals_all = _expvals_all isa Nothing ?nothing:stack(_expvals_all, dims =2) # Stack on dimension 2 to align with QuTiP
409
-
states =map(i ->_smesolve_generate_state.(sol[:, i].u, Ref(dims)), eachindex(sol))
414
+
415
+
states =map(i ->_smesolve_generate_state.(sol[:, i].u, Ref(dims), ens_prob.kwargs.isoperket), eachindex(sol))
410
416
411
417
_m_expvals =
412
418
_m_expvals_sol_1 isa Nothing ?nothing:map(i ->_get_m_expvals(sol[:, i], SaveFuncSMESolve), eachindex(sol))
0 commit comments