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.
