Chemical kinetics: Cantera, zero-RK, PelePhysics#
Chemical kinetics packages are tools for problems involving chemical kinetics, thermodynamics, and transport processes. They can be useful in applications including but not limited to combustion, detonations, electrochemical energy conversion and storage, fuel cells, batteries, aqueous electrolyte solutions, plasmas, and thin film deposition.
Overview#
A wide variety of packages are available for the purpose, each with their strengths, pros and cons. The matrix below provides a birds eye view of some of the packages. When applicable, please refer to the footnotes marked at the bottom of the page. (All company, product and service names used on this page are for identification purposes only. Use of these names, trademarks and brands does not imply endorsement.)
C++ | Fortran | Python | Matlab | GPU | Speed*5 | Features | Cost | Compatibility | Speciality | |
---|---|---|---|---|---|---|---|---|---|---|
Cantera | y | y | y | y | x | ++ | ++++ | Free | Research codes*8 | Simplicity, large user base |
zero-RK | y | x | x*6 | x | y*1 | ++++*7 | ++*4 | Free | Converge CFD ($) | Model reduction tools |
PelePhysics | y | x | x | x | y | +++++ | +++ | Free | Amrex/Pele | HPC, NREL popular framework |
Chemkin Pro | y | y*2 | x | x | x*3 | ++++ | ++++ | $ | Ansys ($) | Legacy, professional support |
Strategy#
A typical workflow could look as follows:
-
Create mechanisms and validate with Cantera:
π Feature rich, multi language, very well documented, large support forum.
π Slower than competition, no GPU support.
-
Perform model reduction with zero-RK if necessary:
π Faster than Cantera & Chemkin for more than 100 species, some GPU support.
π Fewer features, sparse documentation, C++ only.
-
Convert to a high performance C++ code with PelePhysics and link to a CFD solver:
π GPU, well documented, amrex/Pele CFD & Cantera mechanisms compatible.
π Fewer features than Cantera & Chemkin, C++ only.
Installation and testing on Kestrel#
Note
Cantera can also be installed from source apart from the conda method explained below. The performance of packages mentioned on this page can vary depending on the choice of dependency library variants and optimization flags while compiling from source. We are more than happy to learn from power users about choices which lead to the best performance. Please report your experiences by email.
Cantera#
$ module load conda
$ conda create --name ct-env --channel cantera cantera ipython matplotlib jupyter
$ conda activate ct-env
$ python3
>>> import cantera as ct
>>> ct.one_atm
101325.0
>>> exit()
$ conda deactivate
Example interactive jupyter usage
$ ssh username@kestrel.hpc.nrel.gov
$ ln -s /scratch/username scratch
$ module load conda
$ conda activate ct-env
$ python -m ipykernel install --user --name=ct-env
Try Cantera python API within the notebook, for example,
import cantera as ct
ct.one_atm
$ module load conda
$ conda create --name ct-dev --channel cantera libcantera-devel
$ conda activate ct-dev
$ conda install cmake scons pkg-config
$ cd /home/username/.conda-envs/ct-dev/share/cantera/samples/cxx/demo
$ scons && ./demo
$ cmake . && cmake --build . && ./demo
$ g++ demo.cpp -o demo $(pkg-config --cflags --libs cantera) && ./demo
Example interactive C++ usage
$ ssh username@kestrel.hpc.nrel.gov
salloc --account=allocationName --time=00:30:00 --nodes=1 --ntasks-per-core=1 --ntasks-per-node=104 --cpus-per-task=1 --partition=debug
module load conda
conda activate ct-dev
CC -DEIGEN_USE_LAPACKE -DEIGEN_USE_BLAS -fopenmp -O3 -march=native -std=c++17 -I /home/username/.conda-envs/ct-dev/include/cantera/ext -I . mainYourCode.C $(pkg-config --cflags --libs cantera) -o flame.out
srun -n 5 ./flame.out
zero-RK#
Please follow the official installation instructions. The procedure has been tested successfully on the Kestrel and repeated below from the official instructions for convenience.
$ git clone https://github.com/llnl/zero-rk #git
$ cd zero-rk
$ mkdir build
$ cd build
$ cmake ../ #configure
$ make #build
$ ctest #test
$ make install #install
PelePhysics#
Note
Please mind the amrex dependency and remember to set the AMREX_HOME
environment variable to your amrex location before beginning to compile PelePhysics.
Please follow the official instructions for obtaining the PelePhysics library and compiling examples. The procedure has been tested successfully on the Kestrel. The process for obtaining PelePhysics and compiling the ReactEval example is repeated below from the official instructions for convenience.
$ git clone --recursive https://github.com/AMReX-Combustion/PelePhysics.git
$ cd PelePhysics
$ git pull && git submodule update
$ cd Testing/Exec/ReactEval
$ make TPL
$ make
Footnotes#
-
Not clear from the documentation but βgpuβ exists in the code in several places. No actual GPU users amongst those surveyed at the NREL. β©
-
Also possible through Chemkin II, which was a free Fortran library, not available online anymore. β©
-
The Ansys Fluent CFD solver uses GPU, the Chemkin Pro module does not. β©
-
Features unclear due to very poor documentation. Estimate based on reading parts of the code and NREL user comments. β©
-
Very vague estimate from documentation and NREL user comments. Benchmarking not performed. β©
-
Python scripts exist which gather parameters to execute C++ executables, no actual Python / Cython API like Cantera. β©
-
Faster than Chemkin and Cantera for mechanisms involving more than 100 species, information from documentation. β©
-
Coupling with various codes such as OpenFoam, Nek5000, JAX-Fluids etc. has been possible. β©