<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Stoichiometry Calculations
Calculating Molar Mass
Determining the molar mass of a substance is done countless times in mass and energy balance models and other process models. It usually requires you to create your own little database or list that you look up the values from. Once you have that, you can perform the required calculations. The auxi.tools.chemistry.stoichiometry module provides the molar_mass() function for this purpose.
Standard Approach
The normal way of getting the molar mass of one or more compounds is as follows
Step1:  An example is shown below with its output
Step2:  Compact Approach
One of Python's strengths is its ability to make code very compact. You may not always want to use a lengthy "stoichiometry.molar_mass" reference to the function. Rather than importing the auxi.tools.chemistry.stoichiometry module, we can import the auxi.tools.chemistry.stoichiometry.molar_mass function directly, and give it another name. Here is how you can make it short and sweet
Step3:  More Examples
Here are some more examples of molar mass calculations
Step4:  Calculating Compound Amount
Sometimes you need to convert the mass of a compound (kg) to the equivalent amount (kmol). The auxi.tools.chemistry.stoichiometry module provides the auxi.tools.chemistry.stoichiometry.amount function to do this.
The amount is calculated as follows
Step5:  Compact Approach
To make the code more compact, we can import the function instead of the module and get the same result like this
Step6:  Calculating Compound Mass
You often have the amount (kmol) of a compound and then need to calculate its mass. The auxi.tools.chemistry.stoichiometry module provides the auxi.tools.chemistry.stoichiometry.mass function for this. The mass is calculate with this formula
Step7:  Identifying Elements in Compounds
The list of elements present in one or more compounds can be used when calculating element balances. Determining this list is often done manually. auxi.tools.chemistry.stoichiometry has the auxi.tools.chemistry.stoichiometry.elements function to automate this task. This is how you use it
Step8:  Calculating Stoichiometry Coefficients
The auxi.tools.chemistry.stoichiometry.stoichiometry_coefficient and auxi.tools.chemistry.stoichiometry.stoichiometry_coefficients functions in auxi.tools.chemistry.stoichiometry determine the stoichiometry coefficients of elements in chemical compounds automatically. If we are only interested in the coefficient for a single element, we use auxi.tools.chemistry.stoichiometry.stoichiometry_coefficient like this
Step9:  We can determine the coefficients for a list of elements using the auxi.tools.chemistry.stoichiometry.stoichiometry_coefficients function
Step10:  Calculating Element Mass Fractions
Another two useful tools in the calculation of element balances are the auxi.tools.chemistry.stoichiometry.element_mass_fraction and auxi.tools.chemistry.stoichiometry.element_mass_fractions functions in auxi.tools.chemistry.stoichiometry. They are similar to the stoichiometry coefficient functions, but calculate the mass fraction of an element or list of elements in a chemical compound. The calculations are done with the following equation
Step11:  Converting Compounds
Sometimes it is needed to convert the mass of one compound to an equivalent mass of another compound. For example, how much Fe will I get when I reduce a certain mass of Fe2O3? auxi.tools.chemistry.stoichiometry has the auxi.tools.chemistry.stoichiometry.convert_compound function to help out. The function calculates the result as follows
<ASSISTANT_TASK:>
Python Code:
from auxi.tools.chemistry import stoichiometry
molarmass_FeO = stoichiometry.molar_mass("FeO")
molarmass_CO2 = stoichiometry.molar_mass("CO2")
molarmass_FeCr2O4 = stoichiometry.molar_mass("FeCr2O4")
Explanation: Stoichiometry Calculations
Calculating Molar Mass
Determining the molar mass of a substance is done countless times in mass and energy balance models and other process models. It usually requires you to create your own little database or list that you look up the values from. Once you have that, you can perform the required calculations. The auxi.tools.chemistry.stoichiometry module provides the molar_mass() function for this purpose.
Standard Approach
The normal way of getting the molar mass of one or more compounds is as follows:
End of explanation
print("Molar mass of FeO    :", molarmass_FeO, "kg/kmol")
print("Molar mass of CO2    :", molarmass_CO2, "kg/kmol")
print("Molar mass of FeCr2O4:", molarmass_FeCr2O4, "kg/kmol")
Explanation: An example is shown below with its output:
End of explanation
from auxi.tools.chemistry.stoichiometry import molar_mass as mm
molarmass_FeO = mm("FeO")
print("Molar mass of FeO    :", molarmass_FeO, "kg/kmol")
print("Molar mass of CO2    :", mm("CO2"), "kg/kmol")
print("Molar mass of FeCr2O4:", mm("FeCr2O4"), "kg/kmol")
Explanation: Compact Approach
One of Python's strengths is its ability to make code very compact. You may not always want to use a lengthy "stoichiometry.molar_mass" reference to the function. Rather than importing the auxi.tools.chemistry.stoichiometry module, we can import the auxi.tools.chemistry.stoichiometry.molar_mass function directly, and give it another name. Here is how you can make it short and sweet:
End of explanation
from auxi.tools.chemistry.stoichiometry import molar_mass as mm
def print_molar_mass(compound):
    print("Molar mass of", compound, "is", mm(compound), "kg/kmol.")
