Challenge

Week 4.1- Handling Mixtures with Cantera

AIM

To work on the quantity class of the Cantera to create various mixtures.

Objective

Perform calculation of the adiabatic flame temperature of a gas mixture using quantity class.

1) Use the "moles" method/function of the A object(air) and explain how it was calculated.

Now consider any hydrocarbon (fuel) reaction with air. The equation is written as

`C_xH_y +b(O_2+3.76N_2) -> xCO_2 +(y/2)H_2O + 3.76 bN_2`

here,

mole-fraction for air is = b/(b+3.76b) = 0.21 (One mole of air contains 0.21 moles of oxygen)

Methane at stoichiometric condition b=2 and 2/0.21 =9.52 moles of air

Python code for calculation for Mass and Mole Fraction of Air

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}


print('number of moles of air = ',air.moles)
print('mole fraction of air = ',air.mole_fraction_dict())
print('mass fraction of air = ',air.mass_fraction_dict())

Output

The Gas object is created for solving the problems related to combustion. Air is created with quantity class defined at STP condition. Then in the print command, we tell the Cantera to execute the code.

if we take one mole of the oxygen we can say,

Mass of one mole of diatomic oxygen O2 = 32 grams

Mass of one mole of diatomic nitrogen N2 = 28 grams

Mass of air can be then defined as the mass of air = 0.21*32 + 0.79*28 = 28.84

mass fraction of oxygen = 0.21*32/28.84 = 0.23

mass fraction of nitrogen = 0.79*28/28.84 = 0.77

"""
Handling Mixtures using Cantera
"""

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
print('Mole fraction in air=',air.mole_fraction_dict())
print('Mass fraction in air=',air.mass_fraction_dict())


fuel = ct.Quantity(gas)
fuel.TPX = 298.15,ct.one_atm,'CH4:1546'
fuel.moles = 1
print('Mole fraction of fuel=',fuel.mole_fraction_dict())

M = air+fuel
air.constant = 'HP'
fuel.constant = 'HP'
M.equilibrate('HP')
print('Value at AFT=',M.T)

here the result can be seen and the output temperature and can be seen as 2224.41K

2. Use the method mole_fraction_dict() of the Air object and explain the result that you get. Here is how you need to use it. print(A.mass_fraction_dict())

This method has been used in the above-written code and we get output as:

For mass fraction: No of moles X No of moles of the compound with molecular weight.

Number of moles of O2 = 2X32=64 gms

Number of moles of N2 = 7.52X28=210.56 gm

Mole-fraction of O2 = 64/(64+210.56) = 0.23

Mole-fraction of N2 = 210.56/(64+210.56) = 0.77

3) What is happening in lines 15 and 16 on the sample Code? and what 1546 means?

In line 15, we are defining the fuel (CH4) with pressure, temperature, and mole-fraction values, and no. of moles are defined so as to avoid any pre-defined values assumed by the software.

Also, as CH4 is only the gas defined hence it has no. of moles and mole-fraction as 1. Therefore, defining 1546 has no effect as it gives the value of mole-fraction as one.

4. What changes do you need to put in place to get the right value of AFT in line 22?

As the mole-fraction is known we just need to define the no. of moles gas object air

2/0.21 each for O2 and N2 = 9.52 with command as air.moles = 9.52 as written in the program.

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.