Cantera Flamelet Generation

A two-point flame control method is implemented in Cantera, which mirrors the standard arclength continuation methods that are used in codes such as FlameMaster. The two-point flame control method is used to generate flamelets that are along the unstable burning branch of a counterflow diffusion flame.

The Flamelet Table Tool can read in these Cantera flamelets and generate flamelet tables.

The flamelet generation script is located in the utilities/cantera_flamelet_generator directory of the Flamelet Table Tool. The script is called flamelet_gen.py. The script takes 1 argument, which is the name of the control file.

When generating a flamelet table using Cantera flamelets, a few extra Flamelet Table Tool control file options are required. These options are:

Extra control file options required for generating flamelet tables using Cantera flamelets.
FLAMELETTYPE Cantera
FUEL H2
Z_PRUNE_THRESHOLD 1e-3

The FUEL is simply the species that is the fuel in the counterflow diffusion flame. The Z_PRUNE_THRESHOLD is the threshold value that is used to reduce the size of the Cantera flamelets. Cantera solves the counterflow diffusion flamelet in the physical domain, which means that the strained flame becomes very thin and as such, much of the 1D domain is either pure fuel or oxidizer with a thin flame zone. The threshold value is used to remove data points that are below/above this threshold value on the fuel/oxidizer side of the flamelet, respectively.

Cantera Control File

A simple YAML control file is used to specify the inputs for the flamelet generation process is shown below. We will use this example to explain the various options that are available in the control file.

Sample control file for generating flamelets using Cantera.
# A run using the same setup as a known case that was run using FlameMaster, for the
# purposes of comparing the final results.

# Input parameters
p: 5.4e6  # pressure [Pascals]
fuel_inlet_temp: 800.0  # fuel inlet temperature [Kelvin]
oxidizer_inlet_temp: 711.0  # oxidizer inlet temperature [Kelvin]
fuel_mdot: 0.05 # kg/m^2/s
oxidizer_mdot_factor: 1.0  # Factor to adjust oxidizer mass flow rate
width: 20.0e-3 # Distance between inlets [m]

# Mass Fraction composition
oxidizer_composition: 'O2:0.9449, H2O:0.0551'  # oxidizer composition (right)
fuel_composition: 'H2:0.4018, H2O:0.5982'  # fuel composition (left)

# Reaction mechanism
mechanism: 'mechanism/H2.yaml'

# Solver settings
steady_tolerances:
   relative_tolerance: 1e-6
   absolute_tolerance: 1e-9

refine_criteria:
   ratio: 15
   slope: 0.25
   curve: 0.08
   prune: 0.04

# Two-Point Controls
spacing: 0.97
initial_temperature_increment: 20
maximum_temperature_increment: 20
temperature_increment_growth_rate: 1.08 #Give this as a factor where 1.02 would be a 2% increase per iteration
maximum_change_in_max_temperature: 60  # This prevents the maximum flame temperature from dropping too fast
increment_direction: decreasing # Valid values are 'increasing' or 'decreasing'

# Diagnostics
log_level: 0  # amount of diagnostic output (0 to 9)
generate_diagnostics: True

# Restart
restart: flamelet_205.yaml

Below is a table that summarizes what each input parameter does:

Input Parameter

Description

p

Pressure in Pascals

fuel_inlet_temp

Fuel inlet temperature in Kelvin

oxidizer_inlet_temp

Oxidizer inlet temperature in Kelvin

fuel_mdot

Fuel mass flow rate in kg/m^2/s

oxidizer_mdot_factor

Factor to adjust the oxidizer mass flow rate (default is same velocity as fuel stream)

width

Distance between inlets in meters

oxidizer_composition

Oxidizer composition (right) in mass fractions, in a dictionary form

fuel_composition

Fuel composition (left) in mass fractions, in a dictionary form

mechanism

Path to the reaction mechanism file (YAML mechanism file)

eos

Equation of state (default is ‘ideal-gas’, can also be ‘peng-robinson’)

steady_tolerances

Tolerances for steady-state solver (same as Cantera’s steady tolerances)

refine_criteria

Criteria for refining the flamelet solution (same as Cantera’s refine criteria)

continuation

Flag for whether to perform automatic continuation (valid values are ‘true’ or ‘false’, default is ‘true’)

spacing

Percentage of maximum flame temperature where control points will be located

initial_temperature_increment

Starting temperature increment between flamelet solutions

maximum_temperature_increment

Maximum allowable temperature increment between flamelet solutions

temperature_increment_growth_rate