print_molar_mass("FeO1.5")
print_molar_mass("Fe2O3")
print_molar_mass("FeOTiO2")
print_molar_mass("FeTiO3")
print_molar_mass("Fe2(CO3)3")
print_molar_mass("Fe2C3O9")
print_molar_mass("H2O")
print_molar_mass("H")
print_molar_mass("He")
print_molar_mass("Au")
Explanation: More Examples
Here are some more examples of molar mass calculations:
End of explanation
from auxi.tools.chemistry import stoichiometry
m_FeO = 10.0
n_FeO = stoichiometry.amount("FeO", m_FeO)
print("There is", n_FeO, "kmol of FeO in", m_FeO , "kg of the compound.")
m_CO2 = 12.3
n_CO2 = stoichiometry.amount("CO2", m_CO2)
print("There is", n_CO2, "kmol of CO2 in", m_CO2 , "kg of the compound.")
m_FeCr2O4 = 453.0
n_FeCr2O4 = stoichiometry.amount("FeCr2O4", m_FeCr2O4)
print("There is", n_FeCr2O4, "kmol of FeCr2O4 in",
      m_FeCr2O4 , "kg of the compound.")
Explanation: Calculating Compound Amount
Sometimes you need to convert the mass of a compound (kg) to the equivalent amount (kmol). The auxi.tools.chemistry.stoichiometry module provides the auxi.tools.chemistry.stoichiometry.amount function to do this.
The amount is calculated as follows:
$$n_{\text{compound}} = \frac{m_{\text{compound}}}{mm_{\text{compound}}}$$
where
$n_{\text{compound}}$ is the compound amount in kmol.
 $m_{\text{compound}}$ is the compound mass in kg.
 $mm_{\text{compound}}$ is the compound molar mass in kg/kmol.
Standard Approach
The normal way of calculating the amount of a compound is as follows:
End of explanation
from auxi.tools.chemistry.stoichiometry import amount
m_FeO = 10.0
n_FeO = amount("FeO", m_FeO)
print("There is", n_FeO, "kmol of FeO in", m_FeO , "kg of the compound.")
m_CO2 = 12.3
n_CO2 = amount("CO2", m_CO2)
print("There is", n_CO2, "kmol of CO2 in", m_CO2 , "kg of the compound.")
m_FeCr2O4 = 453.0
n_FeCr2O4 = amount("FeCr2O4", m_FeCr2O4)
print("There is", n_FeCr2O4, "kmol of FeCr2O4 in",
      m_FeCr2O4 , "kg of the compound.")
Explanation: Compact Approach
To make the code more compact, we can import the function instead of the module and get the same result like this:
End of explanation
from auxi.tools.chemistry import stoichiometry
n_FeO = 10.0
m_FeO = stoichiometry.mass("FeO", n_FeO)
print("There is", m_FeO, "kg of FeO in", n_FeO , "kmol of the compound.")
m_CO2 = 12.3
n_CO2 = stoichiometry.mass("CO2", m_CO2)
print("There is", m_CO2, "kg of CO2 in", n_CO2 , "kmol of the compound.")
m_FeCr2O4 = 453.0
n_FeCr2O4 = stoichiometry.mass("FeCr2O4", m_FeCr2O4)
print("There is", m_FeCr2O4, "kg of FeCr2O4 in",
      n_FeCr2O4 , "kmol of the compound.")
