1. Install OpenFOAM-7 (if not already installed)
Note
If Ubuntu is used as the subsystem, please use Ubuntu:20.04 instead of the latest version. OpenFOAM-7 accompanied by ParaView 5.6.0 is not available for Ubuntu-latest.
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo apt-get update
sudo apt-get -y install openfoam7
OpenFOAM 7 and ParaView 5.6.0 will be installed in the /opt
directory.
2. Source your OpenFOAM
source $HOME/OpenFOAM/OpenFOAM-7/etc/bashrc
This depends on your own path for OpenFOAM bashrc.
3. Clone the DeepFlame repository
git clone https://github.com/deepmodeling/deepflame-dev.git
cd deepflame-dev
4. Install dependencies and DeepFlame based on your need
DeepFlame supports three compilation choices: no torch, LibTorch, and PyTorch.
Note
You are encouaged to try all three options, but remember to install the next version in a new terminal to clean previous environment variables.
4.1. No Torch version
If your are using DeepFlame’s CVODE solver without DNN model, just install LibCantera via conda.
conda create -n df-notorch
conda activate df-notorch
conda install -c cantera libcantera-devel
Note
Check your Miniconda3/envs/libcantera
directory and make sure the install was successful (lib/ include/ etc. exist).
If the conda env df-notorch
is activated, install DeepFlame by running:
. install.sh
If df-notorch
not activated (or you have a self-complied libcantera), specify the path to your libcantera:
. install.sh --libcantera_dir /your/path/to/libcantera/
4.2. LibTorch version
If you choose to use LibTorch (C++ API for Torch), first create the conda env and install LibCantera:
conda create -n df-libtorch
conda activate df-libtorch
conda install -c cantera libcantera-devel
Then you can either install DeepFlame with autodownloaded LibTorch
. install.sh --libtorch_autodownload
or you can pass your own libtorch path to DeepFlame.
. install.sh --libtorch_dir /path/to/libtorch/
4.3. PyTorch version
PyTorch version aims to support computation on CUDA. If you have compatible platform, run the following command to install DeepFlame.
conda create -n df-pytorch python=3.8
conda activate df-pytorch
conda install -c cantera libcantera-devel
conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge
conda install pybind11
. install.sh --use_pytorch
Note
You may come accross an error regarding shared library libmkl_rt.so.2
when libcantera is installed through cantera channel. If so, go to your conda environment and check the existance of libmkl_rt.so.2
and libmkl_rt.so.1
, and then link libmkl_rt.so.2
to libmkl_rt.so.1
.
cd ~/miniconda3/envs/df-pytorch/lib
ln -s libmkl_rt.so.1 libmkl_rt.so.2
Note
Some compiling issues may happen due to system compatability. Instead of using conda installed Cantera C++ lib and the downloaded Torch C++ lib, try to compile your own Cantera and Torch C++ libraries.