Handling Mixtures with Cantera
Question
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’
Hint : For the analytical part you need to calculate the number of moles in 1g of Air.
2. Use the method mass_fraction_dict() of the A object and explain it analytically
Hint : Here is how you use it. print(A.mass_fraction_dict())
3. What is happening in lines 15 and 16? Make sure you explain what 1546 means. Is that reasonable?
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.
Answer
A lot of times in interviews, you are asked questions that look very confusing and meaningless. Unnecessary information would be added to the question to make you panic. This is one such Assignment and there is a simple answer to this assignment.
In straight, the question is what is the total number of moles of air required for the stoichiometric combustion of Methane?
So, the total number of moles of air is 2+2(3.76) = 9.52
This has to be specified as the number of moles of air in the code so as to get the right AFT.
import cantera as ct
import matplotlib.pyplot as plt
import math
import numpy as np
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
b=ct.Quantity(gas)
b.TPX=298.15,ct.one_atm,{'CH4':1}
b.moles=1
mixture=a+b
mixture.equilibrate('HP')
print(mixture.T)

The Adiabatic fuel temperature is 2224.411
print(a.mass_fraction_dict())
Adding the above line in the code gives us the mass fraction of species in the air as

Analytically this can be obtained as follows
Mass of Oxygen in the stoichiometric reaction is 2*32=64
Mass of Nitrogen in the stoichiometric reaction is 2*3.76*28=210.56
Mass Fraction of O2 = 64/274.56=0.233
Mass fraction of N2=210.56/274.56=0.766
-> The number 1546 has no significance, it was added to the question just to confuse the reader and waste his/her time. The mole fraction can never be greater than 1. Also, when there is only one species, the mole fraction will always be one.