@@ -398,10 +398,13 @@ def backwards(self, reactant=None, X=None, rate=None):
398398 new ._rescale ()
399399 return new
400400
401- @property
401+ def reaction_indices (self ):
402+ """Return all chemical indices involved in the reaction."""
403+ return self .stoichiometry .nonzero_keys ()
404+
402405 def reaction_chemicals (self ):
403406 """Return all chemicals involved in the reaction."""
404- keys = sorted (self ._stoichiometry . nonzero_keys ())
407+ keys = sorted (self .reaction_indices ())
405408 chemicals = self .chemicals
406409 return [chemicals [i ] for i in keys ]
407410
@@ -1297,6 +1300,12 @@ def __init__(self, reactions):
12971300 reactant_index = [i ._reactant_index for i in reactions ]
12981301 self ._reactant_index = tuple (reactant_index ) if self ._phases else np .array (reactant_index )
12991302
1303+ def reaction_indices (self ):
1304+ """Return all chemical indices involved in the reaction."""
1305+ keys = []
1306+ for i in self ._stoichiometry : keys .extend (i .set )
1307+ return set (keys )
1308+
13001309 def equilibrium (self , material , T , P , phase ):
13011310 raise NotImplementedError ('equilibrium of reaction sets not implemented in BioSTEAM (yet)' )
13021311
@@ -1778,9 +1787,16 @@ def __init__(self, *reactions, basis=None):
17781787
17791788 force_reaction = Reaction .force_reaction
17801789 adiabatic_reaction = Reaction .adiabatic_reaction
1790+ reaction_chemicals = Reaction .reaction_chemicals
17811791 __call__ = Reaction .__call__
17821792 show = Reaction .show
17831793
1794+ def reaction_indices (self ):
1795+ """Return all chemical indices involved in the reaction."""
1796+ keys = []
1797+ for i in self ._reactions : keys .extend (i .reaction_indices )
1798+ return set (keys )
1799+
17841800 def equilibrium (self , material , T , P , phase ):
17851801 raise NotImplementedError ('equilibrium of reaction systems not implemented in BioSTEAM (yet)' )
17861802
0 commit comments