Growth rate of temperature increment allowed per iteration

maximum_change_in_max_temperature

Maximum change in maximum flame temperature

increment_direction

Direction of temperature increment (valid values are ‘increasing’ or ‘decreasing’, default is ‘decreasing’)

log_level

Amount of diagnostic output (based on Cantera’s loglevel)

generate_diagnostics

Whether to generate diagnostics

restart

Path to the restart file

The maximum_temperature_increment input variable is related to the temperature decrement that is attempted during a two-point flame control solution. This is the amount by which the code will attempt the lower the temperatures at the control points. Larger values can be unstable, so the user can set a maximum allowable temperature decrement. The temperature_increment_growth_rate is a factor that is used to increase the temperature increment between flamelet solutions. This is useful for speeding up the flamelet generation process. The maximum_change_in_max_temperature is used the prevent the maximum flame temperature from dropping too fast between two flamelet solutions. This occurs often during the march down the unstable burning branch of the counterflow diffusion flame, so this option allows a user to have more points along the unstable burning branch.

If the generate_diagnostics option is set to True, the flamelet generator will create an output folder that contains plots of the flamelet solution variables for each flamelet solution. This is useful for diagnosing issues with the flamelet generation process.

The solver is often run starting from a solution that is on the burning branch. When Cantera is generating solution along the stable burning branch, the two-point flame control method is not enabled and successive solutions are simply generated by increasing the mass flow rates of the fuel and oxidizer streams. At some point, the solver will be unable to generate any more non-extinguished solutions, and the flamelet generation script will switch to the two-point flame control method to march down the unstable branch. If an error occurs during the flamelet generation process, a user would have to restart the entire process starting on the burning branch again. The restart option allows a user to restart the flamelet generation process from an existing flamelet solution. This flamelet generation script will load this solution and activate the two-point flame control and continue the marching process of lowering the flame temperature.

The numerical solver options for Cantera can be set by providing the steady_tolerances and refine_criteria options. The steady_tolerances option control the convergence criteria for the Cantera 1D flame solver. The refine_criteria option controls the criteria for refining the flamelet solution. This controls how additional points are place dynamically in the solution during the generation of each solution. Cantera defines the refinement options as:

Refinement Parameter

Description

ratio

Maximum ratio between grid spacing at adjacent intervals. E.g. (x[j+1] - x[j]) / (x[j] - x[j-1]) < ratio

slope

Maximum fractional change in the value of each solution component between adjacent grid points

curve

Maximum fractional change in the derivative of each solution component between adjacent grid points.

prune

Threshold for removing unnecessary grid points. prune should be smaller than both slope and curve. Set prune <= 0 to disable pruning.

The refiner can often add many additional points to the domain in the region where the solution is essentially constant (due to the flame being very thin). Adjusting the refinement criteria can help to keep the number of points in the domain to a minimum and to cluster them where they are needed most in the regions where the solution is changing rapidly in the vicinity of the flame. The values that are shown the sample YAML control file above are good starting values for the refinement criteria. The user may need to adjust these values based on the flamelet solutions that are generated.

Real-Gas Simulation

If the eos option is set to peng_robinson in the flamelet generator control file, then the script will attempt to extract the Peng-Robinson parameters from Cantera. To have Cantera use the cubic Peng-Robinson equation of state, the input YAML mechanism file must have the Peng-Robinson value set for the thermo attribute.

Example of a Cantera YAML mechanism file with Peng-Robinson equation of state specified.
 phases:
 - name: gas
     thermo: Peng-Robinson
     elements: [N, O, H]
     species: [N2, O2, H, OH, O, H2, H2O, HO2, H2O2]
     kinetics: gas
     reactions: all
     transport: mixture-averaged
     state:
       T: 300.0
       P: 1.01325e+05

The current default behavior of Cantera when the Peng-Robinson equation of state is specified is to search the input YAML file for either the critical-parameters attribute with the critical-temperature, critical-pressure, critical-volume, critical-compressibility, and acentric-factor defined under that attribute.

Example of a Cantera YAML mechanism file with critical parameters specified.
 species:
 - name: N2
   composition: {N: 2}
   thermo:
     model: NASA7
     temperature-ranges: [300.0, 1000.0, 5000.0]
     data:
     - [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12,
       -1020.8999, 3.950372]
     - [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15,
       -922.7977, 5.980528]
   transport:
     model: gas
     geometry: linear
     diameter: 3.621
     well-depth: 97.53
     polarizability: 1.76
     rotational-relaxation: 4.0
   critical-parameters:
     critical-temperature: 126.19
     critical-pressure: 3.3958e6
     critical-molar-volume: 0.543
     critical-compressibility: 0.253
     acentric-factor: 0.445
   note: '000000'

