Besides the chemTable method, The NGA code is able to calculate finite rate chemistry. The source codes for the finite rate chemistry include finitechem.f90 and the mechanism-specific source codes. For example, if it is the hydrogen chemical mechanism to be used, you should include HYDROGENF.F90 in the Makefile under the /src/combustion path.
You can easily see that the HYDROGENF.F90 code computes the species, reaction and thermo data with a hard-coded way. You can automatically generate those .F90 files by FlameMaster. For example, if you want to use the GRI3.0 ChemKin mechanism to simulate a methane flame, you can use the FlameMaster CK2FM tool to convert the files into FlameMaster format.
(1) If you have a FlameMaster format mechanism rather than a Chemkin format mechanism (open the file to tell!), you shouldn’t follow the steps here, but should follow the steps in code installation!
(2) It’s very important that all the input files are match/corresponding/compatible with each other, please double check!
The detailed way to use CK2FM for mechanism format conversion is introduced in the readme file in the Readme file in the CK2FMReinh folder. The basic steps (using gri211 as an example) are:
chmod 755 maki ./maki
The result is an executable ‘ckintrp3seiser’. Then excute this executable file by
During the execution, the input is required:
thermo data file name = ?: thermo211.dat input model file name = ?: grimech211.dat interpreter ascii output file name = ?: (any filename. We will call it a.i) CHEMKIN link file name = ?: (any filename, we will call it linkfile)
Check in the bottom of the file a.i to see if there are any errors and make appropriate changes.
Then, execute two perl scripts to genearte the mech files. Start with making these executable
chmod 755 *.perl
Then execute the first script using the chemkin ascii output as
./mechi2tex.perl a.i 1 2
This produces the files a.mech and a.tex. Now continue with the file a.mech and the second perl script. Execute
./modmech.perl -t thermo211.dat -r transport211.dat -o gri.211.mech a.mech
Check the error messages and make appropriate corrections, if the script has problems reading some data. This produces a couple of files, two of which you need:
newthermofile. The mechanism in FlameMaster format is now in
gri.211.mech. This file will be used by ScanMan, which preprocesses the data and generates a binary file
gri.211.pre, which is the input to the FlameMaster program. The second file is
newthermofile, which is a combination (i.e., linked file) of the
transport211.dat files. This will have to be preprocessed to be used by ScanMan. Now, use the following command to preprocess
CreateBinFile -i newthermofile -o gri.211.thermo.bin
This creates the binary file
gri.211.thermo.bin, which is used as an input file for
Finally, we typically use the following line to obtain the binary mechanism file (
gri.211.pre, which is the final input for FlameMaster):
ScanMan -S -i gri.211.mech -t gri.211.thermo.bin
Note: it’s important to use the
-S, which treats isomers separately.
However, in order to generate the mechanism.F90 and .H files for NGA, we need to use the following line instead:
ScanMan -Sw -i gri.211.mech -t gri.211.thermo.bin
Note: use the lower case “w”.
Remark 1: with the way NGA uses it, the chemical Jacobian does not have to be exact; it is merely a preconditioner to make the monolithic implicit solver converge more quickly; but the exact chemical Jacobian may slightly enhance the convergence.
Remark 2: Those hard coded fortran files could have very large size if it is a large mechanism (more than 6000KB for GRI.211). The later compilation in NGA with those files lead to errors (Intel mpiifort_2018). Error information:
ifort: error #10106: Fatal error in /panfs/roc/intel/x86_64/2018/parallel_studio_xe_msi/compilers_and_libraries_2018.0.128/linux/bin/intel64/fortcom, terminated by kill signal
Need to find a way to solve this error.
Remark 3: Typically in a FlameMaster mechanism, the species names can contain more than 8 characters. In this case, the
GETSPECIESNAME subroutine in the mechanism-specific .f90 file contains long names. However, species names with longer than 8 characters cannot work in NGA (NGA uses the variable
str_short=8 to control name length, which can not be easily changed because this
str_short variable is relavant to ensight and monitor output). Hence, we can use the
ShortSymbol function in FlameMaster to reduce the species name length. In
ListUlities2.C where the function
PrintMagicNames write the species names to
GETSPECIESNAME, we can change
CSymbol( species->name ) to
CSymbolS( ShortSymbolS( species->name, shortsym ) ).
Remark 4: If your NGA finite chemistry case keeps crashing after the 0-th step, you should check the
COMPTHERMODATA subroutine in the generated .f90 file to see if all the NASA polynomial coefficients are normal. If they are all zero, the reason why the code crashed is then due to the zero
Cp value calculated by
COMPTHERMODATA. The reason may be because the FlameMaster format mechanism is not unix formatted. You can use
dos2unix command to convert the format and run ScanMan again to produce new .f90 files.