Skip to content

Commit 64a25a5

Browse files
committed
updated ratematrix to take symbolics
1 parent b8d0201 commit 64a25a5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/network_analysis.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ end
723723
iscomplexbalanced(rs::ReactionSystem, parametermap)
724724
725725
Constructively compute whether a network will have complex-balanced equilibrium
726-
solutions, following the method in van der Schaft et al., [2015](https://link.springer.com/article/10.1007/s10910-015-0498-2#Sec3). Accepts a dictionary, vector, or tuple ofvariable-to-value mappings, e.g. [k1 => 1.0, k2 => 2.0,...].
726+
solutions, following the method in van der Schaft et al., [2015](https://link.springer.com/article/10.1007/s10910-015-0498-2#Sec3). Accepts a dictionary, vector, or tuple of variable-to-value mappings, e.g. [k1 => 1.0, k2 => 2.0,...].
727727
"""
728728

729729
function iscomplexbalanced(rs::ReactionSystem, parametermap::Dict)
@@ -791,7 +791,7 @@ iscomplexbalanced(rs::ReactionSystem, parametermap) = error("Parameter map must
791791
"""
792792
ratematrix(rs::ReactionSystem, parametermap)
793793
794-
Given a reaction system with n complexes, outputs an n-by-n matrix where R_{ij} is the rate constant of the reaction between complex i and complex j.
794+
Given a reaction system with n complexes, outputs an n-by-n matrix where R_{ij} is the rate constant of the reaction between complex i and complex j. Accepts a dictionary, vector, or tuple of variable-to-value mappings, e.g. [k1 => 1.0, k2 => 2.0,...].
795795
"""
796796

797797
function ratematrix(rs::ReactionSystem, rates::Vector{Float64})
@@ -809,11 +809,14 @@ function ratematrix(rs::ReactionSystem, rates::Vector{Float64})
809809
ratematrix
810810
end
811811

812-
function ratematrix(rs::ReactionSystem, parametermap::Dict{Symbol, Float64})
812+
function ratematrix(rs::ReactionSystem, parametermap::Dict)
813813
if length(parametermap) != numparams(rs)
814-
error("The number of reaction rates must be equal to the number of parameters")
814+
error("Incorrect number of parameters specified.")
815815
end
816+
816817
pmap = symmap_to_varmap(rs, parametermap)
818+
pmap = Dict(ModelingToolkit.value(k) => v for (k,v) in pmap)
819+
817820
rates = [substitute(rate, pmap) for rate in reactionrates(rs)]
818821
ratematrix(rs, rates)
819822
end

0 commit comments

Comments
 (0)