Skip to content

Commit 4cd280f

Browse files
committed
other sys types
1 parent ac489ba commit 4cd280f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/reactionsystem_conversions.jl

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ end
108108

109109
# this doesn't work with constraint equations currently
110110
function assemble_diffusion(rs, sts, ispcs; combinatoric_ratelaws = true,
111-
remove_conserved = false)
111+
remove_conserved = false, expand_catalyst_funs = true)
112112
# as BC species should ultimately get an equation, we include them in the noise matrix
113113
num_bcsts = count(isbc, get_unknowns(rs))
114114

@@ -124,7 +124,9 @@ function assemble_diffusion(rs, sts, ispcs; combinatoric_ratelaws = true,
124124
end
125125

126126
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))
128130
hasnoisescaling(rx) && (rlsqrt *= getnoisescaling(rx))
129131
remove_conserved && (rlsqrt = substitute(rlsqrt, depspec_submap))
130132

@@ -173,9 +175,12 @@ Notes:
173175
the ratelaw is `k*S*(S-1)`, i.e. the rate law is not normalized by the scaling
174176
factor.
175177
"""
176-
function jumpratelaw(rx; combinatoric_ratelaw = true)
178+
function jumpratelaw(rx; combinatoric_ratelaw = true, expand_catalyst_funs = true)
177179
@unpack rate, substrates, substoich, only_use_rate = rx
180+
178181
rl = rate
182+
expand_catalyst_funs && (rl = expand_registered_functions(rl))
183+
179184
if !only_use_rate
180185
coef = eltype(substoich) <: Number ? one(eltype(substoich)) : 1
181186
for (i, stoich) in enumerate(substoich)
@@ -317,7 +322,7 @@ function get_depgraph(rs)
317322
eqeq_dependencies(jdeps, vdeps).fadjlist
318323
end
319324

320-
function assemble_jumps(rs; combinatoric_ratelaws = true)
325+
function assemble_jumps(rs; combinatoric_ratelaws = true, expand_catalyst_funs = true)
321326
meqs = MassActionJump[]
322327
ceqs = ConstantRateJump[]
323328
veqs = VariableRateJump[]
@@ -365,7 +370,8 @@ function assemble_jumps(rs; combinatoric_ratelaws = true)
365370
if (!isvrj) && ismassaction(rx, rs; rxvars, haveivdep = false, unknownset)
366371
push!(meqs, makemajump(rx; combinatoric_ratelaw = combinatoric_ratelaws))
367372
else
368-
rl = jumpratelaw(rx; combinatoric_ratelaw = combinatoric_ratelaws)
373+
rl = jumpratelaw(rx; combinatoric_ratelaw = combinatoric_ratelaws,
374+
expand_catalyst_funs)
369375
affect = Vector{Equation}()
370376
for (spec, stoich) in rx.netstoich
371377
# don't change species that are constant or BCs
@@ -569,7 +575,7 @@ function Base.convert(::Type{<:NonlinearSystem}, rs::ReactionSystem; name = name
569575
remove_conserved && conservationlaws(fullrs)
570576
ists, ispcs = get_indep_sts(fullrs, remove_conserved)
571577
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)
573579
eqs, us, ps, obs, defs, initeqs = addconstraints!(eqs, fullrs, ists, ispcs;
574580
remove_conserved, treat_conserved_as_eqs = true)
575581

@@ -648,9 +654,9 @@ function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
648654
remove_conserved && conservationlaws(flatrs)
649655
ists, ispcs = get_indep_sts(flatrs, remove_conserved)
650656
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)
654660
eqs, us, ps, obs, defs = addconstraints!(eqs, flatrs, ists, ispcs; remove_conserved)
655661

656662
if any(isbc, get_unknowns(flatrs))
@@ -701,7 +707,7 @@ function Base.convert(::Type{<:JumpSystem}, rs::ReactionSystem; name = nameof(rs
701707
(length(MT.continuous_events(flatrs)) > 0) &&
702708
(@warn "continuous_events will be dropped as they are not currently supported by JumpSystems.")
703709

704-
eqs = assemble_jumps(flatrs; combinatoric_ratelaws)
710+
eqs = assemble_jumps(flatrs; combinatoric_ratelaws, expand_catalyst_funs)
705711

706712
# handle BC species
707713
sts, ispcs = get_indep_sts(flatrs)

0 commit comments

Comments
 (0)