Challenge

 HANDLING COMBUSTION MIXTURE WITH CANTERA

HANDLING COMBUSTION MIXTURE WITH CANTERA

l. OBJECTIVE:

Write the code to calculate the properties of Air-Fuel Mixture by varying the properties of air and fuel individually.

ll. EXPLANATION:

1)

For the combustion of methane in the air, we know that the ideal reaction must be:

`CH_4+2(O_2+3.76N_2)rarrCO_2+2H_2O+7.52N_2`

Generally, the air and fuel are mixed at the same conditions before entering into the furnace. However, sometimes they are mixed at different conditions. One such condition includes preheating the air before the combustion. For such a scenario, we need to model the fuel(methane) and the oxidizer(air) individually at their respective specified conditions. For This Purpose, we use the Quantity class in Cantera to create the mixture. The starting code (before debugging) is shown below:

The above code returns the AFT as 374.14 K which is clearly wrong. This is because the number of moles of quantity A is not specified. For specifying the number of moles, we look at the stoichiometric reaction-we need 2 moles of `O_2` for 1 mole of `CH_4`. Now,`O_2` being part of the air with a mole fraction of 0.21, we can use the definition of mole fraction as:

Mole Fraction of `O_2= (text(Moles of )O_2)/(text(Total moles of air))`

`0.21=2/text(Total moles of air)`

Total moles of air`=2/0.21`

The above can be applied more generally by using the mole_fraction_dict() method of A. If we use the following 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}
print(A.mole_fraction_dict())

we get output as:

{'N2': 0.79, 'O2': 0.21}
[Finished in 1.8s]

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

2)

The mole_fraction_dict() is a dictionary object and we can use it to call the mole fraction of any element specified in the mixture. Hence, instead of using 0.21 directly as the mole fraction of`O_2`, we will use the dictionary object to call the mole fraction of `O_2` from the quantity A as:

A.moles = 2/A.mole_fraction_dict()['O2']

Now, looking at quantity B, we see that it contains only one compound in the mixture- `CH_4`. We need 1 mole of `CH_4` for the reaction, which is specified with the B.moles function.

On line 15, we can see the dictionary of the mole fraction as {'CH4':1546}. Technically, this is correct because Cantera will reduce the numbers provided in this dictionary to their respective mole fractions by dividing the quantity on the RHS of each compound in the mixture by the total sum of RHS of all the compounds. SO if you enter

A.TPX = 298.15,ct.one_atm,{'O2':2,'N2':7.52}

the above statement is equivalent to:

A.TPX = 298.15,ct.one_atm,{'O2':0.21,'N2':0.79}

Because,

mole fraction of`O_2=2/(2+7.52)=0.21`

mole fraction of`N_2=7.52/(2+7.52)=0.79`

So looking at the B quantity, we have only one compound. Hence, any number we enter in the RHS of 'CH4' will be equivalent to:

B.TPX = 298.15,ct.one_atm,{'CH4':1}

However, it is a good practice to use the mole fraction of the compounds whose total suns up to 1. This makes it easier for other people to understand your code and can lead to consistent calculations when working in a team.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

3)

Now, after making the necessary changes to the starting code, mainly:

Line 10: Specifying A.moles

Line 15: Changing mole fraction of 'CH4' from 1546 to 1

"""
 Code to vary the temperature of fuel and oxidizer individually
 """
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/A.mole_fraction_dict()['O2']
print(A.mole_fraction_dict())


B = ct.Quantity(gas)
B.TPX = 298.15,ct.one_atm,{'CH4':1}
B.moles = 1

# The following step is used to apply the right molar balance
M=A+B
M.equilibrate('HP')
print(M.T)

we get the correct AFT as 2224.22 K in output

{'N2': 0.79, 'O2': 0.20999999999999996}
2224.224370856457
[Finished in 0.9s]
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.