diff --git a/src/network_analysis.jl b/src/network_analysis.jl index 1ece746fa..8610b60c9 100644 --- a/src/network_analysis.jl +++ b/src/network_analysis.jl @@ -877,6 +877,7 @@ function cache_conservationlaw_eqs!(rn::ReactionSystem, N::AbstractMatrix, col_o nps.depspecs = Set(depspecs) nps.conservedeqs = conservedeqs nps.constantdefs = constantdefs + nps.conservedconst = constants nothing end diff --git a/src/reactionsystem.jl b/src/reactionsystem.jl index a2cd0ecf2..01be8f6e9 100644 --- a/src/reactionsystem.jl +++ b/src/reactionsystem.jl @@ -86,6 +86,7 @@ Base.@kwdef mutable struct NetworkProperties{I <: Integer, V <: BasicSymbolic{Re depspecs::Set{V} = Set{V}() conservedeqs::Vector{Equation} = Equation[] constantdefs::Vector{Equation} = Equation[] + conservedconst::BasicSymbolic{Real} = only(@parameters __UNINITIALIZED) speciesmap::Dict{V, Int} = Dict{V, Int}() complextorxsmap::OrderedDict{ReactionComplex{Int}, Vector{Pair{Int, Int}}} = OrderedDict{ReactionComplex{Int},Vector{Pair{Int,Int}}}() complexes::Vector{ReactionComplex{Int}} = Vector{ReactionComplex{Int}}(undef, 0) @@ -126,6 +127,7 @@ function reset!(nps::NetworkProperties{I, V}) where {I, V} empty!(nps.col_order) nps.rank = 0 nps.nullity = 0 + nps.conservedconst = only(@parameters __UNINITIALIZED) empty!(nps.indepspecs) empty!(nps.depspecs) empty!(nps.conservedeqs) diff --git a/src/reactionsystem_conversions.jl b/src/reactionsystem_conversions.jl index aa5a17fed..470e7e847 100644 --- a/src/reactionsystem_conversions.jl +++ b/src/reactionsystem_conversions.jl @@ -392,11 +392,8 @@ function addconstraints!(eqs, rs::ReactionSystem, ists, ispcs; remove_conserved nps = get_networkproperties(rs) # add the conservation constants as parameters and set their values - ps = vcat(ps, collect(eq.lhs for eq in nps.constantdefs)) + ps = push!(ps, nps.conservedconst) defs = copy(MT.defaults(rs)) - # for eq in nps.constantdefs - # defs[eq.lhs] = eq.rhs - # end # add the dependent species as observed obs = copy(MT.observed(rs))