Chemical equation

Use the ChemicalEquation class to determine properties of the reactants and products in a given chemical equation.

class chemics.ChemicalEquation(eq, names=None)[source]

Properties of the reactants and products in a given chemical equation.

Parameters:
  • eq (str) – Chemical equation such as A + B -> C + D

  • names (dict, optional) – Names of unique species and their corresponding chemical formula.

Variables:
  • eq (str) – Chemical equation such as A + B -> C + D

  • names (dict, optional) – Names of unique species and their corresponding chemical formula.

  • rct_properties (dataframe) – Number of moles, chemical species, molecular weight, mass, mole fraction, and mass fraction for each reactant.

  • rct_elements (dict) – Total number of atomic elements on reactant side of the equation.

  • rct_moles (float) – Total number of moles on reactant side of the equation.

  • rct_mass (float) – Total mass of the reactants.

  • prod_properties (dataframe) – Number of moles, chemical species, molecular weight, mass, mole fraction, and mass fraction for each product.

  • prod_elements (dict) – Total number of atomic elements on product side of the equation.

  • prod_moles (float) – Total number of moles on product side of the equation.

  • prod_mass (float) – Total mass of the products.

Examples

>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.is_balanced()
True
>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.rct_properties
               HCl        Na
moles          2.0       2.0
species        HCl        Na
molwt       36.458     22.99
mass        72.916     45.98
molfrac        0.5       0.5
massfrac  0.613275  0.386725
>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.rct_properties.loc['massfrac']
HCl    0.613275
Na     0.386725
...
>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.rct_elements
{'H': 2.0, 'Cl': 2.0, 'Na': 2.0}
>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.rct_moles
4.0...
>>> ce = cm.ChemicalEquation('2 HCl + 2 Na -> 2 NaCl + H2')
>>> ce.rct_mass
118.896...
is_balanced() bool[source]

Check balance of atomic elements in reactants or products.