Week 4.1- Handling Mixtures with Cantera
Handling Mixtures with Cantera:
Aim:
Use Quantity class in Cantera, to perform mixtures calculations.
Theory:
Balanced equation for stoichiometric combustion of methane is as follows:
`CH_4 + 2(O_2 + 3.76N_2) -> CO_2 + 2H_2O + 7.52N_2`
Composition of Air:
Air is assumed to be contain only oxygen and Nitrogen.
21% oxygen and 79% nitrogen on volume basis.
Code:
"""
sample code to vary the temperature of air and oxidiser individually
"""
import cantera as ct
gas = ct.Solution('gri30.cti')
# creating air object
A = ct.Quantity(gas)
A.TPX = 298.15,ct.one_atm,'O2:1, N2:3.76'
# we take equivalence ration to 1
A.moles = 9.52
print('Mole fraction of A '+str(A.mole_fraction_dict()))
print('Mass fraction of A '+str(A.mass_fraction_dict()))
#gas(A)
# creating fuel object
B = ct.Quantity(gas)
B.TPX = 298.15,ct.one_atm,'CH4 : 1'
B.moles = 1
#gas(B)
print('Mole fraction of B '+str(B.mole_fraction_dict()))
print('Mass fraction of B '+str(B.mass_fraction_dict()))
# combining both fuel and air
M = A + B
# Calculating AFT
M.equilibrate('HP')
#gas(M)
#print(M.report())
print('Adiabatic Flame temperature of stoichiometric methane air mixture ' + str(M.T) + 'K')
#help(B)
Output of the above code:

1. Use the "moles" method/function, calculate the number of moles of the object A and explain how it is calculated analytically. You need to use this after line number 9 by using the predefined function ‘A.moles’
A. We know air contains mostly nitrogen and oxygen. We consider their mole fractions approximately as 0.79 and 0.21 respectively.
The balanced equation for stoichiometric methane combustion with equivalence ratio of '1' is
`CH_4 + 2(O_2 + 3.76N_2) -> CO_2 + 2H_2O + 7.52N_2`
From the above equation, wa can see for every one mole of methane, we need two moles of Oxygen and 7.52 moles of Nitrigen. Total of object A contains 2+7.52 moles. Of which 7.52 moles is Nitrogen (0.79%) and 2 moles is Oxygen (0.21%).
So, we need to use A.moles = 9.52 in line 9 of the code.
2. Use the method mass_fraction_dict() of the A object and explain it analytically
A. The method 'mass_fraction_dict()' is used to calculate mass fractions of a given composition.
| Species | Mole Fraction | Number of moles | Mass | Mass Fraction |
| `O_2` | 0.21 | 9.52*0.21 =2 | 2*32=64 | 64/(64+210.56)=0.2331 |
| `N_2` | 0.79 | 9.52*0.79=7.52 | 7.52*28=210.56 | 210.56/(64+210.56)=0.7668 |
We obtain the same output from Cantera.
3. What is happening in lines 15 and 16? Make sure you explain what 1546 means? Is that reasonable?
A. In line 15 we are assigning the intial temperature , pressure and number of moles of each species or mole fraction.
Whether we enter the number of moles of each species or mole fraction, we obtain the same result. this is because the cantera converts it into mole fraction. Therefore the value written 1546 has no significance . It will be read as 'B' contains only one species methane , which has mole fraction of one.
In line 16, we are inputing the number of moles of all the species present in the 'B'.
4. What changes do you need to put in place to get the right value of AFT in line 22?. The right answer is 2224K.
A. We need to input correct number of moles of each species participating in the reaction for correct value of AFT. That is number of moles of species in object A is 9.52.