Difference between revisions of "Contrib alternateReactingFoam"

From OpenFOAMWiki
Line 1: Line 1:
This page describes how to install the <tt>alternateReactingFoam</tt>  and alternateSteadyReactingFoam solvers.  
+
This page describes how to install the '''alternateReactingFoam''' and '''alternateSteadyReactingFoam''' solvers.  
As presented in [http://www.opensourcecfd.com/conference2008/media/proceedings/OSCIC-08_GschaiderRehm.pdf] a library to connect Cantera ([http://sourceforge.net/projects/cantera]) and OpenFOAM was written.  
+
As presented [http://www.opensourcecfd.com/conference2008/media/proceedings/OSCIC-08_GschaiderRehm.pdf here] a library to connect [http://sourceforge.net/projects/cantera Cantera] and OpenFOAM was written.  
  
 
The main reasons for using Cantera are:  
 
The main reasons for using Cantera are:  
Line 9: Line 9:
  
 
The library consists of two parts:
 
The library consists of two parts:
# alternateChemistryModel a library that allows the inclusion of alternate chemistry engines in solvers (allowing still to use OF chemistryModel)
+
# '''alternateChemistryModel''' a library that allows the inclusion of alternate chemistry engines in solvers (allowing still to use OF chemistryModel)
# canteraThermosChemistry a library that makes it possible to use Cantera in OpenFOAM
+
# '''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 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.
 
The following guide is valid for OpenFOAM 1.5.x and Cantera 1.8.
 
  
  
Line 26: Line 25:
 
     svn checkout http://cantera.googlecode.com/svn/cantera18/trunk/ cantera-1.8
 
     svn checkout http://cantera.googlecode.com/svn/cantera18/trunk/ cantera-1.8
  
The preconfig file was changed. See my example and if necessary adopt it for you.
+
The preconfig file was changed. See my [[preconfig: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 --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials
+
You need BLAS, LAPACK, numpy and gfortran packages installed (I installed it via my packet manager.) Additionally you need to install the [https://computation.llnl.gov/casc/sundials/main.html Sundials] package. I configured Sundials with
  
To install CANTERA type
+
    ./configure --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials
./preconfig
+
make
+
make install
+
  
Now add the CANTERA-Setup to you ~/.bashrc:
+
To install Cantera go to $WM_THIRD_PARTY_DIR/cantera-1.8 and type
 +
    ./preconfig
 +
    make
 +
    make install
  
#Cantera
+
Now add the Cantera setup script to your ~/.bashrc:
. ~/setup_cantera
+
 
 +
    #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:
 
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
+
    #Add Sundials Path for CVODE
# ./configure --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials
+
    # ./configure --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials
# -----------------------------------------------------------------------------
+
    # -----------------------------------------------------------------------------
export SUNDIALS_HOME=/home/rem/OpenFOAM/ThirdParty/sundials-2.3.0/installSundials
+
    export SUNDIALS_HOME=/home/rem/OpenFOAM/ThirdParty/sundials-2.3.0/installSundials
export LD_LIBRARY_PATH=$SUNDIALS_HOME/lib:$LD_LIBRARY_PATH
+
    export LD_LIBRARY_PATH=$SUNDIALS_HOME/lib:$LD_LIBRARY_PATH
 
+
   
#Add Cantera Path
+
    #Add Cantera Path
# ./preconfig (preconfig was adapted)
+
    # ./preconfig (preconfig was adapted)
# -----------------------------------------------------------------------------
+
    # -----------------------------------------------------------------------------
export CANTERA_HOME=$WM_THIRD_PARTY_DIR/cantera-1.8/installCantera
+
    export CANTERA_HOME=$WM_THIRD_PARTY_DIR/cantera-1.8/installCantera
export LD_LIBRARY_PATH=$CANTERA_HOME/lib:$LD_LIBRARY_PATH
+
    export LD_LIBRARY_PATH=$CANTERA_HOME/lib:$LD_LIBRARY_PATH
export PYTHONPATH=$CANTERA_HOME/lib64/python2.5/site-packages:$PYTHONPATH
+
    export PYTHONPATH=$CANTERA_HOME/lib64/python2.5/site-packages:$PYTHONPATH
  
  
Line 59: Line 60:
 
Now source your bashrc again to update all variables:
 
Now source your bashrc again to update all variables:
  
. ~/.bashrc
+
    . ~/.bashrc
  
 
== Install alternateChemistryModel and canteraThermosChemistry ==  
 
== Install alternateChemistryModel and canteraThermosChemistry ==  
  
 
Choose a location for the Libraries (e.g. $WM_PROJECT_USER_DIR/Libraries) and get the files via svn:
 
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
+
    cd $WM_PROJECT_USER_DIR/Libraries
svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/alternateChemistryModels/
+
    svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/alternateChemistryModels/
svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/canteraThermosChemistry/
+
    svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/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.
 
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:
 
Get the solvers and examples and wmake the solvers:
svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/solvers/AlternateChemistry/
+
 
 +
    svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/solvers/AlternateChemistry/
  
 
Make sure the Make/option file contains a valid link to $WM_PROJECT_USER_DIR/Libraries/alternateChemistryModels/lnInclude.  
 
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).
 
Now see if the dualInlet case runs (Transient/Steady).

Revision as of 21:44, 6 September 2009

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 preconfig: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 --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials

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
    # ./configure --enable-shared --prefix=$WM_SUNDIALS_PATH/installSundials
    # -----------------------------------------------------------------------------
    export SUNDIALS_HOME=/home/rem/OpenFOAM/ThirdParty/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 https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/trunk/Breeder_1.5/libraries/alternateChemistryModels/
    svn co https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/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 https://openfoam-extend.svn.sourceforge.net/svnroot/openfoam-extend/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).