Skip to content

Commit 7426126

Browse files
committed
- Mass action jumps should now also be created properly.
1 parent 2d6d4c3 commit 7426126

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/systems/reaction/reactionsystem.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,16 @@ function assemble_jumps(rs)
131131
push!(affect,var2op(spec) ~ var2op(spec) + stoich)
132132
end
133133
if any(isequal.(var2op(rs.iv),get_variables(rx.rate)))
134+
println("Var Jump")
134135
push!(eqs,VariableRateJump(rl,affect))
135136
elseif any([isequal(state,r_op) for state in rs.states, r_op in getfield.(get_variables(rx.rate),:op)])
137+
println("Const")
136138
push!(eqs,ConstantRateJump(rl,affect))
137139
else
138-
push!(eqs,ConstantRateJump(rl,affect))
140+
reactant_stoch = Pair.(var2op.(getfield.(rx.substrates,:op)),rx.substoich)
141+
println("MA Jump")
142+
net_stoch = isempty(rx.substoich) ? [0 => 1] : map(p -> Pair(var2op(p[1]),p[2]),rx.netstoich)
143+
push!(eqs,MassActionJump(rx.rate, reactant_stoch, net_stoch))
139144
end
140145
end
141146
eqs
@@ -145,7 +150,8 @@ end
145150
# The former geenrates a "MethodError: objects of type Int64 are not callable" when trying to solve the problem.
146151
function jumpratelaw(rx)
147152
@unpack rate, substrates, substoich, only_use_rate = rx
148-
rl = rate
153+
rl = deepcopy(rate)
154+
foreach(op -> substitute_expr!(rl,op=>var2op(op.op)), get_variables(rx.rate))
149155
if !only_use_rate
150156
coef = one(eltype(substoich))
151157
for (i,stoich) in enumerate(substoich)

0 commit comments

Comments
 (0)