auxi.tools.chemistry.stoichiometry module¶
This module provides a number of functions for doing stoichiometry calculations.
-
class
auxi.tools.chemistry.stoichiometry.
Compound
(group, dottedgroup=None, phase=None)¶ Bases:
object
Represents a full compound formula
Parameters: - group – iterable of Group/Element
- dottedgroup – A Group if there is a .H2O part, None otherwise
- phase – The phase if there is a [phase] part, None otherwise
-
count
()¶
-
molar_mass
()¶
-
class
auxi.tools.chemistry.stoichiometry.
CompoundVisitor
¶ Bases:
parsimonious.nodes.NodeVisitor
Visitor which takes parsed tree to useful groups.
For parallels, check the grammar.
-
generic_visit
(node, other)¶
-
visit_compound
(_, compound)¶
-
visit_dottedgroup
(_, dottedgroup)¶
-
visit_element
(node, _)¶
-
visit_group
(_, group)¶
-
visit_number
(node, _)¶
-
visit_phase
(node, _)¶
-
visit_subscriptedelement
(_, subscriptedelement)¶
-
visit_subscriptedgroup
(_, subscriptedgroup)¶
-
-
class
auxi.tools.chemistry.stoichiometry.
Element
(period, group, atomic_number, symbol, molar_mass)¶ Bases:
auxi.core.objects.Object
An element in the periodic table.
Parameters: - period – Period to which the element belongs.
- group – Group to which the element belongs.
- atomic_number – Number of protons in the element’s nucleus.
- symbol – Element’s symbol.
- molar_mass – [kg/kmol] Element’s standard atomic mass.
-
count
()¶
-
class
auxi.tools.chemistry.stoichiometry.
Group
(group, multiplier=1, dotted=False)¶ Bases:
object
Represent a part of a compound formula
Parameters: - group – iterable of Group/Element parts
- multiplier – multiplier in subscript or prefix of group
- dotted – True of the group is like ‘.2H2O’
-
count
()¶
-
auxi.tools.chemistry.stoichiometry.
amount
(compound, mass)¶ Calculate the number of moles in the specified mass of a chemical compound.
Parameters: - compound – Formula and phase of a compound, e.g. ‘Fe2O3[S1]’. The phase may be omitted.
- mass – [kg]
Returns: Amount. [kmol]
-
auxi.tools.chemistry.stoichiometry.
amount_fractions
(masses)¶ Calculate the mole fractions from the specified compound masses.
Parameters: masses – [kg] dictionary, e.g. {‘SiO2’: 3.0, ‘FeO’: 1.5} Returns: [mole fractions] dictionary
-
auxi.tools.chemistry.stoichiometry.
amounts
(masses)¶ Calculate the amounts from the specified compound masses.
Parameters: masses – [kg] dictionary, e.g. {‘SiO2’: 3.0, ‘FeO’: 1.5} Returns: [kmol] dictionary
-
auxi.tools.chemistry.stoichiometry.
convert_compound
(mass, source, target, element)¶ Convert the specified mass of the source compound to the target using element as basis.
Parameters: - mass – Mass of from_compound. [kg]
- source – Formula and phase of the original compound, e.g. ‘Fe2O3[S1]’.
- target – Formula and phase of the target compound, e.g. ‘Fe[S1]’.
- element – Element to use as basis for the conversion, e.g. ‘Fe’ or ‘O’.
Returns: Mass of target. [kg]
-
auxi.tools.chemistry.stoichiometry.
count_with_multiplier
(groups, multiplier)¶ Update group counts with multiplier
This is for handling atom counts on groups like (OH)2
Parameters: - groups – iterable of Group/Element
- multiplier – the number to multiply by
-
auxi.tools.chemistry.stoichiometry.
element_mass_fraction
(compound, element)¶ Determine the mass fraction of an element in a chemical compound.
Parameters: - compound – Formula of the chemical compound, ‘FeCr2O4’.
- element – Element, e.g. ‘Cr’.
Returns: Element mass fraction.
-
auxi.tools.chemistry.stoichiometry.
element_mass_fractions
(compound, elements)¶ Determine the mass fractions of a list of elements in a chemical compound.
Parameters: - compound – Formula and phase of a chemical compound, e.g. ‘Fe2O3[S1]’.
- elements – List of elements, [‘Si’, ‘O’, ‘Fe’].
Returns: Mass fractions.
-
auxi.tools.chemistry.stoichiometry.
elements
(compounds)¶ Determine the set of elements present in a list of chemical compounds.
The list of elements is sorted alphabetically.
Parameters: compounds – List of compound formulas and phases, e.g. [‘Fe2O3[S1]’, ‘Al2O3[S1]’]. Returns: List of elements.
-
auxi.tools.chemistry.stoichiometry.
mass
(compound, amount)¶ Calculate the mass of the specified amount of a chemical compound.
Parameters: - compound – Formula and phase of a compound, e.g. ‘Fe2O3[S1]’. The phase may be omitted.
- amount – [kmol]
Returns: Mass. [kg]
-
auxi.tools.chemistry.stoichiometry.
mass_fractions
(amounts)¶ Calculate the mole fractions from the specified compound masses.
Parameters: masses – [kg] dictionary, e.g. {‘SiO2’: 3.0, ‘FeO’: 1.5} Returns: [mass fractions] dictionary
-
auxi.tools.chemistry.stoichiometry.
masses
(amounts)¶ Calculate the masses from the specified compound amounts.
Parameters: masses – [kmol] dictionary, e.g. {‘SiO2’: 3.0, ‘FeO’: 1.5} Returns: [kg] dictionary
-
auxi.tools.chemistry.stoichiometry.
molar_mass
(compound='')¶ Determine the molar mass of a chemical compound.
The molar mass is usually the mass of one mole of the substance, but here it is the mass of 1000 moles, since the mass unit used in auxi is kg.
Parameters: compound – Formula of a chemical compound, e.g. ‘Fe2O3’. Returns: Molar mass. [kg/kmol]
-
auxi.tools.chemistry.stoichiometry.
parse_compound
¶
-
auxi.tools.chemistry.stoichiometry.
stoichiometry_coefficient
(compound, element)¶ Determine the stoichiometry coefficient of an element in a chemical compound.
Parameters: - compound – Formula of a chemical compound, e.g. ‘SiO2’.
- element – Element, e.g. ‘Si’.
Returns: Stoichiometry coefficient.
-
auxi.tools.chemistry.stoichiometry.
stoichiometry_coefficients
(compound, elements)¶ Determine the stoichiometry coefficients of the specified elements in the specified chemical compound.
Parameters: - compound – Formula of a chemical compound, e.g. ‘SiO2’.
- elements – List of elements, e.g. [‘Si’, ‘O’, ‘C’].
Returns: List of stoichiometry coefficients.