Explanation: Calculating Compound Mass
You often have the amount (kmol) of a compound and then need to calculate its mass. The auxi.tools.chemistry.stoichiometry module provides the auxi.tools.chemistry.stoichiometry.mass function for this. The mass is calculate with this formula:
$$m_{\text{compound}} = n_{\text{compound}} \cdot mm_{\text{compound}}$$
where
$m_{\text{compound}}$ is the compound mass in kg.
 $n_{\text{compound}}$ is the compound amount in kmol.
 $mm_{\text{compound}}$ is the compound molar mass in kg/kmol.
From this point forward the standard and compact approaches are not both demonstrated. Only the standard method, which imports the module, is used below since it is more explicit:
End of explanation
from auxi.tools.chemistry import stoichiometry
elements_Fe2O3 = stoichiometry.elements(["Fe2O3"])
print("Fe2O3 contains these elements:", elements_Fe2O3)
elements_CO2 = stoichiometry.elements(["CO2"])
print("CO2 contains these elements:", elements_CO2)
elements_Fe2Cr2O4 = stoichiometry.elements(["Fe2Cr2O4"])
print("Fe2Cr2O4 contains these elements:", elements_Fe2Cr2O4)
elements_Al2S3O12 = stoichiometry.elements(["Al2(SO4)3"])
print("Al2(SO4)3 contains these elements:", elements_Al2S3O12)
elements_all = stoichiometry.elements(["Fe2O3", "CO2", "Fe2Cr2O4", "Al2(SO4)3"])
print("Fe2O3, CO2, Fe2Cr2O4 and Al2(SO4)3 contain these elements:",
      elements_all)
Explanation: Identifying Elements in Compounds
The list of elements present in one or more compounds can be used when calculating element balances. Determining this list is often done manually. auxi.tools.chemistry.stoichiometry has the auxi.tools.chemistry.stoichiometry.elements function to automate this task. This is how you use it:
End of explanation
from auxi.tools.chemistry import stoichiometry
coeff_Fe2O3_Fe = stoichiometry.stoichiometry_coefficient("Fe2O3", "Fe")
print("Stoichiometry coefficient of Fe in Fe2O3:", coeff_Fe2O3_Fe)
coeff_Fe2O3_O = stoichiometry.stoichiometry_coefficient("Fe2O3", "O")
print("Stoichiometry coefficient of O in Fe2O3:", coeff_Fe2O3_O)
coeff_Fe2O3_C = stoichiometry.stoichiometry_coefficient("Fe2O3", "C")
print("Stoichiometry coefficient of C in Fe2O3:", coeff_Fe2O3_C)
Explanation: Calculating Stoichiometry Coefficients
The auxi.tools.chemistry.stoichiometry.stoichiometry_coefficient and auxi.tools.chemistry.stoichiometry.stoichiometry_coefficients functions in auxi.tools.chemistry.stoichiometry determine the stoichiometry coefficients of elements in chemical compounds automatically. If we are only interested in the coefficient for a single element, we use auxi.tools.chemistry.stoichiometry.stoichiometry_coefficient like this:
End of explanation
from auxi.tools.chemistry import stoichiometry
elements = ["Fe", "O", "C", "Ar"]
st_Fe2O3 = stoichiometry.stoichiometry_coefficients("Fe2O3", elements)
print("Stoichiometry coefficient of", elements, "in Fe2O3:",
      st_Fe2O3)
elements = ["Al", "Ca", "Fe", "Si", "O", "C", "H"]
st_Lawsonite = stoichiometry.stoichiometry_coefficients("CaAl2Si2O7O2H2H2O",
                                                 elements)
