Skip to content

Commit e89535f

Browse files
[no ci] Check tlist properties
1 parent e6f7670 commit e89535f

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

src/time_evolution/lr_mesolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ function lr_mesolveProblem(
409409
c_ops = get_data.(c_ops)
410410
e_ops = get_data.(e_ops)
411411

412-
t_l = convert(Vector{_FType(H)}, tlist)
412+
t_l = _check_tlist(tlist, _FType(H))
413413

414414
# Initialization of Arrays
415415
expvals = Array{ComplexF64}(undef, length(e_ops), length(t_l))

src/time_evolution/mcsolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function mcsolveProblem(
167167
c_ops isa Nothing &&
168168
throw(ArgumentError("The list of collapse operators must be provided. Use sesolveProblem instead."))
169169

170-
tlist = convert(Vector{_FType(ψ0)}, tlist) # Convert it to support GPUs and avoid type instabilities for OrdinaryDiffEq.jl
170+
tlist = _check_tlist(tlist, _FType(ψ0))
171171

172172
H_eff_evo = _mcsolve_make_Heff_QobjEvo(H, c_ops)
173173

src/time_evolution/mesolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function mesolveProblem(
6868
haskey(kwargs, :save_idxs) &&
6969
throw(ArgumentError("The keyword argument \"save_idxs\" is not supported in QuantumToolbox."))
7070

71-
tlist = convert(Vector{_FType(ψ0)}, tlist) # Convert it to support GPUs and avoid type instabilities for OrdinaryDiffEq.jl
71+
tlist = _check_tlist(tlist, _FType(ψ0))
7272

7373
L_evo = _mesolve_make_L_QobjEvo(H, c_ops)
7474
check_dimensions(L_evo, ψ0)

src/time_evolution/sesolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function sesolveProblem(
5959
haskey(kwargs, :save_idxs) &&
6060
throw(ArgumentError("The keyword argument \"save_idxs\" is not supported in QuantumToolbox."))
6161

62-
tlist = convert(Vector{_FType(ψ0)}, tlist) # Convert it to support GPUs and avoid type instabilities for OrdinaryDiffEq.jl
62+
tlist = _check_tlist(tlist, _FType(ψ0))
6363

6464
H_evo = _sesolve_make_U_QobjEvo(H) # Multiply by -i
6565
isoper(H_evo) || throw(ArgumentError("The Hamiltonian must be an Operator."))

src/time_evolution/ssesolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function ssesolveProblem(
162162
sc_ops isa Nothing &&
163163
throw(ArgumentError("The list of collapse operators must be provided. Use sesolveProblem instead."))
164164

165-
tlist = convert(Vector{Float64}, tlist) # Convert it into Float64 to avoid type instabilities for StochasticDiffEq.jl
165+
tlist = _check_tlist(tlist, _FType(ψ0))
166166

167167
H_eff_evo = _mcsolve_make_Heff_QobjEvo(H, sc_ops)
168168
isoper(H_eff_evo) || throw(ArgumentError("The Hamiltonian must be an Operator."))

src/time_evolution/time_evolution.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,20 @@ struct DiscreteLindbladJumpCallback <: LindbladJumpCallbackType end
212212

213213
ContinuousLindbladJumpCallback(; interp_points::Int = 10) = ContinuousLindbladJumpCallback(interp_points)
214214

215+
function _check_tlist(tlist, T::Type)
216+
217+
tlist = convert(Vector{T}, tlist) # Convert it to support GPUs and avoid type instabilities for OrdinaryDiffEq.jl
218+
219+
# Check if the list of times is not empty
220+
isempty(tlist) && throw(ArgumentError("The list of times must not be empty."))
221+
# Check if the list of times is sorted
222+
!issorted(tlist) && throw(ArgumentError("The list of times must be sorted."))
223+
# Check if the list of times is unique
224+
length(tlist) != length(unique(tlist)) && throw(ArgumentError("The list of times must be unique."))
225+
226+
return tlist
227+
end
228+
215229
#######################################
216230

217231
function liouvillian_floquet(

0 commit comments

Comments
 (0)