Table of Contents
Fetching ...

ChemGen: Code Generation for Multispecies Chemically Reacting Flow Simulations

Ryan F. Johnson, Eric J. Ching, Ethan S. Genter, Joshua E. Lipman, Andrew D. Kercher, Jay Arcities, Hai Wang

TL;DR

ChemGen tackles the challenge of embedding multispecies chemistry into CFD codes by a decorator-driven code-generation workflow that outputs C++ compatible source terms, thermodynamics, and analytical Jacobians. It unifies thermodynamics fits, reaction kinetics, and time integration strategies within a single framework, validated against Cantera and demonstrated to accelerate OpenFOAM detonation simulations by about $4\times$. The approach provides explicit and implicit time integrators, robust linear solvers, and flexible code-generation mechanics that can adapt to various CFD ecosystems. This work enables more malleable, efficient, and high-fidelity chemically reacting flow simulations in practical, production-grade codes under an open license with broad extensibility.

Abstract

This paper introduces ChemGen, a software package that uses code generation to integrate multispecies thermodynamics and chemical kinetics into C+-based computational physics codes. ChemGen aims to make chemical kinetics more accessible in existing simulation frameworks and help bridge the gap between combustion modeling and computational physics. The package employs the concept of decorators which enable flexible C++ code generation to target established software ecosystems. ChemGen generates code to evaluate thermodynamic properties, chemical source terms, and their analytical derivatives for Jacobian calculations. Also included are a variety of implicit time integration schemes, linear solvers, and preconditioners. The various components of Chemgen are verified by demonstrating agreement with Cantera and/or theoretical convergence rates. Finally, we integrate ChemGen into OpenFOAM and achieve a speedup over its native chemistry solver by approximately four times. ChemGen is an ongoing project released under the NRL Open License, a source-available license provided by the U.S. Naval Research Laboratory.

ChemGen: Code Generation for Multispecies Chemically Reacting Flow Simulations

TL;DR

ChemGen tackles the challenge of embedding multispecies chemistry into CFD codes by a decorator-driven code-generation workflow that outputs C++ compatible source terms, thermodynamics, and analytical Jacobians. It unifies thermodynamics fits, reaction kinetics, and time integration strategies within a single framework, validated against Cantera and demonstrated to accelerate OpenFOAM detonation simulations by about . The approach provides explicit and implicit time integrators, robust linear solvers, and flexible code-generation mechanics that can adapt to various CFD ecosystems. This work enables more malleable, efficient, and high-fidelity chemically reacting flow simulations in practical, production-grade codes under an open license with broad extensibility.

Abstract

This paper introduces ChemGen, a software package that uses code generation to integrate multispecies thermodynamics and chemical kinetics into C+-based computational physics codes. ChemGen aims to make chemical kinetics more accessible in existing simulation frameworks and help bridge the gap between combustion modeling and computational physics. The package employs the concept of decorators which enable flexible C++ code generation to target established software ecosystems. ChemGen generates code to evaluate thermodynamic properties, chemical source terms, and their analytical derivatives for Jacobian calculations. Also included are a variety of implicit time integration schemes, linear solvers, and preconditioners. The various components of Chemgen are verified by demonstrating agreement with Cantera and/or theoretical convergence rates. Finally, we integrate ChemGen into OpenFOAM and achieve a speedup over its native chemistry solver by approximately four times. ChemGen is an ongoing project released under the NRL Open License, a source-available license provided by the U.S. Naval Research Laboratory.

Paper Structure

This paper contains 34 sections, 107 equations, 11 figures, 6 tables.

Figures (11)

  • Figure 1: ChemGen flowchart
  • Figure 2: Distribution of error, $\epsilon$, as defined in Equation (\ref{['eq:source_error']}), for ChemGen source calculations in comparison to Cantera source calculations for five tested chemical models from Table \ref{['tab:chemical models']}. The vertical dash line represents the mean of the distribution and is colored according to the corresponding model. The distribution mean, $\mu$, and corresponding standard deviation, $\sigma$, are also reported as text.
  • Figure 3: Temperature (left) and species (right) evolution for a constant volume reactor using an explicit RK4 scheme and initial conditions given in Equation (\ref{['eq:chemical_state_02']}). These results are produced using a hydrogen submodel extracted from FFCM2 Zha23. The solid lines represent the Cantera solution, and the dashed black lines represent the ChemGen solution.
  • Figure 4: Order of accuracy convergence for $\hat{\mathcal{J}_{ij}}$ when compared to $\mathcal{J}_{ij}$.
  • Figure 5: Homogeneous reactor results obtained with ChemGen's implicit time integrators
  • ...and 6 more figures