If the critical parameters are not found in the input YAML file, the Cantera will search for the equation-of-state attribute with the a, b, and acentric-factor defined under that attribute. For gas species that are ideal, specifying the a and b parameters to be 0.0 will result in that species being treated as ideal in the mixture Peng-Robinson equation of state.

Example of a Cantera YAML mechanism file with equation of state parameters specified.
 - name: H
   composition: {H: 1}
   thermo:
     model: NASA7
     temperature-ranges: [300.0, 1000.0, 5000.0]
     data:
     - [2.5, 0.0, 0.0, 0.0, 0.0, 2.547162e+04, -0.4601176]
     - [2.5, 0.0, 0.0, 0.0, 0.0, 2.547162e+04, -0.4601176]
   transport:
     model: gas
     geometry: atom
     diameter: 2.05
     well-depth: 145.0
   equation-of-state:
     model: Peng-Robinson
     a: 0
     b: 0
     acentric-factor: 0

As a final search, Cantera will look for a file named critical_parameters.yaml in the same directory as the input YAML mechanism file. This file is provided by Cantera and is located in the data/ of Cantera. It has a collection of critical parameters for many species, but it is not exhaustive, so additional entries may need to be added.

Note: Critical pressures are given in Pa, critical temperatures are in Kelvin, and critical volumes are given in m^3/kmol.

Pruning Flamelets

In the utilities/cantera_tools/ directory there is a script that can be used to prune the flamelet solutions that are generated by the Cantera. The generation intuition is that a set of solutions that spans in the S-curve with 10 flamelets per decade of strain rate is sufficient. Often times it is difficult to set up a control file that will generate the exact number of flamelets that are needed, and so it is easier to generate more solutions than is necessary and then prune away the ones that are not needed. The pruning script is called cantera_flamelet_pruning.py. Using instructions can be seen by calling the script with no arguments. The arguments and a brief summary of them are shown in the table below.

Argument

Description

--flamelets_path

Path to the flamelet solutions (can be absolute or relative)

--minimum_arclength

Flamelet solutions that are closer together than this distance are removed.

--output_dir_name

Directory where the pruned flamelet solutions will be output to

The arclength is computed from the maximum temperature versus mean strain rate plot of all of the flamelet solutions. The arclength is the simple euclidean distance between two points on the S-curve. The script will remove flamelet solutions that are closer together than the minimum_arclength value.

_images/sample_cantera_s_curve_for_pruning.png

A sample S-curve for a H2/O2 reaction in the \(T_{max}\) - \(a_{mean}\) space.

General Guidance

Cantera solves the axisymmetric counterflow diffusion flame in the physical domain, and as such, the choice of the initial mass flow rates of the fuel and oxidizer streams as well as the domain width are important factors to consider. The initial solution should always be located within the domain and should not be too close to the fuel or oxidizer inlets. The flamelet generation script uses a mass flow balance to estimate the velocity of the oxidizer stream. For some cases, this will not result in a flame solution that is located away from the boundaries. In cases where the oxidizer stream needs to be adjusted, the user can add the oxidizer_mdot_factor option to the control file. This option is a factor that is used to adjust the oxidizer mass flow rate. A value of 1.0 will use the mass flow rate that is calculated by the flamelet generation script, while a value of 0.5 will reduce the oxidizer mass flow rate by half. The default value when it is not specified is 1.0.

From the literature on the two-point control method, it is suggested that the control points be located in regions of high temperature gradient. The spacing option in the control file is used to specify the percentage of the maximum flame temperature where the control points will be located, which dictates how far from the peak the control points will be located. In some cases a lower value may be better for flames during the low strain-rate regime, while a higher value may be better for flames during the high strain-rate regime. The user may need to adjust this value based on the flamelet solutions that are generated.

If the flamelet generator is started from scratch on the burning branch, then at the end, it uses the history of the traversal of the S-curve to compute an extinction flamelet by taking the highest strain solution, and then increasing the strain past that point and calling the Cantera solver. This is what generates the flamelet_0.yaml file. When restarting, this final action will not be performed as the code does not have the full history from which to estimate the highest strain rate. Under these conditions, a single extinction flamelet can be generated by setting the continuation option to false in the control file. This disables the two-point control method and simply generates a single flamelet solution based on the inputs given in the control file (for an extinction flamelet, the mass flow rates need to be set high).