Skip to content

Commit 4cf12d2

Browse files
committed
updated for DiffEqJump PR changes
1 parent 796cdaf commit 4cf12d2

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/systems/jumps/jumpsystem.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ function numericnstoich(mtrs::Vector{Pair{V,W}}, statetoid) where {V,W}
186186
end
187187

188188
# assemble a numeric MassActionJump from a MT symbolics MassActionJumps
189-
function assemble_maj(majv::Vector{U}, statetoid, pmapper, params) where {U <: MassActionJump}
189+
function assemble_maj(majv::Vector{U}, statetoid, pmapper) where {U <: MassActionJump}
190190
rs = [numericrstoich(maj.reactant_stoch, statetoid) for maj in majv]
191191
ns = [numericnstoich(maj.net_stoch, statetoid) for maj in majv]
192-
MassActionJump(rs, ns; param_mapper = pmapper, params=params, scale_rates=false, nocopy=true)
192+
MassActionJump(rs, ns; param_mapper=pmapper, nocopy=true)
193193
end
194194

195195
"""
@@ -278,7 +278,7 @@ function DiffEqJump.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
278278
p = (prob.p isa DiffEqBase.NullParameters || prob.p === nothing) ? Num[] : prob.p
279279

280280
majpmapper = JumpSysMajParamMapper(js, p; jseqs=eqs, rateconsttype=invttype)
281-
majs = isempty(eqs.x[1]) ? nothing : assemble_maj(eqs.x[1], statetoid, majpmapper, p)
281+
majs = isempty(eqs.x[1]) ? nothing : assemble_maj(eqs.x[1], statetoid, majpmapper)
282282
crjs = ConstantRateJump[assemble_crj(js, j, statetoid) for j in eqs.x[2]]
283283
vrjs = VariableRateJump[assemble_vrj(js, j, statetoid) for j in eqs.x[3]]
284284
((prob isa DiscreteProblem) && !isempty(vrjs)) && error("Use continuous problems such as an ODEProblem or a SDEProblem with VariableRateJumps")
@@ -294,7 +294,8 @@ function DiffEqJump.JumpProblem(js::JumpSystem, prob, aggregator; kwargs...)
294294
vtoj = nothing; jtov = nothing; jtoj = nothing
295295
end
296296

297-
JumpProblem(prob, aggregator, jset; dep_graph=jtoj, vartojumps_map=vtoj, jumptovars_map=jtov, kwargs...)
297+
JumpProblem(prob, aggregator, jset; dep_graph=jtoj, vartojumps_map=vtoj, jumptovars_map=jtov,
298+
scale_rates=false, nocopy=true, kwargs...)
298299
end
299300

300301

@@ -349,8 +350,14 @@ function updateparams!(ratemap::JumpSysMajParamMapper{U,V,W}, params) where {U <
349350
sympar = ratemap.sympars[i]
350351
ratemap.subdict[sympar] = p
351352
end
353+
nothing
352354
end
353355

356+
function updateparams!(::JumpSysMajParamMapper{U,V,W}, params::Nothing) where {U <: AbstractArray, V <: AbstractArray, W}
357+
nothing
358+
end
359+
360+
354361
# create the initial parameter vector for use in a MassActionJump
355362
function (ratemap::JumpSysMajParamMapper{U,V,W})(params) where {U <: AbstractArray, V <: AbstractArray, W}
356363
updateparams!(ratemap, params)

test/reactionsystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ jumps[20] = VariableRateJump((u,p,t) -> p[20]*t*u[1]*binomial(u[2],2)*u[3], inte
193193

194194
statetoid = Dict(state => i for (i,state) in enumerate(states(js)))
195195
jspmapper = ModelingToolkit.JumpSysMajParamMapper(js, pars)
196-
maj = MT.assemble_maj(equations(js).x[1], statetoid, jspmapper, pars)
196+
symmaj = MT.assemble_maj(equations(js).x[1], statetoid, jspmapper)
197+
maj = MassActionJump(symmaj.param_mapper(pars), symmaj.reactant_stoch, symmaj.net_stoch, symmaj.param_mapper, scale_rates=false)
197198
for i in midxs
198199
@test abs(jumps[i].scaled_rates - maj.scaled_rates[i]) < 100*eps()
199200
@test jumps[i].reactant_stoch == maj.reactant_stoch[i]

0 commit comments

Comments
 (0)