eqtk.parse_rxns

eqtk.parse_rxns(rxns)

Parse reactions inputted as multiline strings to a stoichiometric matrix.

Parameters

rxns (str) – String expressing chemical reactions. The syntax is similar to that of Cantera (http://cantera.org). Specifically: - The chemical equality operator is defined by <=> or and must be preceded and followed by whitespace. - The chemical + operator must be preceded and followed by whitespace. - Stoichiometric coefficients are followed by a space. - Each chemical reaction appears on its own line.

Returns

output – DataFrame with column names given by the chemical species. Each row of the data frame represents the stoichiometric coefficients of a reaction. If equilibrium constants are given in the input, a column “equilibrium constant” is also included in the output, giving the equilibrium constant for the respective reaction.

Return type

Pandas DataFrame

Examples

>>> import eqtk
>>> rxns = '''
... L + A <=> LA ; 1.2
... L + B <=> LB ; 3e-7
... A + B <=> AB ; 0.005
... LB + A <=> LAB ; 2'''
>>> eqtk.parse_rxns(rxns)
     L    A   LA    B   LB   AB  LAB  equilibrium constant
0 -1.0 -1.0  1.0  0.0  0.0  0.0  0.0          1.200000e+00
1 -1.0  0.0  0.0 -1.0  1.0  0.0  0.0          3.000000e-07
2  0.0 -1.0  0.0 -1.0  0.0  1.0  0.0          5.000000e-03
3  0.0 -1.0  0.0  0.0 -1.0  0.0  1.0          2.000000e+00
>>> import eqtk
>>> rxns = '''
... AB <=> A + B ; 0.015
... AC <=> A + C ; 0.003
... AA <=> 2 A   ; 0.02'''
>>> eqtk.parse_rxns(rxns)
    AB    A    B   AC    C   AA  equilibrium constant
0 -1.0  1.0  1.0  0.0  0.0  0.0                 0.015
1  0.0  1.0  0.0 -1.0  1.0  0.0                 0.003
2  0.0  2.0  0.0  0.0  0.0 -1.0                 0.020