Updated August 21, 2024 Authored by Chris Cloney
Have you ever tried using the chemkin openFoam converter (chemkinToFoam)?
From searching online people have had problems with both the conversion steps and interpreting the simulation results. This post demonstrates how to use chemkinToFoam to convert the GRI-Mech 3.0 mechanism to openFoam format, and the thermodynamics and reaction data files with the OpenFOAM format. A video showing the process is given below, followed by a description of some of the input format problems and assumptions.
Video showing how to use chemkin openFoam converter (chemkinToFoam)
Methane Flame Test Case
The test case used in the video is a one-dimensional methane flame. The equivalence ratio is 0.8 and the initial conditions are computed using Cantera. This solution is interpolated onto the openFoam mesh and stored in the \0 folder. A future post will explain this process in more detail for those who are interested.
Download the test case using this link:
Test Case: Methane Flame With 0.8 Equivalence Ratio
Copy the files and use the command “tar -xvzf Chemkin-OpenFoam-Methane-Flame-Simulation.tar.gz” to unzip the folder
This test case uses the Gri-Mech 3.0 kinetic mechanism. This detailed mechanism contains 325 reactions and 53 species. The chemistry file (grimech30.dat) and thermodynamics file (thermo30.dat) can be retrieved from the Gri-Mech 3.0 Website.
Input File Format Problems
In order to use the chemkin openFoam converter, two changes to the input format are needed:
- Replace THERMO with THERMO ALL in thermo30.dat
- Search and replace CH2(S) to CH2S in both files
I am not sure why chemkinToFoam is expecting THERMO ALL in the header, but this change is needed for the files to convert. The parser does not like brackets in the species names, so these must be changed as well. After fixing the format issues use the command “chemkinToFoam grimech30.dat thermo30.dat grimech30_foam.dat thermo30_foam.dat” to convert the files.
Other Problems and Assumptions
There are two other things to keep in mind when using files converted with chemkinToFoam:
- Not all chemkin files are in the correct format for the converter
- Viscosity, thermal conductivity, and diffusivity properties are not taken from the thermodynamics file
Some reaction mechanisms given in chemkin format do not actually contain the reaction rate constants (e.g., Lu and Law 19). These files require a second converter and cannot be used directly with the openFoam converter. Also, there are complaints online about converting files with older chemkin formating rules. I have not tested any of these to date.
The second problem involves the treatment of thermodynamic properties in openFoam. The following figure shows the converted openFoam thermo file. Note that the Sutherland parameters are the same for each specie. These parameters appear to be hard-coded in the converter and are not taken from the input thermodynamic data file.
The Sutherland parameters are used to calculate fluid viscosity in openFoam. This parameter is then used to calculate thermal conductivity and diffusivity. Both the constant values used for calculating viscosity, and the assumptions used to determine conductivity and diffusivity will impact the accuracy of the flame simulation.
Typical Methane Burning Velocity Results with OpenFoam
Methane flame simulations were completed using the chemistry mechanisms Gri-mech 3.0, Lu and Law 19, BFER2, MP1, and DRM19 found at the following links: GRI-Mech 3.0, Lu and Law Reduced Mechanisms, Cantera User Guide, and Kazakov and Frenklach. In all cases the therm30.dat thermodynamics file from the gri-mech 3.0 mechanism was used. It appears that this file is sufficient to use for most reaction mechanisms, although this has not been tested extensively.
Typical flame speed results are summarized in the following plots. The cantera simulation results are shown on the left and openFoam results with the same mechanisms on the right. Cantera uses an adaptive meshing procedure, while the openFoam mesh varied between 50 and 25 micron resolution.
The differences in flame speed between Cantera and OpenFoam appear to be due to the thermal conductivity and mass diffusivity assumptions. These will be reviewed further in another post, but the interested reader can refer to the CFD-online post here: “Difficulties with premixed laminar methane flame in openFoam“. In addition here is the weblink for Description Convert CHEMKINIII thermodynamics and reaction data files into OpenFOAM format and the free software foundation.
If you have any questions or would like more information on the problem setup and results, leave a message below or reach out to me on the contact page. You can also email me direct at:
Email: [email protected].
Disclaimer: The chemkinToFoam utility in OpenFOAM, a powerful open source CFD toolbox, provides users with the ability to convert ChemkinIII thermodynamics and reaction data into the OpenFOAM format. This ensures that reaction data files and thermo file information are compatible with OpenFOAM, facilitating the simulation of combustion and other chemical processes. The tool reads the Chemkin thermo file, converting it into a new format suitable for OpenFOAM simulations, with advanced features such as the registered debug switch, registered optimisation switch, and registered info switch that allow for fine-tuning the conversion process. These switches offer users exit compatibility options and precise control over the parameters and value of the files during the conversion.
The chemkinToFoam utility not only manages the conversion of specie composition data and thermodynamics structure from a Chemkin file but also integrates Janaf coefficients for accurate thermodynamic modeling. Through advanced options, users can configure const word, int argc, and other arguments within the arglist args framework to handle thermodynamics and reaction data with precision. Additionally, the tool includes a library list that supports integration with an additional library for enhanced functionality, allowing for the complete processing of chemical reactions in CFD simulations. For user assistance, short help and full help outputs are provided, offering essential notes and guidance on using the tool effectively, especially when dealing with the conversion of chemkin file and its associated files in the new format.
As part of the Free Software Foundation‘s mission, chemkinToFoam is licensed under the GNU General Public License, enabling users to redistribute and modify the software under its terms. The license covers all files and code, including files in the new format, but it comes with even the implied warranty disclaimer that excludes any guarantee of suitability for a particular purpose. This allows for flexibility in how users implement the software in various case directories and ensures complete integration of chemkiniii thermodynamics and reaction data with the OpenFOAM system. The display help notes and display documentation functions are also available for quick reference, helping users navigate the utility’s complex processes, including the conversion of thermo files and the handling of multiple reaction mechanisms.
Despite the inherent disclaimers of free software, the chemkinToFoam utility provides a robust solution for converting thermodynamics and reaction data from the chemkin format to the OpenFOAM format. It is designed to be used multiple times within simulation workflows, ensuring that all files are properly processed and integrated into the case directory. With support for browser functions, advanced options, and full documentation, users can effectively manage their reaction data files and optimize their simulation environments. By handling thermo files in the new format, the tool achieves complete integration within OpenFOAM, offering users a reliable and flexible method to handle chemical reactions and species in their CFD applications.