Skip to content

Instantly share code, notes, and snippets.

@ischoegl
Last active March 4, 2022 15:16
Show Gist options
  • Save ischoegl/33bbf0ea42b2d06e5be54a6cbcf7c9f7 to your computer and use it in GitHub Desktop.
Save ischoegl/33bbf0ea42b2d06e5be54a6cbcf7c9f7 to your computer and use it in GitHub Desktop.
Cantera toolchain on Linux conda

Disclaimer: the following instructions are not part of an official Cantera distribution and are posted here in the hope that they will help others to compile Cantera from scratch in a Linux/conda environment. Steps require Cantera >= 2.6.0a4 and will not work for older versions. In case you should have suggestions for improvement, please feel free to leave comments (or post on the Cantera Users' group as usual).

Cantera Toolchain for Linux / Anaconda

Using the correct packages for the conda environment is critical, as it will take care of the entire configuration.

Install mamba

$ conda install -c conda-forge mamba

Create a conda environment

Create the conda environment as

$ mamba create -n cantera-dev -c conda-forge sundials=6.0 scons numpy ruamel.yaml \
cython boost-cpp fmt eigen yaml-cpp libgomp openblas pytest ipython matplotlib h5py scipy jupyter

and activate this new environment using

$ conda activate cantera-dev

Compile Cantera

Change to a suitable folder used for compilation (instructions below use GitHub, which should be a pre-existing folder), and clone the repository (or a fork thereof), e.g.

$ cd GitHub
$ git clone https://github.com/Cantera/cantera.git
$ cd cantera

Now that everything is set up, run

$ scons build
$ scons test
$ scons install

(note that there are no options necessary!). The installation ends with

Cantera has been successfully installed.

File locations:

  applications                /home/<user>/.conda/envs/cantera-dev/bin
  library files               /home/<user>/.conda/envs/cantera-dev/lib
  C++ headers                 /home/<user>/.conda/envs/cantera-dev/include
  samples                     /home/<user>/.conda/envs/cantera-dev/share/cantera/samples
  data files                  /home/<user>/.conda/envs/cantera-dev/share/cantera/data  
  Python package (cantera)    /home/<user>/.conda/envs/cantera-dev/lib/python3.10/site-packages
  Python samples              /home/<user>/.conda/envs/cantera-dev/lib/python3.10/site-packages/cantera/examples

Setup scripts to configure the environment for Cantera are at:

  setup script (bash)         /home/<user>/.conda/envs/cantera-dev/bin/setup_cantera
  setup script (csh/tcsh)     /home/<user>/.conda/envs/cantera-dev/bin/setup_cantera.csh

It is recommended that you run the script for your shell by typing:

  source /home/<user>/.conda/envs/cantera-dev/bin/setup_cantera

before using Cantera, or else include its contents in your shell login script.

scons: done building targets.

Important: As the compiled code is based on the conda environment cantera-dev, it is only usable from within that environment. This means that in order to use your newly compiled Cantera version, you have to activate your cantera-dev environment first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment