Skip to content

Commit a2a9e4d

Browse files
committed
minor fixes
1 parent f9beabc commit a2a9e4d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/network_analysis.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ function conservationlaw_errorcheck(rs, pre_varmap)
738738
end
739739

740740
"""
741-
iscomplexbalanced(rs::ReactionSystem, parametermap)
741+
isdetailedbalanced(rs::ReactionSystem, parametermap)
742742
743743
Constructively compute whether a kinetic system (a reaction network with a set of rate constants) will admit detailed-balanced equilibrium
744744
solutions, using the Wegscheider conditions, [Feinberg, 1989](https://www.sciencedirect.com/science/article/pii/0009250989851243). A detailed-balanced solution is one for which the rate of every forward reaction exactly equals its reverse reaction. Accepts a dictionary, vector, or tuple of variable-to-value mappings, e.g. [k1 => 1.0, k2 => 2.0,...].
@@ -782,7 +782,6 @@ function isdetailedbalanced(rs::ReactionSystem, parametermap::Dict)
782782
rxn_idxs = [edgeindex(D, Graphs.src(e), Graphs.dst(e)) for e in spanning_forest]
783783
S_F = netstoichmat(rs)[:, rxn_idxs]
784784
sols = nullspace(S_F)
785-
@assert size(sols, 2) == deficiency(rs)
786785

787786
for i in 1:size(sols, 2)
788787
α = sols[:, i]
@@ -797,19 +796,20 @@ function isdetailedbalanced(rs::ReactionSystem, parametermap::Dict)
797796
true
798797
end
799798

800-
function edgeindex(imat::Matrix{Int64}, src::Int64, dst::Int64)
799+
# Helper to find the index of the reaction with a given reactnat and product complex.
800+
function edgeindex(imat, src::T, dst::T) where T <: Int
801801
for i in 1:size(imat, 2)
802802
(imat[src, i] == -1) && (imat[dst, i] == 1) && return i
803803
end
804804
error("This edge does not exist in this reaction graph.")
805805
end
806806

807-
function isdetailedbalanced(rs::ReactionSystem, parametermap::Vector{Pair{Symbol, Float64}})
807+
function isdetailedbalanced(rs::ReactionSystem, parametermap::Vector{<:Pair})
808808
pdict = Dict(parametermap)
809809
isdetailedbalanced(rs, pdict)
810810
end
811811

812-
function isdetailedbalanced(rs::ReactionSystem, parametermap::Tuple{Pair{Symbol, Float64}})
812+
function isdetailedbalanced(rs::ReactionSystem, parametermap::Tuple{<:Pair})
813813
pdict = Dict(parametermap)
814814
isdetailedbalanced(rs, pdict)
815815
end

0 commit comments

Comments
 (0)