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.
Warning
Conda environments should always be installed outside of your home directory for storage and performance reasons. This is especially important if linking a chemical kinetics package with a C++ code whose parallel processes can strain the /home
filesystem. Please refer to our dedicated conda documentation for more information on how to setup your conda environments to redirect the installation outside of /home
by default.
Cantera#
$ module load anaconda3/2024.06.1
$ cd /projects/<projectname>/<username>
$ conda create --prefix ./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 anaconda3/2024.06.1
$ conda activate /projects/<projectname>/<username>/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 anaconda3/2024.06.1
$ cd /projects/<projectname>/<username>
$ conda create --prefix ./ct-dev --channel cantera libcantera-devel
$ conda activate ./ct-dev
$ conda install cmake scons pkg-config
$ cd /projects/<projectname>/<username>/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 anaconda3/2024.06.1
conda activate /projects/<projectname>/<username>/ct-dev
CC -DEIGEN_USE_LAPACKE -DEIGEN_USE_BLAS -fopenmp -O3 -march=native -std=c++17 -I /projects/<projectname>/<username>/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.
$ cd /projects/<projectname>/<username>
$ 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.
$ cd /projects/<projectname>/<username>
$ git clone --recursive https://github.com/AMReX-Combustion/PelePhysics.git
$ cd PelePhysics
$ git pull && git submodule update
$ cd Testing/Exec/ReactEval
$ make TPL
$ make
Chemkin#
The Chemkin GUI can be accessed though a FastX virtual desktop. To use Chemkin Reaction Workbench in a FastX session, open a terminal within the FastX desktop and execute the following:
$ module load ansys
$ run_rdworkbench.sh
- Open a terminal in a FastX session and ask for an allocation. For example,
$ salloc -A <projectname> -t 02:00:00 --nodes=1 --ntasks-per-node=20 --mem=60G --gres=gpu:1
- Wait until you obtain an allocation, The terminal will display
<username>@<nodename>
when successful. - Open a new terminal tab by right clicking on empty in the terminal. In the new terminal tab, execute the following to connect to the node you have been allocated.
$ ssh -X <nodename>
- You are now on a compute node with X forwarding to a FastX desktop session, ready to run GUI applications. To run Chemkin, execute the following in this new terminal tab:
$ module load ansys $ run_rdworkbench.sh
Your GUI enabled applications in general and Chemkin in this specific case, can now utilize 20 cores and 1 GPU for 2 hours, as requested in the salloc
command above.
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. ↩