Challenge

Week 4.1- Handling Mixtures with Cantera

HANDLING MIXTURES WITH CANTERA

AIM:

Use the Quantity class from Cantera to create and analyze various mixtures and explain how it can be calculated analytically as well.

INTRODUCTION and THEORY:

Quantity class:

In Cantera, the Quantity class represents the specific quantity of the class Solution. It is actually created from the Solution class with mass or number of moles. The Quantity class is helpful for analyzing the resulting state of two mixed substances.

Mole fractions:

The mole fractions are useful for defining the amount of constituent present in the mixed substances and expressed in terms of the number of moles. The mole fractions range from 0 to 1.

Xi = ni / ntotal

Or

Mole fraction = Moles of i / Total number of moles

Mass fractions:

Mass fraction is the mass of constituent present in the mixtures and that are expressed in terms of mass of the elements.

Wi = mi / mtotal

Or

Mass fraction = Mass fraction of i / Total mass of mixture

CODING PROCEDURE:

  • Import Cantera as ct
  • Using the class “Solution” create an instance object gas.
  • Create a new object A with Quantity class for oxidizer
  • Define the temperature, pressure and mole fractions
  • Calculate the moles of object A
  • Create a new object B for fuel and define the necessary values
  • Mix both the A and B and equilibrate at constant pressure.
  • Print the final temperature.

CODE and RESULTS:

Question 1:

The mole function at the code defines the number of moles of A. For analytical calculation the number of moles of A is defined by:

Xo2 = no2/nair

Xo2 = Mole fraction of oxygen; 0.21 (given)

no2 = Total no of moles of oxygen

nair = Total no of moles of air

We assume that the methane combustion is in stoichiometric and STP conditions. Calculate the number of moles of air using the above equation:

0.21 = 2/nair

nair = 9.52

Question 2:

Insert the line “print(A.mass_fraction_dict())” with the code. It displays the mass fraction of the oxidizer A.

Manual calculation:

Species

Mole fraction

Total no of moles

Number of moles

MW (g)

Mass

Mass fraction

O2

0.21

9.52

1.9992

32

63.9744

0.2330

N2

0.79

9.52

7.5208

28

210.5824

0.7670

RESULT:

{'N2': 0.7670907820415769, 'O2': 0.2329092179584231}


Question 3:

In line 15 we define the Temperature, Pressure and mole fractions for the fuel B.

If we need to set values for different species we can use the dictionary format to set values of the species using their mole fractions. In our case we use only one species, CH4 which is not necessary to use dictionary format. Moreover, if only one species is defined the cantera automatically changes to default value 1. So the number 1546 is just an arbitrary number.

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

Question 4:

For calculating AFT, the number of moles of the fuel (Object B) and oxidizer (Object A) should be correct. In our code we modified and set the correct mole fractions for both the objects (A.moles = 9.52 and B.moles = 1). Now the result shows the correct value which is 2224K.

RESULT:

2224.4247741166455

CONCLUSION:

The Quantity class is used to mix the fuel and oxidizer objects together. And the logic behind the calculation is calculated analytically. The values from both the Cantera and manual calculation match with each other.

CODE:

"""
Assignment 3: Handling mixtures with Cantera
"""

import cantera as ct

gas = ct.Solution('grimech30.cti')

A = ct.Quantity(gas)
A.TPX = 298.18,ct.one_atm,{'O2':0.21, 'N2':0.79}
A.moles = 9.52
print(A.mass_fraction_dict())

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

# The following step is used to apply the right molar balance

M = A+B
M.equilibrate('HP')
print(M.T)

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.