Challenge

Week 4.1- Handling Mixtures with Cantera

HANDLING MIXTURES WITH CANTERA

AIM: To work with the Quantity class of Cantera to create various mixtures and explain how the mixture calculations are performed.

OBJECTIVE:

  • Explain how the mixture calculations are performed.
  • Using the above image answer and solve the following questions
  • Use the "moles" method/function of the A object and explain how it was calculated. You need to use this after line number 9.

    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())

    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.

SOLUTION AND ANSWERS:

Questions and answers:

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

The mole's function defines the number of moles of object A (comprised of the species O2 and N2). By basic chemistry, we arrive at the number of moles of A -

xO2=nO2nO2+nN2=nO2nairxO2=nO2nO2+nN2=nO2nair

At STP, the oxidizer air contains 21% O2 and 79% N2. This has been provided as an input to the TPX method. To calculate the number of moles of air that is needed for mixture handling, we assume that the methane combustion is stoichiometric.

Thus, substituting the values in the above equation, we get

0.21=2nair0.21=2nair

⇒nair=9.52⇒nair=9.52

This can also be obtained from the balanced equation of stoichiometric methane combustion i.e.

CH4+2(O2+3.76N2)→CO2+2H2O+7.52N2CH4+2(O2+3.76N2)→CO2+2H2O+7.52N2

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())

This function calculates the mole fraction(mass fraction) of the species.

When used as a print(A.mass_fraction_dict()), it calculates the mass fraction of the species in object A. This is calculated as given in the below table

Species Mole fraction Number of moles Mass Mass fraction
O2O2 0.21 0.21*9.52 = 1.9992 ≈≈2 2*32 = 64 64/(64+210.56)= 0.2331
N2N2 0.79 0.79*9.52 = 7.52 7.52*28 = 210.56 210.56/(64+210.56) = 0.7668

Thus, the number of moles of air provided as an input is used for calculating the mass fractions.

3. What is happening in lines 15 and 16? Make sure you explain what 1546 means? Is that reasonable?

In line 15, we are assigning the initial conditions of object B (fuel). The formate for this is the temperature (in Kelvin), pressure(in Pascals), mole fractions. If there are multiple species to be defined in object B, we can use a dictionary to define them using their mole fractions. However, since we only have considered 1 species (i.e. CH4) we don't need to use dictionary format. Also, because there are only 1 species the mole fraction of CH4 is 1 by default.

The number 1546 is just an arbitrary number. It must be noted that 0 is not acceptable.

In line 16, we assign the number of moles of object B.

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.

AFT temperature depends on the number of moles of fuel (object B) and oxidizer (object A) which react at constant pressure.

Thus, we need to provide the correct number of moles for both objects. The number of moles of object A is thus defined at line 10 as

A.moles = 9.52

This gives the correct value of AFT for Methane combustion.

Code:

"""
Sample code to vary the temperature of air 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 = 9.52

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

A.constant = B.constant = 'HP'
M = A + B

M.equilibrate('HP')

print(M.T)

Conclusion

The correct value for temperature has been arrived at using the 'Quantity' class to create the air-fuel mixture in Cantera.

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.