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