From charlesreid1

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

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.

Downloading

You can download Cantera from Google Code: http://code.google.com/p/cantera/downloads/list

(it used to be hosted at SourceForge, but the project has since moved to Google Code)

This guide will cover version 1.8.0.

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.

Mac OS X

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. This guide will only cover this method.

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

Leopard

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

Start by downloading the Cantera 1.8 source code, and unzip it. Go to this directory, and edit the preconfig file (see Cantera Preconfig/Snow Leopard Preconfig). 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

Beware that including the "numpy" directory at the end may cause problems. If you are getting lots of Numpy-related (or Python-related) errors, try leaving off the last "numpy" directory. See Installing Cantera#Mac Installation Errors below for more info on errors and possible causes.

You can find my preconfig file for Leopard here: Cantera Preconfig/Leopard Preconfig

The next steps are the usual:

$ ./preconfig
$ make all
$ make install

Snow Leopard

Snow Leopard was a bit more of a challenge to get working, not sure why. So if you run into problems, consult the Installing Cantera#Mac Installation Errors section below, or try emailing myself or the Cantera user group.

I first downloaded Cantera, then unzipped the file, and edited the preconfig file (see Cantera Preconfig/Snow Leopard Preconfig) to point to the correct version of Numpy and the correct prefix.

I installed Numpy by building it directly from the Python source (not using a binary): see Py4Sci for details of how to do that. Also, I installed it with its own prefix, specifically ${HOME}/pkg/numpy-1.5.1.

As with Leopard, the preconfig file pointed to Numpy incorrectly, so I had to change it from this (broken):

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

to this (fixed):

NUMPY_INC_DIR=${NUMPY_INC_DIR:="/Users/charles/pkg/numpy-1.5.1/lib/python2.7/site-packages/numpy/core/include"}
export NUMPY_INC_DIR

IMPORTANT: I ended up having to change the depth of directories I included when specifying NUMPY_INC_DIR on Snow Leopard vs. Leopard. If you get python errors during "make install", try adding numpy/ to the end of the NUMPY_INC_DIR path given above.

Mac Installation Errors

(Many details forthcoming...)

Windows

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

Windows XP

See below... instructions work for both Windows XP and Windows 7.

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.

Windows Installation Errors

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 at the University of Utah, I gave a lecture on the installation and use of Cantera.

The lecture notes are here: Cantera Lecture

The video screencast of the lcture is here: http://files.charlesmartinreid.com/CanteraScreencast.mov

You can download the example Matlab scripts here as well: