108
108
109
109
# this doesn't work with constraint equations currently
110
110
function assemble_diffusion (rs, sts, ispcs; combinatoric_ratelaws = true ,
111
- remove_conserved = false )
111
+ remove_conserved = false , expand_catalyst_funs = true )
112
112
# as BC species should ultimately get an equation, we include them in the noise matrix
113
113
num_bcsts = count (isbc, get_unknowns (rs))
114
114
@@ -124,7 +124,9 @@ function assemble_diffusion(rs, sts, ispcs; combinatoric_ratelaws = true,
124
124
end
125
125
126
126
for (j, rx) in enumerate (get_rxs (rs))
127
- rlsqrt = sqrt (abs (oderatelaw (rx; combinatoric_ratelaw = combinatoric_ratelaws)))
127
+ rl = oderatelaw (rx; combinatoric_ratelaw = combinatoric_ratelaws,
128
+ expand_catalyst_funs)
129
+ rlsqrt = sqrt (abs (rl))
128
130
hasnoisescaling (rx) && (rlsqrt *= getnoisescaling (rx))
129
131
remove_conserved && (rlsqrt = substitute (rlsqrt, depspec_submap))
130
132
@@ -173,9 +175,12 @@ Notes:
173
175
the ratelaw is `k*S*(S-1)`, i.e. the rate law is not normalized by the scaling
174
176
factor.
175
177
"""
176
- function jumpratelaw (rx; combinatoric_ratelaw = true )
178
+ function jumpratelaw (rx; combinatoric_ratelaw = true , expand_catalyst_funs = true )
177
179
@unpack rate, substrates, substoich, only_use_rate = rx
180
+
178
181
rl = rate
182
+ expand_catalyst_funs && (rl = expand_registered_functions (rl))
183
+
179
184
if ! only_use_rate
180
185
coef = eltype (substoich) <: Number ? one (eltype (substoich)) : 1
181
186
for (i, stoich) in enumerate (substoich)
@@ -317,7 +322,7 @@ function get_depgraph(rs)
317
322
eqeq_dependencies (jdeps, vdeps). fadjlist
318
323
end
319
324
320
- function assemble_jumps (rs; combinatoric_ratelaws = true )
325
+ function assemble_jumps (rs; combinatoric_ratelaws = true , expand_catalyst_funs = true )
321
326
meqs = MassActionJump[]
322
327
ceqs = ConstantRateJump[]
323
328
veqs = VariableRateJump[]
@@ -365,7 +370,8 @@ function assemble_jumps(rs; combinatoric_ratelaws = true)
365
370
if (! isvrj) && ismassaction (rx, rs; rxvars, haveivdep = false , unknownset)
366
371
push! (meqs, makemajump (rx; combinatoric_ratelaw = combinatoric_ratelaws))
367
372
else
368
- rl = jumpratelaw (rx; combinatoric_ratelaw = combinatoric_ratelaws)
373
+ rl = jumpratelaw (rx; combinatoric_ratelaw = combinatoric_ratelaws,
374
+ expand_catalyst_funs)
369
375
affect = Vector {Equation} ()
370
376
for (spec, stoich) in rx. netstoich
371
377
# don't change species that are constant or BCs
@@ -569,7 +575,7 @@ function Base.convert(::Type{<:NonlinearSystem}, rs::ReactionSystem; name = name
569
575
remove_conserved && conservationlaws (fullrs)
570
576
ists, ispcs = get_indep_sts (fullrs, remove_conserved)
571
577
eqs = assemble_drift (fullrs, ispcs; combinatoric_ratelaws, remove_conserved,
572
- as_odes = false , include_zero_odes = false )
578
+ as_odes = false , include_zero_odes = false , expand_catalyst_funs )
573
579
eqs, us, ps, obs, defs, initeqs = addconstraints! (eqs, fullrs, ists, ispcs;
574
580
remove_conserved, treat_conserved_as_eqs = true )
575
581
@@ -648,9 +654,9 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
648
654
remove_conserved && conservationlaws (flatrs)
649
655
ists, ispcs = get_indep_sts (flatrs, remove_conserved)
650
656
eqs = assemble_drift (flatrs, ispcs; combinatoric_ratelaws, include_zero_odes,
651
- remove_conserved)
652
- noiseeqs = assemble_diffusion (flatrs, ists, ispcs;
653
- combinatoric_ratelaws, remove_conserved )
657
+ remove_conserved, expand_catalyst_funs )
658
+ noiseeqs = assemble_diffusion (flatrs, ists, ispcs; combinatoric_ratelaws,
659
+ remove_conserved, expand_catalyst_funs )
654
660
eqs, us, ps, obs, defs = addconstraints! (eqs, flatrs, ists, ispcs; remove_conserved)
655
661
656
662
if any (isbc, get_unknowns (flatrs))
@@ -701,7 +707,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
701
707
(length (MT. continuous_events (flatrs)) > 0 ) &&
702
708
(@warn " continuous_events will be dropped as they are not currently supported by JumpSystems." )
703
709
704
- eqs = assemble_jumps (flatrs; combinatoric_ratelaws)
710
+ eqs = assemble_jumps (flatrs; combinatoric_ratelaws, expand_catalyst_funs )
705
711
706
712
# handle BC species
707
713
sts, ispcs = get_indep_sts (flatrs)
0 commit comments