Week 4.1- Handling Mixtures with Cantera
Aim: To work with the Quantity class of Cantera to create various mixtures. In this process, you will explain how the mixture calculations are performed.
The explanation for the
1.Calculation of number of moles air
The moles are calculated for the air by using the formula
`x_ (O_2) = n_ (O_2) / (n_ (O_2) + n_ (N_2)) = n_ (O_2) / n_ (air)`
`n_(O_2)` is the number of moles of oxygen
`x_(O_2)` is the mole fraction of the oxygen
`n_(air)` is the number of moles of air`
`n_(air)` =2/0.21 = 9.52`
it can also be calculate from the balanced equation
`CH_4 + 2(O_2 +3.76N_2) -> CO_2 + 2H_2O + 7.52N_2`
`n_(air)` = 2(1+3.76)
2. Using print(A.mass_fraction_dict()) command
This gives the mass fraction of the Air

This calculates the mass fraction of species present in the air. The number of moles given is used to calculate the mass fraction.
3. lines 15 and 16 explanation
B.TPX = 298.15,ct.one_atm,' CH4:1546' It is the defining of the initial values for the methane gas like Temperature, pressure, mole fraction. As there is only one species present the mole fraction is 1.
The number 1546 is arbitrary.
In line 16 the mole fraction of fuel B is defined as 1.
4. The changes that are put in place to get the right value of AFT are assigning the number of moles in line 10 for the air. The number of moles of air is calculated using the mole fraction formula or from the balanced equation.
The number of moles of air is assigned using command A.moles = 9.523
"""
Sample code to vary the temperature of air and oxidizer individually
"""
import cantera as ct
gas = ct.Solution('gri30.cti')
#Air
A = ct.Quantity(gas)
A.TPX = 298.15,ct.one_atm,{'O2':0.21,'N2':0.79}
A.moles = 9.523
print('Air Mass Fraction',A.mass_fraction_dict())
print('Mass of air:',A.mass,'kg')
#Fuel
B = ct.Quantity(gas)
B.TPX = 298.15,ct.one_atm,'CH4:1546'
B.moles = 1
print('Mass of Fuel:',B.mass,'kg')
# To find the AFT of the mixture
M=A+B
M.equilibrate('HP',solver ='auto')
print('Adiabatic Flame Temperature',M.T)