Getting Chemkin reaction mechanisms to work in OpenFOAM

Although Chemkin files (that is, the reaction file usually called “chem.inp” and the thermodynamics file usually called “therm.dat”) are mostly compatible with OpenFOAM thanks to the OF utility chemkinReader, certain Chemkin functionalities and conventions are unrecognized and cause OF to crash.

Some of these functionalities, such as the keyword PLOG for pressure-dependent coefficients, are simply not supported – so if you need them, and have the time and patience, go ahead and implement them in your own version of chemkinReader!

Other errors are caused by different conventions for writing the same thing, or comments in the Chemkin files. Luckily, these errors can be fixed by altering the Chemkin files in a text editor, without changing any information about the chemistry itself.

The following is a (very non-exhaustive) list of simple fixes to try if OF crashes when it tries to read your Chemkin files. With these fixes, I have managed to get Hai Wang’s HyChem mechanisms (https://web.stanford.edu/group/haiwanglab/HyChem) to work. Other mechanisms may require further steps not listed here.

  • Make sure you have a transportProperties file in the /chemkin directory. This file HAS to be in the OF format. If you don’t have transport data for the species in your reaction mechanism, you can take the generic transportProperties from the aachenBomb tutorial. It gives all species the same coefficients, though this is of minor importance in my experience.
  • Make fresh “chem.inp” and “therm.dat” files and paste all the corresponding text from your Chemkin files into them. This ensures that there is no embedded information to confuse chemkinReader.
  • The thermodynamics file should begin with “THERMO ALL” and end with “END”.
  • Each species in the thermodynamics file has four rows dedicated to it. The first contains the species name and some parameters, while the remaining three contains polynomial coefficients for computing specific heat capacity, enthalpy, and entropy as a function of temperature. The last column keeps track of which row is which: it should go “1; 2; 3; 4; 1; 2; 3; 4; 1…” and so on. Sometimes though, and I don’t know why, the “1” is some other number like 31. If that’s the case, change it to 1.
  • All keywords (“DUPLICATE”, for example) need to be written in capital letters.
  • OF might complain about an “element imbalance”. This means that the elements on each side of one of your reactions don’t add up. Of course, in general, they should add up perfectly. Some reaction mechanisms (HyChem, for example) may however contain model species that are supposed to represent a mixture of molecules, which can lead to small imbalances. The default tolerance is really tiny though. Solve the problem by including “imbalance tolerance <some number>;” on a new line in constant/thermophysicalProperties. Only set the tolerance as high as you need it to be.
  • Some characters or words in the Chemkin files can lead to a crash, even if they are part of comments. If in doubt, remove any comments that you think might be causing trouble. When chemkinReader crashes, it tells you which line the error was encountered on, so remove all comments near that line and see if that solves the problem.
  • The coefficients in the reactions file should be preceded by a minus sign when negative, but sometimes they are also preceded by a plus sign when positive. Remove all such plus signs.
  • Even if chemkinReader manages to load your files, you may notice that the temperature in your simulation is capped at some number like 2000 K. You will also notice a warning along the lines of “attempt to use janafThermo out of temperature range 200 -> 2000″. This happens because you have reached the upper temperature bound of one of the species in your thermodynamics file. The temperature bounds are given on the same line as the species name (the same line that SHOULD end with a 1”. The upper bound is the highest of these number, usually the last or the second last one. Simply increase it to some number that you will not reach in your simulation, and you’re good to go. I know, I know – this feels like we’re breaking the reaction mechanism. But from what I gather, this is how it’s done in Chemkin. I have compared mathematically identical simulations in both Chemkin and OpenFOAM using this trick and the results are identical.