From charlesreid1

No edit summary
Line 19: Line 19:
You probably already know what to do.  You can follow the Mac instructions - the main thing that will change is the procedure for installing Numpy (you can probably use aptitude or yum or whatever package manager your distro uses), and the corresponding path to Numpy include files.  But this is as easy as figuring out where Numpy is installed on your hard drive.
You probably already know what to do.  You can follow the Mac instructions - the main thing that will change is the procedure for installing Numpy (you can probably use aptitude or yum or whatever package manager your distro uses), and the corresponding path to Numpy include files.  But this is as easy as figuring out where Numpy is installed on your hard drive.


== Mac ==
== Mac: Leopard (10.5) ==


If you're installing Cantera on a Mac, you have to [[Compiling Software|build it from source]].
If you're installing Cantera on a Mac, you have to [[Compiling Software|build it from source]].
Line 75: Line 75:


this means Cantera isn't including Numpy header files, meaning you probably didn't set the path to Numpy home correctly in your <code>preconfig</code> file.  This is probably caused by the incorrect parsing of the <code>NUMPY_HOME</code> variable.  To resolve this, set <code>NUMPY_INC_DIR</code> directly (don't forget to export it).
this means Cantera isn't including Numpy header files, meaning you probably didn't set the path to Numpy home correctly in your <code>preconfig</code> file.  This is probably caused by the incorrect parsing of the <code>NUMPY_HOME</code> variable.  To resolve this, set <code>NUMPY_INC_DIR</code> directly (don't forget to export it).
==Mac: Snow Leopard (10.6)==
I just got a new MacBook Pro with Snow Leopard, so instructions for building Cantera on Snow Leopard are forthcoming...


== Windows ==
== Windows ==

Revision as of 00:21, 10 May 2011

Cantera is a C++ package that provides objects for solving chemical kinetics, thermodynamics, and transport problems. The core of Cantera is written in C++, but it provides interfaces for using Cantera through Matlab (via a Matlab toolbox), Python, or Fortran.

This page is primarily focused on explaining the Cantera installation procedure for Linux, Mac OS X, and Windows.

If you're looking for a Cantera Matlab user's guide, or a Cantera Python user's guide, please visit the Cantera Lecture page. This page gives details on the usage of Cantera.

Also, this page is designed to be useful for anyone installing Cantera. If you don't think it's useful, or if you're having a problem not addressed by the page, please email me at root (at) charlesmartinreid.com with your problem and (if you found it) the solution, or with any comments or suggestions, and I will adjust the page accordingly.


Installation

Linux

You probably already know what to do. You can follow the Mac instructions - the main thing that will change is the procedure for installing Numpy (you can probably use aptitude or yum or whatever package manager your distro uses), and the corresponding path to Numpy include files. But this is as easy as figuring out where Numpy is installed on your hard drive.

Mac: Leopard (10.5)

If you're installing Cantera on a Mac, you have to build it from source.

Dependencies

If you wish to use Cantera from Python, you have two options:

  • Use version 1.8.0 and install Numpy
  • Use version 1.7.x and install Numarray

I highly recommend using version 1.8.0 and Numpy, as Numarray is no longer supported.

Anther package that is not required by Cantera, but that is useful, is Sundials, a suite of nonlinear and differential equation solvers.

Building

Start by downloading the Cantera 1.7 or 1.8 source code, and unzip it. Go to this directory, and edit the preconfig file. This is a wrapper for configure (so when you are ready to configure, you don't run ./configure, you run ./preconfig). Preconfig contains many options that are laid out very clearly, so go through the file and set values appropriate to your system.

One of the problems with using Cantera with Numpy is that Cantera incorrectly parses the path to the Numpy home directory to get a Numpy include directory that doesn't exist. This causes the 'import_array' error (below). This can be resolved by pointing Cantera configure to the Numpy include directory, by removing the variable NUMPY_HOME and adding a variable NUMPY_INC_DIR.

Before (broken):

NUMPY_HOME=${NUMPY_HOME:="/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include"}

After (fixed):

# NUMPY_HOME=${NUMPY_HOME:="/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include"}
NUMPY_INC_DIR=${NUMPY_INC_DIR:="/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include/numpy"}
export NUMPY_INC_DIR

You can find my preconfig file here: Cantera Preconfig

Your next steps are obvious:

$ ./preconfig
$ make
$ make install

Mac Installation Errors

If you see this error:

src/pycantera.cpp: In function ‘void init_cantera()’:
src/pycantera.cpp:95: error: ‘import_array’ was not declared in this scope
error: command 'g++' failed with exit status 1
make[1]: *** [_build] Error 1
make: *** [python] Error 2

this means Cantera isn't including Numpy header files, meaning you probably didn't set the path to Numpy home correctly in your preconfig file. This is probably caused by the incorrect parsing of the NUMPY_HOME variable. To resolve this, set NUMPY_INC_DIR directly (don't forget to export it).

Mac: Snow Leopard (10.6)

I just got a new MacBook Pro with Snow Leopard, so instructions for building Cantera on Snow Leopard are forthcoming...

Windows

The following instructions for installing a binary version of Cantera on Windows have been tested on both Windows XP and Windows 7.

  1. Install Python 2.5 (you will need the Python 2.5.4 installer from here: http://www.python.org/download/releases/2.5.4 ).
    1. It is strongly recommended that you install Python to the root path "C:\Python25"
  2. Install the Python Numarray package (you will need to download the installer for numarray from Sourceforge: http://sourceforge.net/projects/numpy/files/ . Be sure and scroll down to the section named “Old Numarray” and download the file numarray-1.5.2.win32-py2.5.exe)
  3. Download and run the Windows installer for Cantera 1.7 from Sourceforge: http://sourceforge.net/projects/cantera/
    1. It is strongly recommended that you install Cantera to the local path "C:\Cantera"
    2. Once Cantera has been installed, open C:\Cantera (or wherever you installed Cantera to) and double-click the executable, which should be named something like Cantera-1.7-python25.exe; this installs the bare minimum Python libraries required by Cantera for importing/converting Cantera input files.
  4. Set two environmental variables by right-clicking My Computer and clicking Properties, then selecting the "Advanced" tab (for Windows XP) or the "Advanced System Settings" link (for Windows 7), and click the "Environmental Variables" button.
    1. Create a new user variable by clicking “New...”
    2. Set the first variable:
      1. For variable name, type PYTHONPATH
      2. For variable value, type C:\Python25
    3. Set the second variable:
      1. For variable name, type PYTHON_CMD
      2. For variable value, type C:\Python25\python.exe
    4. Click “OK”several times until you've saved everything
  5. Download the Sundials Matlab Toolbox, which will not have anything to install; the Sundials toolbox provides Cantera with some important differential equation solvers. It can be downloaded here: https://computation.llnl.gov/casc/sundials/download/download.html
    1. The toolbox does not need to be “installed” - it's just a collection of files that needs to be put somewhere
    2. It is strongly recommended that you put the Sundials toolbox in the directory C:\sundialsTB
  6. Point Matlab to the Cantera and Sundials toolboxes
    1. Open Matlab and click File > Set Path...
    2. Click “Add with subdirectories”
    3. Add C:\Cantera\MATLAB
    4. Add C:\sundialsTB
  7. To test your installation of Cantera, execute the following command:
>> gas = GRI30;

This should create a gas using the GRI-Mech 3.0 chemical mechanism. If you see problems with a cti reader, or a ct2html reader not being built, check to make sure you set the PYTHON_CMD environmental variable properly.

Cantera Usage and Examples

You can find example Cantera Matlab scripts, as well as explanations of basic Cantera concepts, at the Cantera Lecture page.

You can also watch the video of my Cantera lecture, available at http://files.charlesmartinreid.com/CanteraScreencast.mov

Resources

On The Web

Cantera Google Groups Page - https://code.google.com/p/cantera/

  • Download Cantera 1.8.0 (beta), source code ONLY
  • Check out a copy of the subversion repository

Cantera (Google) Users Group Page - https://groups.google.com/group/cantera-users?pli=1

  • Download Cantera documentation
  • Use the discussion board

Cantera SourceForge Page - http://sourceforge.net/projects/cantera/files/

  • Download Cantera 1.7.1, source code or (Windows) binaries
  • Download (more) Cantera documentation


Lecture

As a TA for CHEN 6153, I gave a lecture on the installation and use of Cantera. I made a video screencast of the lecture, which is available here: http://files.charlesmartinreid.com/CanteraScreencast.mov

You can download the example Matlab scripts here as well: