Week 4 - Handling Mixtures with Cantera
Objective:
- Use of 'mole' function on an object and explain.
- Use mole_fraction_dict() and mass_fraction_dict() of object.
- Explain line no. 17 & 18
- Compute moles of A to get the right value of AFT
Results:
Mole & Mass function:
Here, using this function we can change the size of 'quantity' by setting the mass or nos. of moles. Mass and mole fractions can also be set using 'dict' objects, which is convenient in cases where the composition is stored in a variable or is computed.
Python Code:
"""
Program to understand the Quantity class of Cantera
By- GAURAV V. KHARWADE|| Skill-Lync 2020
"""
import cantera as ct
gas= ct.Solution('gri30.cti')
# To define the composition of AIR
A= ct.Quantity(gas)
A.TPX= 298.15,ct.one_atm,{'O2':0.21,'N2':0.79}
A.moles= 9.52
# To define the composition of OXIDIZER
B= ct.Quantity(gas)
B.TPX= 298.15,ct.one_atm,'CH4:1546'
B.moles= 1
M= A + B
M.equilibrate('HP', solver='auto')
print(A.report())
print(B.report())
# To Know the mass fraction of object A & B
print('Mass fraction of AIR is=',A.mass_fraction_dict())
print('Mass fraction of OXIDIZER is=',B.mass_fraction_dict())
# To Know the relative mole fraction of object A & B
print('Mole fraction of AIR is=',A.mole_fraction_dict())
print('Mole fraction of OXIDIZER is=',B.mole_fraction_dict())
print('AFT is=',M.T)
When the composition alone is changed, the temperature and density are held constant. This means that the pressure and other intensive properties will change. The composition can also be set in conjunction with the intensive properties of the mixture
The mole numbers will be normalized to produce the mole fractions, and therefore they are “relative” mole numbers. Mass fractions can be set in this way too by changing X to Y in the above statements.


As we can see in the output of this program, we have seen both mass fraction and mole fraction of objects A & B. Moles of air is set to 9.52 as we know for 2 moles of N2 2/0.79=9.52 to achieve an accurate AFT of 2224.41K.
For object B, we have already defined mole number to 1 hence using 1546 will not be reasonable. The state of object B is initialized by a temperature of 298.15 K, 101325 pa of Pressure, and composition on a mole basis (CH4:1546).