Week 4.1- Handling Mixtures with Cantera
Handling Mixtures with Cantera
Introduction
Quantity is a defined class representing a specific quantity of a Solution. Class Quantity provides several additional capabilities. A Quantity object is created from a Solution with either the mass or number of moles specified
Calculation of mole
Mole fraction as per given in the code, for O2 its 0.21 and for N2 its 0.79. As per the stoichiometric coefficients, applying the definition of molar fraction for O2 and N2 species we get,
`n_{O2} = {2}/{n_("air")}`
- `0.21 = {2}/{n_("air")}`
And
`n_(N2) = {7.52}/{n_("air")}`
- `0.79 = {7.52}/{n_("air")}`
Thus, Quantity of air from both the species is calculated out to be ~ 9.52
Molar fraction of components
As given in the documentation mass_fraction_dict is a property of Quantity object. It is used to get the mass fraction of the species in the given object.
Calculation for mass fraction:
- For O2
Given Mole fraction, 0.21
No. of Moles = 0.21 * total no. of mole = 2
Mass of O2 Species = 2*mol wt. = 64g
Similarly, Mass of Nitrogen (Species other than O2) = 210.56g
So mass Fraction of O2 = `{64}/{210.56+64}` ~ = 0.233
- For N2
Similarly mass Fraction of N2 = `{210.56}/{210.56+64}` ~ = 0.767
Code Explanation line 15/16
In the given lines, Variable B is initialized with Quantity object using above declared gas Solution. Following, temperature of 298.15K, Pressure of 1 atm and concentration of species is defined. The no. 1546 has got no meaning as molar fraction is between 0 and 1. Since only one species has been declared, so its value by default is 1.
Changes to the code
For the combustion to be complete. Each mole of fuel, methane in our case, we need 2 moles of O2 and 7.52 moles of N2. So, the number of moles of air required to fulfil the complete combustion criterion is 9.52
Code Solution
# Importing Modules
import cantera as cant
gas = cant.Solution('gri30.cti')
A = cant.Quantity(gas)
A.TPX = 298.15,cant.one_atm,{'o2':0.21, 'N2':0.79}
A.moles = 9.52
print(A.mass_fraction_dict())
B = cant.Quantity(gas)
B.TPX = 298.15,cant.one_atm,'CH4:1546'
B.moles = 1
# The following step is used to apply right molar balance
M = A+B
M.equilibrate('HP')
print(M.T)