Week 4.1- Handling Mixtures with Cantera
Handling mixtures with Cantera:
Methane is considered as the fuel here and stoichiometric balance equation is mentioned below.
`CH_4+2(O_2+3.76N_2)=> CO2+2H_2O+7.52N_`
1. Moles method:
For stoichiometric combustion CH4, 2 moles of air is required.
Mole fraction of O is 2/(2+2*3.76) = 0.21
Mole fraction of N is 7.52/(2+2*3.76) = 0.79
Total number of moles = 9.52
2. print(A.mass_fraction_dict()):
It is used to print the mass fraction of the species in the object A.

3. CH4:1546 - In general, it should be 1 mole of CH4. But whatever value we put here it concludes to 1 mole of CH4.
To make the code simpler and understandable it is advisable to give 1 mole of CH4.

4. In the code sample provided by adding A.moles=2/0.21 gives the correct result ie. 2224k. And the corrected code is given below.
import cantera as ct
gas = ct.Solution('gri30.cti')
A=ct.Quantity(gas)
A.TPX= 298.15, ct.one_atm,{'O2':0.21,'N2':0.79}
A.moles=2/0.21
A.mass_fraction_dict()
A.mole_fraction_dict()
B=ct.Quantity(gas)
B.TPX= 298.15, ct.one_atm,{'CH4':1}
B.moles=1
M=A+B
M.equilibrate('HP','auto')
print(M.T)
print(A.mass_fraction_dict())
print(A.mole_fraction_dict())
print(A.moles)