Skip to content

Commit

Permalink
equations are now supported, rather than throwing an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
TorkelE committed Nov 14, 2023
1 parent 3d8e791 commit f210093
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ function Catalyst.hc_steady_states(rs::ReactionSystem, ps; filter_negative=true,
end

# For a given reaction system, parameter values, and initial conditions, find the polynomial that HC solves to find steady states.
function steady_state_polynomial(rs_in::ReactionSystem, ps, u0)
any(!(eq isa Reaction) for eq in rs_in.eqs) && error("This feature is currently not supported for reaction systems containing (non-reaction) equations.")
rs = @set rs_in.rxs = [Catalyst.expand_registered_functions(rx) for rx in rs_in.rxs]
function steady_state_polynomial(rs::ReactionSystem, ps, u0)
rs = expand_registered_functions(rs)
ns = convert(NonlinearSystem, rs; remove_conserved = true)
pre_varmap = [symmap_to_varmap(rs,u0)..., symmap_to_varmap(rs,ps)...]
conservationlaw_errorcheck(rs, pre_varmap)
Expand Down
10 changes: 9 additions & 1 deletion src/registered_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ function expand_registered_functions(expr)
end
return expr
end
# If applied to a reaction, return a reaction with its rate modified.
# If applied to a Reaction, return a reaction with its rate modified.
function expand_registered_functions(rx::Reaction)
Reaction(expand_registered_functions(rx.rate), rx.substrates, rx.products, rx.substoich, rx.prodstoich, rx.netstoich, rx.only_use_rate)
end
# If applied to a Equation, returns it with it applied to lhs and rhs
function expand_registered_functions(eq::Equation)
return expand_registered_functions(eq.lhs) ~ expand_registered_functions(eq.rhs)
end
# If applied to a ReactionSystem, applied function to all Reactions and other Equations, and return updated system.
function expand_registered_functions(rs::ReactionSystem)
@set rs.eqs = [Catalyst.expand_registered_functions(eq) for eq in rs.eqs]
end

0 comments on commit f210093

Please sign in to comment.