@@ -96,11 +96,6 @@ struct JumpSystem{U <: ArrayPartition} <: AbstractTimeDependentSystem
9696 """
9797 discrete_events:: Vector{SymbolicDiscreteCallback}
9898 """
99- A `Vector{SymbolicContinuousCallback}` that model events.
100- The integrator will use root finding to guarantee that it steps at each zero crossing.
101- """
102- continuous_events:: Vector{SymbolicContinuousCallback}
103- """
10499 Topologically sorted parameter dependency equations, where all symbols are parameters and
105100 the LHS is a single parameter.
106101 """
@@ -172,13 +167,14 @@ function JumpSystem(eqs, iv, unknowns, ps;
172167 iv′ = value (iv)
173168 us′ = value .(unknowns)
174169 ps′ = value .(ps)
175- parameter_dependencies, ps = process_parameter_dependencies (parameter_dependencies, ps′)
170+ parameter_dependencies, ps′ = process_parameter_dependencies (
171+ parameter_dependencies, ps′)
176172 if ! (isempty (default_u0) && isempty (default_p))
177173 Base. depwarn (
178174 " `default_u0` and `default_p` are deprecated. Use `defaults` instead." ,
179175 :JumpSystem , force = true )
180176 end
181- defaults = todict (defaults)
177+ defaults = Dict {Any,Any} ( todict (defaults) )
182178 var_to_name = Dict ()
183179 process_variables! (var_to_name, defaults, us′)
184180 process_variables! (var_to_name, defaults, ps′)
@@ -188,7 +184,14 @@ function JumpSystem(eqs, iv, unknowns, ps;
188184 if value (v) != = nothing )
189185 isempty (observed) || collect_var_to_name! (var_to_name, (eq. lhs for eq in observed))
190186
187+ sysnames = nameof .(systems)
188+ if length (unique (sysnames)) != length (sysnames)
189+ throw (ArgumentError (" System names must be unique." ))
190+ end
191+
191192 # equation processing
193+ # this and the treatment of continuous events are the only part
194+ # unique to JumpSystems
192195 eqs = scalarize .(eqs)
193196 ap = ArrayPartition (MassActionJump[], ConstantRateJump[], VariableRateJump[])
194197 for eq in eqs
@@ -203,11 +206,6 @@ function JumpSystem(eqs, iv, unknowns, ps;
203206 end
204207 end
205208
206- sysnames = nameof .(systems)
207- if length (unique (sysnames)) != length (sysnames)
208- throw (ArgumentError (" System names must be unique." ))
209- end
210-
211209 (continuous_events === nothing ) ||
212210 error (" JumpSystems currently only support discrete events." )
213211 disc_callbacks = SymbolicDiscreteCallbacks (discrete_events)
@@ -220,17 +218,19 @@ end
220218
221219# #### MTK dispatches for JumpSystems #####
222220function collect_vars! (unknowns, parameters, j:: MassActionJump , iv; depth = 0 ,
223- op = Differential)
221+ op = Differential)
224222 for field in (j. scaled_rates, j. reactant_stoch, j. net_stoch)
225- collect_vars! (unknowns, parameters, field, iv; depth, op)
223+ for el in field
224+ collect_vars! (unknowns, parameters, el, iv; depth, op)
225+ end
226226 end
227227 return nothing
228228end
229229
230230function collect_vars! (unknowns, parameters, j:: Union{ConstantRateJump,VariableRateJump} ,
231231 iv; depth = 0 , op = Differential)
232- collect_vars! (unknowns, parameters, j. condition , iv; depth, op)
233- for eq in j. affect
232+ collect_vars! (unknowns, parameters, j. rate , iv; depth, op)
233+ for eq in j. affect!
234234 (eq isa Equation) && collect_vars! (unknowns, parameters, eq, iv; depth, op)
235235 end
236236 return nothing
0 commit comments