Week 4.1- Handling Mixtures with Cantera
1. Use the "moles" method/function of the A object and explain how it was calculated.
In the dictionary command line, its given : O2=0.21 and N2=0.71
1 mole O2 = 0.79/0.21 moles of N2 = 3.76 moles of N2
Stiochiometric reaction of Methane and Air : CH4+2 (O2+3.76 N2)= CO2+2 H2O+2*3.76 N2
mixture (O2+N2) ~ 2 Moles ,i.e, One mole of methane requires 2 moles of air.
Moles=(number of moles)/(species Mole fraction)
>O2 moles = 2/0.21 = 9.5238
>N2 moles = (2*3.76)/0.79 = 9.5189
2.Use the method mole_fraction_dict() of the A object and explain the result that you get.
import cantera as ct
#Air(A) and Fuel(B) using quantity class from cantera library.
phi = 1 #equivalence ratio
gas = ct.Solution('gri30.cti')
A = ct.Quantity(gas)
A.TPX = 298.15, 101325,{'O2':0.21,'N2':0.79}
A.moles = 9.52/phi # no of moles of air taken for one mole of fuel.
print(A.mass_fraction_dict())
print(A.mole_fraction_dict())
B = ct.Quantity(gas)
B.TPX = 298.15, 101325,{'CH4':1546}
B.moles = 1
print(B.mass_fraction_dict())
print(B.mole_fraction_dict())
M = A + B
M.equilibrate('HP')
print(M.T)

Explanation:
mole fraction = no.of moles of the species/ total no.of moles available
O2 mole fraction = 2/(2+3.76*2) = 0.21
N2 mole fraction = 2*3.76/(2+3.76*2) = 0.79
Mass fraction = molecular weight of species * no.of moles of species taken/ Total molecular weight of species * total no.of moles of species taken
O2 mass fraction = 32*2/((32*2) + (7.52*28)) = 64/(64+210.56) = 0.23
N2 mass fraction = 210.56/(64+210.56) = 0.76
3. What is happenging in lines 15 and 16? Make sure you explain what 1546 means? Is that reasonable?
After creating another instance 'B' of class 'Quantity' in line 14, we are defining the Temperature, Pressure and the mole fractions. While defining the mole fraction, we must specify all the species involved along with their mole fractions separated by a colon. However, since there is only one species inside this quantity, any positive number greater than 0 can be specified alongside the species. The result does not change.
In line 16, it is necessary to specify the number of moles of CH4 we're working with, otherwise, Cantera will again assume per gram value for the number of moles for CH4 which would give wrong results.
4. What changes do you need to put in place to get the right value of AFT in line 22?. You have to compute the right number of moles of A.
import cantera as ct
gas = ct.Solution('gri30.cti')
air = ct.Quantity(gas)
air.TPX = 298.15, ct.one_atm, {'O2': 0.21, 'N2': 0.79}
air.moles = 9.52
fuel = ct.Quantity(gas)
fuel.TPX = 298.15, ct.one_atm, 'CH4:0.1'
fuel.moles = 1
air.constant = fuel.constant = 'HP'
mix = air + fuel
mix.equilibrate('HP')
print(mix.T)

Correction:
On the reactants side,
Number of moles of CH4 = 1 ; phi = 1
Number of moles of air = 2 + 2*3.76 = 9.52