Week 4 - Handling Mixtures with Cantera
1. Use the "moles" method/function of the A object and explain how it was calculated. You need to use this after line number 9.
One mole of methane requires 2 moles of air for the stochiometric reaction to take place.
Air consists of 21% Oxygen and 79% Nitrogen.
1 mole oxygen = 0.79/0.21 moles of nitrogen.
Which means that for every 1 mole of oxygen there are 3.76 moles of nitrogen
oxygen + nitrogen = 4.76 moles
since we take 2 moles of Air for this reaction total no of moles of air = 2*4.76 = 9.52
mole fraction = no.of moles of the species/ total no.of moles available
moles of the air taken = no of moles of species/ mole fraction of the species
O2 = 2/0.21 = 9.52
N2 moles = 2*3.76/0.79 = 9.52
So moles of oxygen = moles of nitrogen
for 1 mole of methane we are taking 9.52 moles of air.
import cantera as ct
#Here we are writing individual code for 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)
Results obtained using A.mass_fraction_dict() : {'N2': 0.7670829987741036, 'O2': 0.23291700122589645}
A.mole_fraction_dict() : {'N2': 0.79, 'O2': 0.21}
AFT of the methane fuel at stochiometric condition = 2224.41 kelvin
In this code we have used 'Quantity' class from the cantera library which helps in providing seperate properties for each species involved in the reaction.
2. Use the method mole_fraction_dict() of the A object and explain the result that you get. Here is how you need to use it. print(A.mass_fraction_dict())
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.2331
N2 mass fraction = 210.56/(64+210.56) = 0.7668
from the calculation we got most accurate values comparing to the Cantera Values.
3. What is happenging in lines 15 and 16? Make sure you explain what 1546 means? Is that reasonable?
B.TPX = 298.15, 101325,{'CH4':1546}
We call the TPX function by defining the temperature , pressure and mole fraction of the fuel or species of gas involved.
here '1546' equals to 1 because no other species are involved in this Quantity class. we can give any random number above zero as long as there is only one species in the 'Quantity' class.
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. Hint: The change needs to be done in line number 10. You have to compute the right number of moles of A.
We have to define the no of moles of air taken by A.moles = 9.52/phi. These tells python that for 1 mole of methane there 9.52 moles of air. we can vary the no of moles of air taken by changing the value of phi.
phi is equivalence ratio.