You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Constructively compute whether a network will have complex-balanced equilibrium
1663
-
solutions, following the method in [this paper](https://link.springer.com/article/10.1007/s10910-015-0498-2#Sec3). Accepts a map of rates [k1 => 1.0, k2 => 2.0,...]k2
1663
+
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,...].
error("Incorrect number of parameters specified.")
1669
1669
end
1670
1670
1671
+
pmap =symmap_to_varmap(rs, parametermap)
1672
+
pmap =Dict(ModelingToolkit.value(k) => v for (k,v) in pmap)
1673
+
1671
1674
sm =speciesmap(rs)
1672
1675
cm =reactioncomplexmap(rs)
1673
1676
complexes, D =reactioncomplexes(rs)
@@ -1678,14 +1681,16 @@ function iscomplexbalanced(rs::ReactionSystem, rates::Dict{Any, Float64})
1678
1681
error("The supplied ReactionSystem has reactions that are not ismassaction. Testing for being complex balanced is currently only supported for pure mass action networks.")
1679
1682
end
1680
1683
1684
+
rates = [substitute(rate, pmap) for rate inreactionrates(rs)]
1685
+
1681
1686
# Construct kinetic matrix, K
1682
1687
K =zeros(nr, nc)
1683
1688
for c in1:nc
1684
1689
complex = complexes[c]
1685
1690
for (r, dir) in cm[complex]
1686
1691
rxn = rxns[r]
1687
1692
if dir ==-1
1688
-
K[r, c] = rates[rxn.rate]
1693
+
K[r, c] = rates[r]
1689
1694
end
1690
1695
end
1691
1696
end
@@ -1697,22 +1702,36 @@ function iscomplexbalanced(rs::ReactionSystem, rates::Dict{Any, Float64})
1697
1702
g =incidencematgraph(rs)
1698
1703
R =ratematrix(rs, rates)
1699
1704
ρ =matrixtree(g, R)
1700
-
@assertisapprox(L*ρ, zeros(nc), atol=1e-12)
1701
1705
1702
1706
# Determine if 1) ρ is positive and 2) D^T Ln ρ lies in the image of S^T
0 commit comments