Mixture fraction for chemical equilibrium

300 views
Skip to first unread message

Gavin

unread,
Mar 22, 2022, 9:08:19 PM3/22/22
to Cantera Users' Group
I have an example shown below where I plot the mass fraction Y for a range of mixture fractions using the equilibrate method (chemical equilibrium). The results look reasonable but I want to make sure I understand what the code is doing. Some questions I have are:

1. For the fuel and air concentrations (yfuel and yair), the composition is given as a mass percent. It appears that Cantera automatically converts these values to mass fractions such that sum(yfuel) = 1 and sum(yair) = 1. Is that correct?

2. In my example, I create a range of mixture fractions from 0.1 to 0.9 using np.linspace(0.1, 0.9). Each value in that range is used to set the mixture fraction. If gas.set_mixture_fraction(0.2, yfuel, yair, basis='mass'), then does this mean that 20% of the mixture is yfuel and 80% of the mixture is yair?

3. In the example, I loop through the mixture fractions then run the equilibrate method. Is there a way to set the mixture fractions with SolutionArray so I can avoid using the for-loop? For example, SolutionArray.set_equivalence_ratio allows me to set a range of equivalence ratios without using a for-loop but I don't see a similar method for mixture fraction.

import cantera as ct
import matplotlib.pyplot as plt
import numpy as np

# Parameters ------------------------------------------------
yfuel = {'C': 43.41, 'H': 5.82, 'O': 44.32, 'N': 0.25} # mass percent
yair = {'O2': 23, 'N2': 76, 'Ar': 1} # mass percent
mixfrac = np.linspace(0.1, 0.9, 20)

# Equilibrium calculations ----------------------------------
gas = ct.Solution('gri30.yaml')
gas.TP = 900, ct.one_atm

# Store mass fractions
yCH4 = []
yCO = []
yCO2 = []
yH2 = []
yH2O = []
yO2 = []

for mf in mixfrac:
    gas.set_mixture_fraction(mf, yfuel, yair, basis='mass')
    gas.equilibrate('TP')
    
    yCH4.append(gas.mass_fraction_dict()['CH4'])
    yCO.append(gas.mass_fraction_dict()['CO'])
    yCO2.append(gas.mass_fraction_dict()['CO2'])
    yH2.append(gas.mass_fraction_dict()['H2'])
    yH2O.append(gas.mass_fraction_dict()['H2O'])
    yO2.append(gas.mass_fraction_dict()['O2'])

# Plot ------------------------------------------------------
_, ax = plt.subplots(tight_layout=True)
ax.plot(mixfrac, yCH4, marker='s', label='CH4')
ax.plot(mixfrac, yCO, marker='p', label='CO')
ax.plot(mixfrac, yCO2, marker='o', label='CO2')
ax.plot(mixfrac, yH2, marker='^', label='H2')
ax.plot(mixfrac, yH2O, marker='*', label='H2O')
ax.plot(mixfrac, yO2, marker='v', label='O2')
ax.set_xlabel('Mixture fraction [-]')
ax.set_ylabel('Mass fraction [-]')
ax.legend()

ax.grid(True, color='0.9')
ax.set_frame_on(False)
ax.tick_params(color='0.9')

plt.show()

Thorsten Zirwes

unread,
Mar 28, 2022, 8:57:10 PM3/28/22
to Cantera Users' Group

1) Yes, if you call set_mixture_fraction (or any other function that sets the mixture composition), Cantera will usually normalize everything internally to sum up to unity, so for example gas.TPY = 300,1e5,{"H2":50,"O2":50} is the same as specifying {"H2":1,"O2":1} or {"H2":0.5,"O2":0.5}.

 

2) Yes, "gas.set_mixture_fraction(0.2, yfuel, yair, basis='mass')" means:

0.2 is the mixture fraction, which in this context always means "mass of fuel divided by mass of the whole mixture" or mass-% of fuel in the mixture.

The basis='mass' means that yfuel and yair are both interpreted as mass fractions (as opposed to mole fractions). You can find more details here: https://github.com/Cantera/cantera/blob/main/interfaces/cython/cantera/thermo.pyx#L959  and  https://cantera.org/documentation/docs-2.5/doxygen/html/dc/d38/classCantera_1_1ThermoPhase.html#aacd7d8cd0d941755bdd9f13f163d09ab

 

3) set_mixture_fraction seems not to be available for SolutionArray at the moment (only set_equivalence_ratio is https://github.com/Cantera/cantera/blob/3a30e3b68fbfaea6b5a61a6e507c09b245f095d6/interfaces/cython/cantera/composite.py#L987)

Reply all
Reply to author
Forward
0 new messages