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
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,...].
error("Incorrect number of parameters specified.")
732
+
end
733
+
734
+
pmap =symmap_to_varmap(rs, parametermap)
735
+
pmap =Dict(ModelingToolkit.value(k) => v for (k,v) in pmap)
736
+
737
+
sm =speciesmap(rs)
738
+
cm =reactioncomplexmap(rs)
739
+
complexes, D =reactioncomplexes(rs)
740
+
rxns =reactions(rs)
741
+
nc =length(complexes); nr =numreactions(rs); nm =numspecies(rs)
742
+
743
+
if!all(r->ismassaction(r, rs), rxns)
744
+
error("The supplied ReactionSystem has reactions that are not ismassaction. Testing for being complex balanced is currently only supported for pure mass action networks.")
745
+
end
746
+
747
+
rates = [substitute(rate, pmap) for rate inreactionrates(rs)]
748
+
749
+
# Construct kinetic matrix, K
750
+
K =zeros(nr, nc)
751
+
for c in1:nc
752
+
complex = complexes[c]
753
+
for (r, dir) in cm[complex]
754
+
rxn = rxns[r]
755
+
if dir ==-1
756
+
K[r, c] = rates[r]
757
+
end
758
+
end
759
+
end
760
+
761
+
L =-D*K
762
+
S =netstoichmat(rs)
763
+
764
+
# Compute ρ using the matrix-tree theorem
765
+
g =incidencematgraph(rs)
766
+
R =ratematrix(rs, rates)
767
+
ρ =matrixtree(g, R)
768
+
769
+
# Determine if 1) ρ is positive and 2) D^T Ln ρ lies in the image of S^T
0 commit comments