ParallelReaction#

class ParallelReaction(reactions)[source]#

Create a ParallelReaction object from Reaction objects. When called, it returns the change in material due to all parallel reactions.

Parameters:

reactions (Iterable[Reaction])

Examples

Run two reactions in parallel:

>>> import thermosteam as tmo
>>> chemicals = tmo.Chemicals(['H2', 'Ethanol', 'CH4', 'O2', 'CO2', 'H2O'], cache=True)
>>> tmo.settings.set_thermo(chemicals)
>>> kwargs = dict(phases='lg', correct_atomic_balance=True)
>>> reaction = tmo.ParallelReaction([
...    #            Reaction definition                    Reactant             Conversion
...    tmo.Reaction('H2,g + O2,g -> 2H2O,g',               reactant='H2',       X=0.7, **kwargs),
...    tmo.Reaction('Ethanol,l + O2,g -> CO2,g + 2H2O,g',  reactant='Ethanol',  X=0.1, **kwargs)
... ])
>>> reaction.reactants # Note that reactants are tuples of phase and ID pairs.
(('g', 'H2'), ('l', 'Ethanol'))
>>> reaction.show()
ParallelReaction (by mol):
index  stoichiometry                            reactant     X[%]
[0]    H2,g + 0.5 O2,g -> H2O,g                 H2,g        70.00
[1]    3 O2,g + Ethanol,l -> 2 CO2,g + 3 H2O,g  Ethanol,l   10.00
>>> s1 = tmo.MultiStream('s1', T=373.15,
...                      l=[('Ethanol', 10)],
...                      g=[('H2', 10), ('CH4', 5), ('O2', 100), ('H2O', 10)])
>>> s1.show() # Before reaction
MultiStream: s1
phases: ('g', 'l'), T: 373.15 K, P: 101325 Pa
flow (kmol/hr): (g) H2       10
                    CH4      5
                    O2       100
                    H2O      10
                (l) Ethanol  10
>>> reaction(s1)
>>> s1.show() # After isothermal reaction
MultiStream: s1
phases: ('g', 'l'), T: 373.15 K, P: 101325 Pa
flow (kmol/hr): (g) H2       3
                    CH4      5
                    O2       93.5
                    CO2      2
                    H2O      20
                (l) Ethanol  9

Reaction items are accessible:

>>> reaction[0].show()
ReactionItem (by mol):
stoichiometry             reactant    X[%]
H2,g + 0.5 O2,g -> H2O,g  H2,g       70.00

Note that changing the conversion of a reaction item changes the conversion of its parent reaction set:

>>> reaction[0].X = 0.5
>>> reaction.show()
ParallelReaction (by mol):
index  stoichiometry                            reactant     X[%]
[0]    H2,g + 0.5 O2,g -> H2O,g                 H2,g        50.00
[1]    3 O2,g + Ethanol,l -> 2 CO2,g + 3 H2O,g  Ethanol,l   10.00

Reactions subsets can be made as well:

>>> reaction[:1].show()
ParallelReaction (by mol):
index  stoichiometry             reactant    X[%]
[0]    H2,g + 0.5 O2,g -> H2O,g  H2,g       50.00

Get net reaction conversion of reactants as a material indexer:

>>> mi = reaction.X_net(indexer=True)
>>> mi.show()
MaterialIndexer:
 (g) H2        0.5
 (l) Ethanol   0.1
>>> mi['g', 'H2']
0.5

If no phases are specified for a reaction set, the X_net property returns a ChemicalIndexer:

>>> kwargs = dict(correct_atomic_balance=True)
>>> reaction = tmo.ParallelReaction([
...    #            Reaction definition            Reactant             Conversion
...    tmo.Reaction('H2 + O2 -> 2H2O',             reactant='H2',       X=0.7, **kwargs),
...    tmo.Reaction('Ethanol + O2 -> CO2 + 2H2O',  reactant='Ethanol',  X=0.1, **kwargs)
... ])
>>> ci = reaction.X_net(indexer=True)
>>> ci.show()
ChemicalIndexer:
 H2       0.7
 Ethanol  0.1
>>> ci['H2']
0.7
reduce()[source]#

Return a new Parallel reaction object that combines reaction with the same reactant together, reducing the number of reactions.

X_net(indexer=False)[source]#

Return net reaction conversion of reactants as a dictionary or a ChemicalIndexer if indexer is True.