Skip to content

Commit de6e60e

Browse files
Fix errors on SDEProblems
1 parent 766123c commit de6e60e

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ OrdinaryDiffEqTsit5 = "1"
6161
Pkg = "1"
6262
Random = "1"
6363
SciMLBase = "2"
64-
SciMLOperators = "0.3, 0.4, 1"
64+
SciMLOperators = "1"
6565
SparseArrays = "1"
6666
SpecialFunctions = "2"
6767
StaticArraysCore = "1"

src/QuantumToolbox.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import SciMLBase:
1616
u_modified!,
1717
NullParameters,
1818
ODEFunction,
19+
SDEFunction,
1920
ODEProblem,
2021
SDEProblem,
2122
EnsembleProblem,

src/time_evolution/time_evolution.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -395,37 +395,37 @@ end
395395
396396
A struct to represent the diffusion operator. This is used to perform the diffusion process on N different Wiener processes.
397397
=#
398-
struct DiffusionOperator{T,OpType<:Tuple{Vararg{AbstractSciMLOperator}}} <: AbstractSciMLOperator{T}
398+
struct DiffusionOperator{T,OpType<:Tuple{Vararg{AbstractSciMLOperator}}}
399399
ops::OpType
400400
function DiffusionOperator(ops::OpType) where {OpType}
401401
T = mapreduce(eltype, promote_type, ops)
402402
return new{T,OpType}(ops)
403403
end
404404
end
405405

406-
@generated function update_coefficients!(L::DiffusionOperator, u, p, t)
406+
@generated function (L::DiffusionOperator)(w, v, p, t)
407407
ops_types = L.parameters[2].parameters
408408
N = length(ops_types)
409-
return quote
409+
quote
410+
M = length(v)
411+
S = (size(w, 1), size(w, 2)) # This supports also `w` as a `Vector`
412+
(S[1] == M && S[2] == $N) || throw(DimensionMismatch("The size of the output vector is incorrect."))
410413
Base.@nexprs $N i -> begin
411-
update_coefficients!(L.ops[i], u, p, t)
414+
# update_coefficients!(L.ops[i], v, p, t)
415+
# mul!(@view(w[:, i]), L.ops[i], v)
416+
op = L.ops[i]
417+
op(@view(w[:, i]), v, v, p, t)
412418
end
413-
414-
nothing
419+
return w
415420
end
416421
end
417422

418-
@generated function LinearAlgebra.mul!(v::AbstractVecOrMat, L::DiffusionOperator, u::AbstractVecOrMat)
419-
ops_types = L.parameters[2].parameters
420-
N = length(ops_types)
421-
quote
422-
M = length(u)
423-
S = (size(v, 1), size(v, 2)) # This supports also `v` as a `Vector`
424-
(S[1] == M && S[2] == $N) || throw(DimensionMismatch("The size of the output vector is incorrect."))
425-
Base.@nexprs $N i -> begin
426-
mul!(@view(v[:, i]), L.ops[i], u)
427-
end
428-
return v
423+
#TODO: Remove when https://github.com/SciML/StochasticDiffEq.jl/issues/615 is fixed.
424+
function (f::SDEFunction)(du, u, p, t)
425+
if f.f isa AbstractSciMLOperator
426+
f.f(du, u, u, p, t)
427+
else
428+
f.f(du, u, p, t)
429429
end
430430
end
431431

test/core-test/time_evolution.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ end
484484
H = TESetup.H
485485
ψ0 = TESetup.ψ0
486486
tlist = TESetup.tlist
487-
c_ops = TESetup.c_ops
488487
c_ops_sme = TESetup.c_ops_sme
489488
sc_ops_sme = TESetup.sc_ops_sme
490489
c_ops_sme2 = TESetup.c_ops_sme2

0 commit comments

Comments
 (0)