Skip to content

Commit 139c4be

Browse files
committed
fixes SDE
1 parent 30dc99a commit 139c4be

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/build_function.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ function _build_function(target::JuliaTarget, rhss::AbstractArray, args...;
224224
skipzeros = outputidxs===nothing,
225225
fillzeros = skipzeros && !(typeof(rhss)<:SparseMatrixCSC),
226226
parallel=SerialForm(), kwargs...)
227-
conv = conv rm_calls_with_iv
228227
if multithread isa Bool
229228
@warn("multithraded is deprecated for the parallel argument. See the documentation.")
230229
parallel = multithread ? MultithreadedForm() : SerialForm()
@@ -524,6 +523,7 @@ function _build_function(target::CTarget, eqs::Array{<:Equation}, args...;
524523
fname = :diffeqf,
525524
lhsname=:du,rhsnames=[Symbol("RHS$i") for i in 1:length(args)],
526525
libpath=tempname(),compiler=:gcc)
526+
527527
differential_equation = string(join([numbered_expr(eq,args...,lhsname=lhsname,
528528
rhsnames=rhsnames,offset=-1) for
529529
(i, eq) enumerate(eqs)],";\n "),";")

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ struct ODEToExpr
3838
states::Vector
3939
end
4040
ODEToExpr(@nospecialize(sys)) = ODEToExpr(sys,states(sys))
41-
function (f::ODEToExpr)(O::Operation)
41+
(f::ODEToExpr)(O::Num) = f(value(O))
42+
function (f::ODEToExpr)(O::Term)
4243
if isa(O.op, Sym)
43-
isequal(O.op, f.sys.iv) && return O.op.name # independent variable
44-
O.op f.states && return O.op.name # dependent variables
45-
isempty(O.args) && return O.op.name # 0-ary parameters
44+
any(isequal(O), f.states) && return O.op.name # dependent variables
4645
return build_expr(:call, Any[O.op.name; f.(O.args)])
4746
end
4847
return build_expr(:call, Any[Symbol(O.op); f.(O.args)])

src/systems/diffeqs/modelingtoolkitize.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function modelingtoolkitize(prob::DiffEqBase.ODEProblem)
88
return (prob.f.sys, prob.f.sys.states, prob.f.sys.ps)
99
@parameters t
1010
var(x, i) = Sym{FnType{Tuple{symtype(t)}, Number}}(nameof(Variable(:x, i)))
11-
vars = reshape([var(:x, i)(t) for i in eachindex(prob.u0)],size(prob.u0))
11+
vars = reshape([var(:x, i)(value(t)) for i in eachindex(prob.u0)],size(prob.u0))
1212
params = prob.p isa DiffEqBase.NullParameters ? [] :
1313
reshape([Variable(,i) for i in eachindex(prob.p)],size(prob.p))
1414
@derivatives D'~t
@@ -40,7 +40,7 @@ function modelingtoolkitize(prob::DiffEqBase.SDEProblem)
4040
return (prob.f.sys, prob.f.sys.states, prob.f.sys.ps)
4141
@parameters t
4242
var(x, i) = Sym{FnType{Tuple{symtype(t)}, Number}}(nameof(Variable(:x, i)))
43-
vars = reshape([var(:x, i)(t) for i in eachindex(prob.u0)],size(prob.u0))
43+
vars = reshape([var(:x, i)(value(t)) for i in eachindex(prob.u0)],size(prob.u0))
4444
params = prob.p isa DiffEqBase.NullParameters ? [] :
4545
reshape([Variable(,i) for i in eachindex(prob.p)],size(prob.p))
4646
@derivatives D'~t

0 commit comments

Comments
 (0)