Reaction

class thermosteam.reaction.Reaction(reaction, reactant, X, chemicals=None, basis='mol', *, check_mass_balance=False, check_atomic_balance=False, correct_atomic_balance=False, correct_mass_balance=False)[source]

Create a Reaction object which defines a stoichiometric reaction and conversion. When called, it elements of a material array due to the reaction.

Parameters
  • reaction (dict or str) – A dictionary of stoichiometric coefficients or a stoichiometric equation written as: i1 R1 + … + in Rn -> j1 P1 + … + jm Pm

  • reactant (str) – ID of reactant compound.

  • X (float) – Reactant conversion (fraction).

  • chemicals=None (Chemicals, defaults to settings.chemicals.) – Chemicals corresponing to each entry in the stoichiometry array.

  • basis='mol' ({'mol', 'wt'}) – Basis of reaction.

Other Parameters
  • check_mass_balance=False (bool) – Whether to assert that mass is not created or destroyed.

  • correct_mass_balance=False (bool) – Whether to make sure mass is not created or destroyed by varying the reactant stoichiometric coefficient.

  • check_atomic_balance=False (bool) – Whether to assert that stoichiometric balance by atoms cancel out.

  • correct_atomic_balance=False (bool) – Whether to correct the stoichiometry according to the atomic balance.

Notes

A reaction object can react either a stream or an array. When a stream is passed, it reacts either the mol or mass flow rate according to the basis of the reaction object. When an array is passed, the array elements are reacted regardless of what basis they are associated with.

Examples

>>> import thermosteam as tmo
>>> import thermosteam.reaction as rxn
>>> chemicals = tmo.Chemicals(['H2O', 'H2', 'O2'])
>>> tmo.settings.set_thermo(chemicals)
>>> reaction = rxn.Reaction('2H2O -> 2H2 + O2', reactant='H2O', X=0.7)
>>> reaction.show() # Note that the default basis is by 'mol'
Reaction (by mol):
 stoichiometry       reactant    X[%]
 H2O -> H2 + 0.5 O2  H2O        70.00
>>> feed = tmo.Stream('feed', H2O=200)
>>> reaction(feed) # Call to run reaction on molar flow
>>> feed.show() # Notice how 70% of water was converted to product
Stream: feed
 phase: 'l', T: 298.15 K, P: 101325 Pa
 flow (kmol/hr): H2O  60
                 H2   140
                 O2   70

Alternatively, its also possible to react an array (instead of a stream):

>>> import numpy as np
>>> array = np.array([200., 0. , 0.])
>>> reaction(array)
>>> array
array([ 60., 140.,  70.])

Let’s change to a per ‘wt’ basis:

>>> reaction.basis = 'wt'
>>> reaction.show()
Reaction (by wt):
 stoichiometry               reactant    X[%]
 H2O -> 0.112 H2 + 0.888 O2  H2O        70.00

Although we changed the basis, the end result is the same if we pass a stream:

>>> feed = tmo.Stream('feed', H2O=200)
>>> reaction(feed) # Call to run reaction on mass flow
>>> feed.show() # Notice how 70% of water was converted to product
Stream: feed
 phase: 'l', T: 298.15 K, P: 101325 Pa
 flow (kmol/hr): H2O  60
                 H2   140
                 O2   70

If we pass an array, however, the Reaction object assumes the array data is by weight:

>>> array = np.array([200., 0. , 0.])
>>> reaction(array)
>>> array
array([ 60.   ,  15.666, 124.334])
copy(basis=None)[source]

Return copy of Reaction object.

force_reaction(material)[source]

React material ignoring feasibility checks.

product_yield(product, basis=None)[source]

Return yield of product per reactant.

adiabatic_reaction(stream)[source]

React stream material adiabatically, accounting for the change in enthalpy due to the heat of reaction.

Examples

Note how the stream temperature changed after the reaction due to the heat of reaction:

>>> import thermosteam as tmo
>>> import thermosteam.reaction as rxn
>>> chemicals = tmo.Chemicals(['H2', 'O2', 'H2O'])
>>> tmo.settings.set_thermo(chemicals)
>>> reaction = rxn.Reaction('2H2 + O2 -> 2H2O', reactant='H2', X=0.7)
>>> s1 = tmo.Stream('s1', H2=10, O2=20, H2O=1000)
>>> s2 = tmo.Stream('s2')
>>> s2.copy_like(s1) # s1 and s2 are the same
>>> s1.show() # Before reaction
Stream: s1
 phase: 'l', T: 298.15 K, P: 101325 Pa
 flow (kmol/hr): H2   10
                 O2   20
                 H2O  1e+03
>>> reaction.show()
Reaction (by mol):
 stoichiometry       reactant    X[%]
 H2 + 0.5 O2 -> H2O  H2         70.00
>>> reaction(s1)
>>> s1.show() # After non-adiabatic reaction
Stream: s1
 phase: 'l', T: 298.15 K, P: 101325 Pa
 flow (kmol/hr): H2   3
                 O2   16.5
                 H2O  1.01e+03
>>> reaction.adiabatic_reaction(s2)
>>> s2.show() # After adiabatic reaction
Stream: s2
 phase: 'l', T: 324.11 K, P: 101325 Pa
 flow (kmol/hr): H2   3
                 O2   16.5
                 H2O  1.01e+03
property dH

Heat of reaction at given conversion. Units are in either J/mol-reactant or J/g-reactant; depending on basis.

property X

[float] Reaction converion as a fraction.

property stoichiometry

[array] Stoichiometry coefficients.

property istoichiometry

[ChemicalIndexer] Stoichiometry coefficients.

property reactant

[str] Reactant associated to conversion.

property MWs

[1d array] Molecular weights of all chemicals [mol/g].

property basis

{‘mol’, ‘wt’} Basis of reaction

check_mass_balance(tol=0.001)[source]

Assert that stoichiometric mass balance is correct.

check_atomic_balance(tol=0.001)[source]

Assert that stoichiometric atomic balance is correct.

correct_mass_balance(variable=None)[source]

Make sure mass is not created or destroyed by varying the reactant stoichiometric coefficient.

correct_atomic_balance(constants=None)[source]

Correct stoichiometry coffecients to satisfy atomic balance.