Contrib alternateReactingFoam

From OpenFOAMWiki

This page describes how to install the alternateReactingFoam and alternateSteadyReactingFoam solvers. As presented here a library to connect Cantera and OpenFOAM was written.

The main reasons for using Cantera are:

  • easy access to thermochemical data and functions,
  • cantera has an excellent lexer for Chemkin-input
  • you can use all transport data (viscosity, diffsion, heat transfer) from transport data which is often available with reaction mechanisms (e.g GRI-3.0)
  • ideal reactor networks can be constructed and solved efficiently and stable with the CVODE stiff ODE solver package

The library consists of two parts:

  1. alternateChemistryModel a library that allows the inclusion of alternate chemistry engines in solvers (allowing still to use OF chemistryModel)
  2. canteraThermosChemistry a library that makes it possible to use Cantera in OpenFOAM

The libraries can be used by the solvers alternateSteadyReactingFoam and alternateReactingFoam. There are also examples included.

The following guide is valid for OpenFOAM 1.5.x and Cantera 1.8.


1 Install Cantera (Version 1.8)

Get the Cantera sources from Googlecode and download it to:

    mkdir $WM_THIRD_PARTY_DIR/cantera-1.8
    cd $WM_THIRD_PARTY_DIR
    svn checkout http://cantera.googlecode.com/svn/cantera18/trunk/ cantera-1.8

The preconfig file was changed. See my File:Preconfig.example.gz example and if necessary adopt it for you.

You need BLAS, LAPACK, numpy and gfortran packages installed (I installed it via my packet manager.) Additionally you need to install the Sundials package. I configured Sundials with

    ./configure CFLAGS=-fPIC --prefix=$SUNDIALS_HOME

To install Cantera go to $WM_THIRD_PARTY_DIR/cantera-1.8 and type

    ./preconfig
    make
    make install

Now add the Cantera setup script to your ~/.bashrc:

    #Cantera
    . ~/setup_cantera

In my case I had to add one more path to PYTHONPATH and some more environment variables which I set in my OpenFOAM-1.5.x/etc/settings.sh:

    #Add Sundials Path for CVODE
    # -----------------------------------------------------------------------------
    export SUNDIALS_HOME=$WM_THIRD_PARTY_DIR/sundials-2.3.0/installSundials
    export LD_LIBRARY_PATH=$SUNDIALS_HOME/lib:$LD_LIBRARY_PATH
    
    #Add Cantera Path
    # ./preconfig (preconfig was adapted)
    # -----------------------------------------------------------------------------
    export CANTERA_HOME=$WM_THIRD_PARTY_DIR/cantera-1.8/installCantera
    export LD_LIBRARY_PATH=$CANTERA_HOME/lib:$LD_LIBRARY_PATH
    export PYTHONPATH=$CANTERA_HOME/lib64/python2.5/site-packages:$PYTHONPATH


Now source your bashrc again to update all variables:

    . ~/.bashrc

2 Install alternateChemistryModel and canteraThermosChemistry

Choose a location for the Libraries (e.g. $WM_PROJECT_USER_DIR/Libraries) and get the files via svn:

    cd $WM_PROJECT_USER_DIR/Libraries
    svn co svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.5/libraries/alternateChemistryModels/
    svn co svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.5/libraries/canteraThermosChemistry/

And compile it (wmake libso). For canteraThermosChemistry make sure that the paths to Cantera, alternateChemistryModels (and Sundials) is correct.

Get the solvers and examples and wmake the solvers:

    svn co svn://svn.code.sf.net/p/openfoam-extend/svn/trunk/Breeder_1.5/solvers/AlternateChemistry/

Make sure the Make/option file contains a valid link to $WM_PROJECT_USER_DIR/Libraries/alternateChemistryModels/lnInclude.

Now see if the dualInlet case runs (Transient/Steady).

3 Bug reports

Can be issued at the bugtracker of openfoam-extend.sourceforge.net.


Cantera Info: Cantera 1.7 is available via CVS-sourceforge and from version 1.8 it is hosted on the Googlecode page. A Cantera discussion group can be found here.