Handling Mixtures
code :
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 = 9.52
print(A.mass_fraction_dict())
B=ct.Quantity(gas)
B.TPX = 298.15,ct.one_atm,\'CH4:1546\'
B.moles = 1
M = A + B
M.equilibrate(\'HP\',\'auto\')
print(M.T)
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.
Ans :CH4 + 2*O2 + 7.52*N2 = CO2 + 2*H2O + 7.52*N2
Here the number of moles of air in A is 2+7.52 = 9.52, which is represented in the code as A.moles =9.52. This number is obtained by balancing the chemical equation.
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())
Ans : On using the print(A.mass_fraction_dict()), the following output was obtained:
{\'N2\': 0.7670829987741036, \'O2\': 0.23291700122589645}
The output obtained for N2 and O2 are the mass fraction values respectively.
3. What is happening in lines 15 and 16? Make sure you explain what 1546 means? Is that reasonable?
Ans: In line 15, the temperature, pressure and the mole fraction values for gas object B. 1546 represents the number of moles of the object. Any value can other than 0 or negative numbers can be assigned to CH4 as object B contains only one element. B.moles = 1 indicates that one mole of B is taken or considered.
4. What changes do you need to put in place to get the right value of AFT in line 22?
Ans: To get the right value of AFT, we need to set A.moles to 9.52.