Project

Handling Mixture with cantera

The stoichiometric chemical equation of methane is

\"CH4 + 2(O2 + 3.76N2) = CO2 + 2H2O + 7.52N2\"

  1. In, TPX - T, P are the temperature, pressure and X- is the dictionary which gives the information about the mole fraction. The summation of the all mole fraction should be equal to 1.
    \"mole fraction = no.of moles of a component / total no of the moles\"
    so, mole fraction of O2 is => 0.21 = no.of moles of O2(=2)/ total no of moles
    hence, total no of moles = 2/0.21. Hence, A.moles is \'2/0.21\'.

  2. A.mass_fraction_dict() gives the values of mass fractions for every gas present in the object \'A\'. Here, \'print(A.mass_fraction_dict())\' prints the mass fraction of the oxygen (O2)and the nitrogen(N2).
  3. In those lines, we are going to set the values of the temperature(T), pressure(P) and mole fraction(X) in the object \'B\' and total no of moles at object B is given as 1. \'1546\' is a random number which can be replaced by the accuarate value of the CH4. It doesnt make any mole fraction because we had defined the number of moles in B.moles command.
  4. In order to get accurate AFT value, we need to assign correct value for no of moles for the object \'A\' at \'A.moles\' command which is 2/0.21 which is calculated above. Hence, the result(2224.224 K) that obtained is accurate.

Code:

\"\"\"
sample code to vary the temperature
Here the chemical equation is 
CH4 + 2(O2+3.76N2)  = CO2+ 2H2O + 7.52N2
\"\"\"
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 = 2/0.21
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\')
print(M.T)

Result:

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.