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* |
Features |
Cost |
Compatibility |
Speciality |
Cantera |
y |
y |
y |
y |
x |
++ |
++++ |
Free |
Research codes* |
Simplicity, large user base |
zero-RK |
y |
x |
x* |
x |
y* |
++++* |
++* |
Free |
Converge CFD ($) |
Model reduction tools |
PelePhysics |
y |
x |
x |
x |
y |
+++++ |
+++ |
Free |
Amrex/Pele |
HPC, NREL popular framework |
Chemkin Pro |
y |
y* |
x |
x |
x* |
++++ |
++++ |
$ |
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
Installation: Python version
$ 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
To access your scratch from the jupyter notebook, execute the following from your Kestrel home directory (optional)
$ ln -s /scratch/username scratch
$ module load conda
$ conda activate ct-env
Create a jupyter kernel from ct-env
$ python -m ipykernel install --user --name=ct-env
In a browser, go to Kestrel JupyterHub, select βct-envβ in the Notebook section to open a new jupyter notebook with the βct-envβ loaded
Try Cantera python API within the notebook, for example,
import cantera as ct
ct.one_atm
Installation: C++ version
$ 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
Allocate resources
salloc --account=allocationName --time=00:30:00 --nodes=1 --ntasks-per-core=1 --ntasks-per-node=104 --cpus-per-task=1 --partition=debug
Load Cantera
module load conda
conda activate ct-dev
Compile your code
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
Execute
Please refer to the job submission documentation for larger jobs in Batch mode.
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