Skip to content

Commit 29ffd99

Browse files
committed
add equations
1 parent e6ebcb9 commit 29ffd99

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/systems/jumps/jumpsystem.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,19 @@ function JumpSystem(eqs, iv, unknowns, ps;
194194
# this and the treatment of continuous events are the only part
195195
# unique to JumpSystems
196196
eqs = scalarize.(eqs)
197-
ap = ArrayPartition(MassActionJump[], ConstantRateJump[], VariableRateJump[])
197+
ap = ArrayPartition(
198+
MassActionJump[], ConstantRateJump[], VariableRateJump[], Equation[])
198199
for eq in eqs
199200
if eq isa MassActionJump
200201
push!(ap.x[1], eq)
201202
elseif eq isa ConstantRateJump
202203
push!(ap.x[2], eq)
203204
elseif eq isa VariableRateJump
204205
push!(ap.x[3], eq)
206+
elseif eq isa Equation
207+
push!(ap.x[4], eq)
205208
else
206-
error("JumpSystem equations must contain MassActionJumps, ConstantRateJumps, or VariableRateJumps.")
209+
error("JumpSystem equations must contain MassActionJumps, ConstantRateJumps, VariableRateJumps, or Equations.")
207210
end
208211
end
209212

@@ -245,6 +248,7 @@ end
245248
has_massactionjumps(js::JumpSystem) = !isempty(equations(js).x[1])
246249
has_constantratejumps(js::JumpSystem) = !isempty(equations(js).x[2])
247250
has_variableratejumps(js::JumpSystem) = !isempty(equations(js).x[3])
251+
has_equations(js::JumpSystem) = !isempty(equations(js).x[4])
248252

249253
function generate_rate_function(js::JumpSystem, rate)
250254
consts = collect_constants(rate)
@@ -390,6 +394,11 @@ function DiffEqBase.DiscreteProblem(sys::JumpSystem, u0map, tspan::Union{Tuple,
390394
if !iscomplete(sys)
391395
error("A completed `JumpSystem` is required. Call `complete` or `structural_simplify` on the system before creating a `DiscreteProblem`")
392396
end
397+
398+
if has_equations(sys)
399+
error("The passed in JumpSystem contains `Equations`, please use a problem type that supports equations such as such as ODEProblem.")
400+
end
401+
393402
_, u0, p = process_SciMLProblem(EmptySciMLFunction, sys, u0map, parammap;
394403
t = tspan === nothing ? nothing : tspan[1], use_union, tofloat = false, check_length = false)
395404
f = DiffEqBase.DISCRETE_INPLACE_DEFAULT

0 commit comments

Comments
 (0)