print("Stoichiometry coefficient of", elements,
      "in Lawsonite (CaAl2(Si2O7)(OH)2·H2O):", st_Lawsonite)
Explanation: We can determine the coefficients for a list of elements using the auxi.tools.chemistry.stoichiometry.stoichiometry_coefficients function:
End of explanation
from auxi.tools.chemistry import stoichiometry
y_Fe2O3_Fe = stoichiometry.element_mass_fraction("Fe2O3", "Fe")
print("Mass fraction of Fe in Fe2O3:", y_Fe2O3_Fe)
y_Fe2O3_O = stoichiometry.element_mass_fraction("Fe2O3", "O")
print("Mass fraction of O in Fe2O3:", y_Fe2O3_O)
y_Fe2O3_C = stoichiometry.element_mass_fraction("Fe2O3", "C")
print("Mass fraction of C in Fe2O3:", y_Fe2O3_C)
from auxi.tools.chemistry import stoichiometry
elements = ["Fe", "O", "C", "Ar"]
y_Fe2O3 = stoichiometry.element_mass_fractions("Fe2O3", elements)
print("Mass fractions of", elements, "in Fe2O3:", y_Fe2O3)
elements = ["Al", "Ca", "Fe", "Si", "O", "C", "H"]
y_Lawsonite = stoichiometry.element_mass_fractions("CaAl2Si2O7O2H2H2O", elements)
print("Mass fractions of", elements,
      "in Lawsonite (CaAl2(Si2O7)(OH)2·H2O):",
      y_Lawsonite)
Explanation: Calculating Element Mass Fractions
Another two useful tools in the calculation of element balances are the auxi.tools.chemistry.stoichiometry.element_mass_fraction and auxi.tools.chemistry.stoichiometry.element_mass_fractions functions in auxi.tools.chemistry.stoichiometry. They are similar to the stoichiometry coefficient functions, but calculate the mass fraction of an element or list of elements in a chemical compound. The calculations are done with the following equation:
$$y_{\text{compound,element}} = \frac{n_{\text{compound,element}} \cdot mm_{\text{element}}}{mm_{\text{compound}}}$$
where
$y_{\text{compound,element}}$ is the mass fraction of the specified element in the compound.
 $n_{\text{compound,element}}$ is the stoichiometry coefficient of the specified element in the compound.
 $mm_{\text{element}}$ is the element's molar mass in kg/kmol.
 $mm_{\text{compound}}$ is the compound's molar mass in kg/kmol.
For determining the mass fraction of a single element we can use auxi.tools.chemistry.stoichiometry.element_mass_fraction as follows:
End of explanation
from auxi.tools.chemistry import stoichiometry
m_Fe2O3 = 10.0
m_Fe = stoichiometry.convert_compound(m_Fe2O3, "Fe2O3", "Fe", "Fe")
print("From", m_Fe2O3, "kg of Fe2O3,", m_Fe ,
      "kg of Fe can be produced.")
m_Fe = 10.0
m_Fe2O3 = stoichiometry.convert_compound(m_Fe, "Fe", "Fe2O3", "Fe")
print("When", m_Fe, "kg of Fe is oxidised completely,", m_Fe2O3 ,
      "kg of Fe2O3 will be produced.")
Explanation: Converting Compounds
Sometimes it is needed to convert the mass of one compound to an equivalent mass of another compound. For example, how much Fe will I get when I reduce a certain mass of Fe2O3? auxi.tools.chemistry.stoichiometry has the auxi.tools.chemistry.stoichiometry.convert_compound function to help out. The function calculates the result as follows:
$$m_{\text{target}} = m_{\text{source}} \cdot \frac{y_{\text{source,element}}}{y_{\text{target,element}}}$$
where
$m_{\text{target}}$ is the target compound mass in kg.
 $m_{\text{source}}$ is the source compound mass in kg.
 $y_{\text{target,element}}$ is the mass fraction of the specified base element in the target compound.
 $y_{\text{source,element}}$ is the mass fraction of the specified base element in the source compound.
Here are some simple examples of how to use auxi.tools.chemistry.stoichiometry.convert_compound:
End of explanation
<END_TASK>