Skip to content

Commit 5bbda08

Browse files
committed
pass syms to DiscreteProblem for plotting
1 parent a81446e commit 5bbda08

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

src/systems/jumps/jumpsystem.jl

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ Generates a DiscreteProblem from an AbstractSystem
9797
function DiffEqBase.DiscreteProblem(sys::AbstractSystem, u0map, tspan::Tuple,
9898
parammap=DiffEqBase.NullParameters(); kwargs...)
9999
u0 = varmap_to_vars(u0map, states(sys))
100-
p = varmap_to_vars(parammap, parameters(sys))
101-
DiscreteProblem(u0, tspan, p; kwargs...)
100+
p = varmap_to_vars(parammap, parameters(sys))
101+
f = (du,u,p,t) -> du.=u # identity function to make syms works
102+
df = DiscreteFunction(f, syms=Symbol.(states(sys)))
103+
DiscreteProblem(df, u0, tspan, p; kwargs...)
102104
end
103105

104106
"""
@@ -115,18 +117,12 @@ function DiffEqJump.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
115117
pvars = parameters(js)
116118
statetoid = Dict(convert(Variable,state) => i for (i,state) in enumerate(states(js)))
117119
parammap = map((x,y)->Pair(x(),y),pvars,prob.p)
120+
eqs = equations(js)
121+
122+
foreach(j -> push!(majs, assemble_maj(js, j, statetoid, parammap)), eqs.x[1])
123+
foreach(j -> push!(crjs, assemble_crj(js, j, statetoid)), eqs.x[2])
124+
foreach(j -> push!(vrjs, assemble_vrj(js, j, statetoid)), eqs.x[3])
118125

119-
for j in equations(js)
120-
if j isa ConstantRateJump
121-
push!(crjs, assemble_crj(js, j, statetoid))
122-
elseif j isa VariableRateJump
123-
push!(vrjs, assemble_vrj(js, j, statetoid))
124-
elseif j isa MassActionJump
125-
push!(majs, assemble_maj(js, j, statetoid, parammap))
126-
else
127-
error("JumpSystems should only contain Constant, Variable or Mass Action Jumps.")
128-
end
129-
end
130126
((prob isa DiscreteProblem) && !isempty(vrjs)) && error("Use continuous problems such as an ODEProblem or a SDEProblem with VariableRateJumps")
131127
jset = JumpSet(Tuple(vrjs), Tuple(crjs), nothing, isempty(majs) ? nothing : majs)
132128
JumpProblem(prob, aggregator, jset)

0 commit comments

Comments
 (0)