Charles Martin Reid - Installing Cantera

 

From Charles Martin Reid

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.

Contents

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

Ubuntu

I installed Ubuntu 12.04 onto an Asus Eee 1001 netbook. Here are some notes.

First, I had to install gfortran, which was available via aptitude:

sudo apt-get intall gfortran

Next came cython and numpy:

pip install numpy
pip intall cython

The trickiest thing I had to do was related to Sundials - I had to re-compile sundials and passed the flags -fPIC to the C compiler. That way, Cantera and Sundials will play well.

Here's my modified sundials config (don't forget to run make clean before re-compiling with fPIC):

#!/bin/sh

./configure \
  --prefix=$HOME/main/pkg/sundials/2.5.0 \
  CXXFLAGS="-fPIC" \
  CFLAGS="-fPIC" \

Once I did that, I could run scons with the following line:

#!/bin/sh

scons build \
    prefix=$HOME/main/pkg/cantera/2.1.1 \
    cxx_flags="-fPIC" \
    python_package=new \
    use_sundials=y \
    f90_interface=n \
    build_with_f2c=no \
    sundials_include=$HOME/main/pkg/sundials/2.5.0/include \
    sundials_libdir=$HOME/main/pkg/sundials/2.5.0/lib \
    debug=no \
&& \
scons install

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

Finally, you can make the Cantera Python package available to Python by putting the following in your Dot files:

export PYTHONPATH="${HOME}/pkg/cantera/1.8.0/lib/python2.7/site-packages:${PYTHONPATH}"

You can test this out by opening Python and issuing the command

from Cantera import *

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.

You can then install Cantera by running:

$ ./preconfig
$ make -j2 all
$ make install

Finally, you can make the Cantera Python package available to Python by putting the following in your Dot files:

export PYTHONPATH="${HOME}/pkg/cantera/1.8.0/lib/python2.7/site-packages:${PYTHONPATH}"

You can test this out by opening Python and issuing the command

from Cantera import *

Lion

The Cantera installation procedure for Lion (Mac OS X 10.7) is same as for #Snow Leopard (Mac OS X 10.6).

Mountain Lion

After upgrading to Mac OS X 10.8 (Mountain Lion), Cantera increased to its next major revision (2.x) and switched to the scons build system.

First, install Scons. When you type which scons, you should see an executable.

Next, configure Cantera when you build scons by specifying options when you run the scons build command:

$ scons build option1=value1 [...]

See Cantera_Config/MountainLion_SconsConfig for my scons config line.

Using Autotools Instead of Scons

With Cantera comes a little script called "bootstrap," which essentially creates an autotools alternative to scons. It spits out a configure file (albeit with fewer configuration options than scons), etc.

Building Samples/Running Tests with Scons

In order to build all of the example problems in the samples directory, you must run

$ scons samples

If you didn't set the option f90_interface=n, you may run into problems; that's what happened to me.

Mac Installation Errors

file was built for unsupported file format which is not the architecture being linked (x86_64)

You may be seeing issues related to 32- and 64-bit libraries, like this:

-> gcc-4.0 -O -Wl,-twolevel_namespace -undefined error -arch x86_64 -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -bundle -Wl,-exported_symbols_list,/Applications/MATLAB_R2010b.app/extern/lib/maci64/mexFunction.map -o  "ctmethods.mexmaci64"  ctmethods.o ctfunctions.o xmlmethods.o phasemethods.o thermomethods.o kineticsmethods.o mixturemethods.o transportmethods.o reactormethods.o reactornetmethods.o wallmethods.o flowdevicemethods.o funcmethods.o onedimmethods.o surfmethods.o  -L/Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0 -L/usr/local/lib -lclib -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lsundials_cvodes -lsundials_nvecserial -lctf2c -lctf2c -lm -L/Applications/MATLAB_R2010b.app/bin/maci64 -lmx -lmex -lmat -lstdc++

ld: warning: in /Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0/libctspectra.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
  "_dgbtrf_", referenced from:
      Cantera::BandMatrix::factor()     in libctnumerics.a(BandMatrix.o)
  "_dgbtrs_", referenced from:
      Cantera::BandMatrix::solve(int, double*)in libctnumerics.a(BandMatrix.o)
  "_dgemv_", referenced from:
      Cantera::increment(Cantera::DenseMatrix const&, double const*, double*)in libctnumerics.a(DenseMatrix.o)
      Cantera::DenseMatrix::mult(double const*, double*) constin libctnumerics.a(DenseMatrix.o)
      Cantera::multiply(Cantera::DenseMatrix const&, double const*, double*)in libctnumerics.a(DenseMatrix.o)
      Cantera::L_Matrix::mult(double const*, double*) constin libtransport.a(MultiTransport.o)
      Cantera::L_Matrix::mult(double const*, double*) constin libtransport.a(MultiTransport.o)
      Cantera::L_Matrix::mult(double const*, double*) constin libtransport.a(MultiTransport.o)
  "Cantera::CVodesIntegrator::CVodesIntegrator()", referenced from:
      Cantera::newIntegrator(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in libctnumerics.a(ODE_integrators.o)
  "_dgetrf_", referenced from:
      Cantera::solve(Cantera::DenseMatrix&, Cantera::DenseMatrix&)in libctnumerics.a(DenseMatrix.o)
      Cantera::solve(Cantera::DenseMatrix&, double*)in libctnumerics.a(DenseMatrix.o)
      Cantera::invert(Cantera::DenseMatrix&, int)in libctnumerics.a(DenseMatrix.o)
      Cantera::MultiTransport::getMassFluxes(double const*, double const*, double, double*)in libtransport.a(MultiTransport.o)
      Cantera::MultiTransport::getSpeciesFluxes(int, double const*, int, double const*, int, double*)in libtransport.a(MultiTransport.o)
      Cantera::solveSP::solveSurfProb(int, double, double, double, double, double)in libkinetics.a(solveSP.o)
  "_dgetri_", referenced from:
      Cantera::invert(Cantera::DenseMatrix&, int)in libctnumerics.a(DenseMatrix.o)
  "_dgetrs_", referenced from:
      Cantera::solve(Cantera::DenseMatrix&, Cantera::DenseMatrix&)in libctnumerics.a(DenseMatrix.o)
      Cantera::solve(Cantera::DenseMatrix&, double*)in libctnumerics.a(DenseMatrix.o)
      Cantera::MultiTransport::getMassFluxes(double const*, double const*, double, double*)in libtransport.a(MultiTransport.o)
      Cantera::MultiTransport::getSpeciesFluxes(int, double const*, int, double const*, int, double*)in libtransport.a(MultiTransport.o)
      Cantera::solveSP::solveSurfProb(int, double, double, double, double, double)in libkinetics.a(solveSP.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

    mex: link of ' "ctmethods.mexmaci64"' failed.

??? Error using ==> mex at 208
Unable to complete successfully.

Error in ==> buildux at 3
mex -cxx -v private/ctmethods.cpp private/ctfunctions.cpp ...

Error in ==> setup at 2
buildux
 
>> quit
rm -f setup.m 
cd tools; make
cd src; make
rm -f /Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/bin/i386-apple-darwin10.8.0/cti2ctml
g++-4.0 -o /Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/bin/i386-apple-darwin10.8.0/cti2ctml cti2ctml.o -L/Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0   -L/usr/local/lib -O3 -Wall -arch x86_64   -luser -loneD -lzeroD -lequil -lkinetics -ltransport -lthermo -lctnumerics -lctmath -ltpx -lctspectra -lconverters -lctbase -lsundials_cvodes -lsundials_nvecserial  -lctf2c   \
               -lctf2c -lm -framework Accelerate 
ld: warning: in cti2ctml.o, file was built for i386 which is not the architecture being linked (x86_64)
ld: warning: in /Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0/libctspectra.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols:
  "_MAIN__", referenced from:
      _main in libctf2c.a(main.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[2]: *** [/Users/goxberry/ScientificSoftware/cantera-1.8.0-beta/build/bin/i386-apple-darwin10.8.0/cti2ctml] Error 1
make[1]: *** [apps] Error 2
make: *** [utils] Error 2

The cause of this problem is different architectures (32 and 64 bit) being linked together, which doesn't work.

the _dg.... functions in the libraries being linked are Lapack and Blas stuff. These are your (64-bit) system Lapack and Blas. On Mac, those are built-in (that's what the -framework Accelerate does). They are 64 bit b/c Snow Leopard is 64 bit. Snow Leopard is capable of compiling and running 32-bit programs, but to be safe, or anytime you're linking to system libraries, you will want to build 64-bit architecture binaries.

You can force your compiler to do this by using CFLAGS and CXXFLAGS, which are compiler flags that Cantera will use. Set them like this (in your preconfig file):

CFLAGS="-arch x86_64"
CXXFLAGS="-arch x86_64"

This will force Cantera to build using the 64-bit architecture, to match your Lapack/Blas.






libclib.a error, *.mod error

The following error is due to a library libclib.a not being made:

$ make install
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/include/cantera
cp -r -f build/include/cantera /Users/charles/pkg/cantera/1.8.0/include
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/lib
rm -fR /Users/charles/pkg/cantera/1.8.0/lib/*
( for ilib in /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/*.a ; do  \
      /usr/bin/install -c -c -m 644 ${ilib} /Users/charles/pkg/cantera/1.8.0/lib ; \
          done )
ranlib /Users/charles/pkg/cantera/1.8.0/lib/*.a
cd Cantera/clib/src; make install
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/lib
/usr/bin/install -c -c -m 644 /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/libclib.a 
  /Users/charles/pkg/cantera/1.8.0/lib
install: /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/libclib.a: No such file or directory
make[1]: *** [install] Error 71
make: *** [clib-install] Error 2

I tried running

cd Cantera/clib/src
make

and this successfully made libclib.a. However, it then caused this error:

$ make install
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/include/cantera
cp -r -f build/include/cantera /Users/charles/pkg/cantera/1.8.0/include
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/lib
rm -fR /Users/charles/pkg/cantera/1.8.0/lib/*
( for ilib in /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/*.a ; do  \
      /usr/bin/install -c -c -m 644 ${ilib} /Users/charles/pkg/cantera/1.8.0/lib ; \
          done )
ranlib /Users/charles/pkg/cantera/1.8.0/lib/*.a
cd Cantera/clib/src; make install
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/lib
/usr/bin/install -c -c -m 644 /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/libclib.a 
  /Users/charles/pkg/cantera/1.8.0/lib
ranlib /Users/charles/pkg/cantera/1.8.0/lib/libclib.a
/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/data
( for iddd in data/inputs/*.xml ; do  \
          /usr/bin/install -c -c -m 644 ${iddd} /Users/charles/pkg/cantera/1.8.0/data ;  done )
( for iddd in data/inputs/*.cti ; do  \
          /usr/bin/install -c -c -m 644 ${iddd} /Users/charles/pkg/cantera/1.8.0/data ;  done )
/usr/bin/install -c -c -m 644 build/include/cantera/*.mod /Users/charles/pkg/cantera/1.8.0/include/cantera
install: build/include/cantera/*.mod: No such file or directory
make: *** [f90-modules-install] Error 71

Looking in the Makefile reveals that libclib.a should have been built, but its target was not the default target; it was probably not a dependency of the default make target.

So instead of running "make", run "make all".

import_array error/Python unrecognized type errors

You may encounter the following Python errors when running "make all":

$ make -j2 all
building 'Cantera._cantera' extension
creating build/temp.macosx-10.6-intel-2.7
creating build/temp.macosx-10.6-intel-2.7/src
g++ -DNDEBUG -g -O3 -O3 -Wall -fPIC -I../../build/include -Isrc -I../clib/src 
  -I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include/numpy 
  -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
  -c src/pycantera.cpp -o build/temp.macosx-10.6-intel-2.7/src/pycantera.o
g++ -c fct.cpp -I../../src/base -I../../src/thermo -I../../src/kinetics -I../../src/transport 
  -I../../src/numerics -I../../src/oneD -I../../src/zeroD -I../../src/equil -I../../src/converters  
  -O3 -Wall   
src/pycantera.cpp:26:31: error: numpy/arrayobject.h: No such file or directory
In file included from src/pycantera.cpp:56:
src/ctphase_methods.cpp: In function ‘PyObject* phase_getarray(PyObject*, PyObject*)’:
src/ctphase_methods.cpp:126: error: ‘PyArrayObject’ was not declared in this scope
src/ctphase_methods.cpp:126: error: ‘x’ was not declared in this scope
src/ctphase_methods.cpp:132: error: ‘npy_intp’ was not declared in this scope
src/ctphase_methods.cpp:132: error: expected `;' before ‘nnn’
src/ctphase_methods.cpp:133: error: expected primary-expression before ‘)’ token
src/ctphase_methods.cpp:133: error: expected `;' before ‘PyArray_SimpleNew’
src/ctphase_methods.cpp:157: error: ‘npy_intp’ was not declared in this scope
src/ctphase_methods.cpp:157: error: expected `;' before ‘nnn’
src/ctphase_methods.cpp:158: error: expected primary-expression before ‘)’ token
src/ctphase_methods.cpp:158: error: expected `;' before ‘PyArray_SimpleNew’
src/ctphase_methods.cpp:173: error: ‘PyArray_Return’ was not declared in this scope
src/ctphase_methods.cpp: In function ‘PyObject* phase_setarray(PyObject*, PyObject*)’:
src/ctphase_methods.cpp:260: error: ‘PyArrayObject’ was not declared in this scope
src/ctphase_methods.cpp:260: error: ‘a’ was not declared in this scope
src/ctphase_methods.cpp:260: error: expected primary-expression before ‘)’ token
src/ctphase_methods.cpp:261: error: expected `;' before ‘PyArray_ContiguousFromObject’
In file included from src/pycantera.cpp:57:
src/ctthermo_methods.cpp: In function ‘PyObject* thermo_getarray(PyObject*, PyObject*)’:
src/ctthermo_methods.cpp:198: error: ‘npy_intp’ was not declared in this scope
src/ctthermo_methods.cpp:198: error: expected `;' before ‘nnn’
src/ctthermo_methods.cpp:199: error: ‘PyArrayObject’ was not declared in this scope
src/ctthermo_methods.cpp:199: error: ‘x’ was not declared in this scope
src/ctthermo_methods.cpp:200: error: expected primary-expression before ‘)’ token
src/ctthermo_methods.cpp:200: error: expected `;' before ‘PyArray_SimpleNew’
src/ctthermo_methods.cpp:228: error: ‘PyArray_Return’ was not declared in this scope
src/ctthermo_methods.cpp:192: warning: unused variable ‘xlen’
In file included from src/pycantera.cpp:58:
src/ctkinetics_methods.cpp: In function ‘PyObject* kin_getarray(PyObject*, PyObject*)’:
src/ctkinetics_methods.cpp:172: error: ‘npy_intp’ was not declared in this scope
src/ctkinetics_methods.cpp:172: error: expected `;' before ‘nix’
src/ctkinetics_methods.cpp:173: error: ‘PyArrayObject’ was not declared in this scope
src/ctkinetics_methods.cpp:173: error: ‘x’ was not declared in this scope
src/ctkinetics_methods.cpp:173: error: expected primary-expression before ‘)’ token
src/ctkinetics_methods.cpp:173: error: expected `;' before ‘PyArray_SimpleNew’
src/ctkinetics_methods.cpp:238: error: ‘PyArray_Return’ was not declared in this scope
In file included from src/pycantera.cpp:59:
src/cttransport_methods.cpp: In function ‘PyObject* py_setParameters(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:40: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:40: error: ‘a’ was not declared in this scope
src/cttransport_methods.cpp:40: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:41: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/cttransport_methods.cpp: In function ‘PyObject* py_thermalDiffCoeffs(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:74: error: ‘npy_intp’ was not declared in this scope
src/cttransport_methods.cpp:74: error: expected `;' before ‘nidt’
src/cttransport_methods.cpp:75: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:75: error: ‘dt’ was not declared in this scope
src/cttransport_methods.cpp:76: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:76: error: expected `;' before ‘PyArray_SimpleNew’
src/cttransport_methods.cpp:83: error: ‘PyArray_Return’ was not declared in this scope
src/cttransport_methods.cpp: In function ‘PyObject* py_binaryDiffCoeffs(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:92: error: ‘npy_intp’ was not declared in this scope
src/cttransport_methods.cpp:92: error: expected `;' before ‘idim’
src/cttransport_methods.cpp:93: error: ‘idim’ was not declared in this scope
src/cttransport_methods.cpp:95: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:95: error: ‘d’ was not declared in this scope
src/cttransport_methods.cpp:95: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:95: error: expected `;' before ‘PyArray_SimpleNew’
src/cttransport_methods.cpp:104: error: ‘PyArray_Return’ was not declared in this scope
src/cttransport_methods.cpp: In function ‘PyObject* py_mixDiffCoeffs(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:113: error: ‘npy_intp’ was not declared in this scope
src/cttransport_methods.cpp:113: error: expected `;' before ‘nid’
src/cttransport_methods.cpp:114: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:114: error: ‘d’ was not declared in this scope
src/cttransport_methods.cpp:114: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:114: error: expected `;' before ‘PyArray_SimpleNew’
src/cttransport_methods.cpp:120: error: ‘PyArray_Return’ was not declared in this scope
src/cttransport_methods.cpp: In function ‘PyObject* py_multiDiffCoeffs(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:130: error: ‘npy_intp’ was not declared in this scope
src/cttransport_methods.cpp:130: error: expected `;' before ‘idim’
src/cttransport_methods.cpp:131: error: ‘idim’ was not declared in this scope
src/cttransport_methods.cpp:133: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:133: error: ‘d’ was not declared in this scope
src/cttransport_methods.cpp:133: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:133: error: expected `;' before ‘PyArray_SimpleNew’
src/cttransport_methods.cpp:142: error: ‘PyArray_Return’ was not declared in this scope
src/cttransport_methods.cpp: In function ‘PyObject* py_getMolarFluxes(PyObject*, PyObject*)’:
src/cttransport_methods.cpp:153: error: ‘PyArrayObject’ was not declared in this scope
src/cttransport_methods.cpp:153: error: ‘state1array’ was not declared in this scope
src/cttransport_methods.cpp:153: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:153: error: expected `;' before ‘state1’
src/cttransport_methods.cpp:154: error: ‘state2array’ was not declared in this scope
src/cttransport_methods.cpp:154: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:154: error: expected `;' before ‘state2’
src/cttransport_methods.cpp:158: error: ‘npy_intp’ was not declared in this scope
src/cttransport_methods.cpp:158: error: expected `;' before ‘nid’
src/cttransport_methods.cpp:159: error: ‘f’ was not declared in this scope
src/cttransport_methods.cpp:159: error: expected primary-expression before ‘)’ token
src/cttransport_methods.cpp:159: error: expected `;' before ‘PyArray_SimpleNew’
src/cttransport_methods.cpp:166: error: ‘PyArray_Return’ was not declared in this scope
In file included from src/pycantera.cpp:60:
src/ctxml_methods.cpp: In function ‘PyObject* py_ctml_getFloatArray(PyObject*, PyObject*)’:
src/ctxml_methods.cpp:229: error: ‘npy_intp’ was not declared in this scope
src/ctxml_methods.cpp:229: error: expected `;' before ‘nia’
src/ctxml_methods.cpp:230: error: ‘PyArrayObject’ was not declared in this scope
src/ctxml_methods.cpp:230: error: ‘a’ was not declared in this scope
src/ctxml_methods.cpp:231: error: expected primary-expression before ‘)’ token
src/ctxml_methods.cpp:231: error: expected `;' before ‘PyArray_SimpleNew’
src/ctxml_methods.cpp:239: error: ‘PyArray_Return’ was not declared in this scope
In file included from src/pycantera.cpp:62:
src/ctsurf_methods.cpp: In function ‘PyObject* py_surf_setcoverages(PyObject*, PyObject*)’:
src/ctsurf_methods.cpp:34: error: ‘PyArrayObject’ was not declared in this scope
src/ctsurf_methods.cpp:34: error: expected primary-expression before ‘double’
src/ctsurf_methods.cpp:34: error: expected `)' before ‘double’
src/ctsurf_methods.cpp: In function ‘PyObject* py_surf_setconcentrations(PyObject*, PyObject*)’:
src/ctsurf_methods.cpp:47: error: ‘PyArrayObject’ was not declared in this scope
src/ctsurf_methods.cpp:47: error: expected primary-expression before ‘double’
src/ctsurf_methods.cpp:47: error: expected `)' before ‘double’
src/ctsurf_methods.cpp: In function ‘PyObject* py_surf_getcoverages(PyObject*, PyObject*)’:
src/ctsurf_methods.cpp:57: error: ‘PyArrayObject’ was not declared in this scope
src/ctsurf_methods.cpp:57: error: ‘cov’ was not declared in this scope
src/ctsurf_methods.cpp:62: error: ‘npy_intp’ was not declared in this scope
src/ctsurf_methods.cpp:62: error: expected `;' before ‘nnsp’
src/ctsurf_methods.cpp:63: error: expected primary-expression before ‘)’ token
src/ctsurf_methods.cpp:63: error: expected `;' before ‘PyArray_SimpleNew’
src/ctsurf_methods.cpp:67: error: expected primary-expression before ‘double’
src/ctsurf_methods.cpp:67: error: expected `)' before ‘double’
src/ctsurf_methods.cpp:60: warning: unused variable ‘nsp’
src/ctsurf_methods.cpp: In function ‘PyObject* py_surf_getconcentrations(PyObject*, PyObject*)’:
src/ctsurf_methods.cpp:77: error: ‘PyArrayObject’ was not declared in this scope
src/ctsurf_methods.cpp:77: error: ‘c’ was not declared in this scope
src/ctsurf_methods.cpp:82: error: ‘npy_intp’ was not declared in this scope
src/ctsurf_methods.cpp:82: error: expected `;' before ‘nnsp’
src/ctsurf_methods.cpp:83: error: expected primary-expression before ‘)’ token
src/ctsurf_methods.cpp:83: error: expected `;' before ‘PyArray_SimpleNew’
src/ctsurf_methods.cpp:87: error: expected primary-expression before ‘double’
src/ctsurf_methods.cpp:87: error: expected `)' before ‘double’
src/ctsurf_methods.cpp:80: warning: unused variable ‘nsp’
In file included from src/pycantera.cpp:64:
src/ctrpath_methods.cpp: In function ‘PyObject* py_rdiag_findMajor(PyObject*, PyObject*)’:
src/ctrpath_methods.cpp:230: error: ‘PyArrayObject’ was not declared in this scope
src/ctrpath_methods.cpp:230: error: ‘aa’ was not declared in this scope
src/ctrpath_methods.cpp:230: error: expected primary-expression before ‘)’ token
src/ctrpath_methods.cpp:230: error: expected `;' before ‘a’
In file included from src/pycantera.cpp:65:
src/ctreactor_methods.cpp: In function ‘PyObject* py_flowdev_setParameters(PyObject*, PyObject*)’:
src/ctreactor_methods.cpp:321: error: ‘PyArrayObject’ was not declared in this scope
src/ctreactor_methods.cpp:321: error: ‘ca’ was not declared in this scope
src/ctreactor_methods.cpp:321: error: expected primary-expression before ‘)’ token
src/ctreactor_methods.cpp:322: error: expected `;' before ‘PyArray_ContiguousFromObject’
In file included from src/pycantera.cpp:66:
src/ctfunc_methods.cpp: In function ‘PyObject* py_func_new(PyObject*, PyObject*)’:
src/ctfunc_methods.cpp:9: error: ‘PyArrayObject’ was not declared in this scope
src/ctfunc_methods.cpp:9: error: ‘coeffs’ was not declared in this scope
src/ctfunc_methods.cpp:9: error: expected primary-expression before ‘)’ token
src/ctfunc_methods.cpp:9: error: expected `;' before ‘c’
In file included from src/pycantera.cpp:67:
src/ctonedim_methods.cpp: In function ‘PyObject* py_domain_setupGrid(PyObject*, PyObject*)’:
src/ctonedim_methods.cpp:230: error: ‘PyArrayObject’ was not declared in this scope
src/ctonedim_methods.cpp:230: error: ‘grid_array’ was not declared in this scope
src/ctonedim_methods.cpp:230: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:231: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp: In function ‘PyObject* py_stflow_setFixedTempProfile(PyObject*, PyObject*)’:
src/ctonedim_methods.cpp:548: error: ‘PyArrayObject’ was not declared in this scope
src/ctonedim_methods.cpp:548: error: ‘pos_array’ was not declared in this scope
src/ctonedim_methods.cpp:548: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:549: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp:554: error: ‘temp_array’ was not declared in this scope
src/ctonedim_methods.cpp:554: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:555: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp: In function ‘PyObject* py_sim1D_new(PyObject*, PyObject*)’:
src/ctonedim_methods.cpp:621: error: ‘PyArrayObject’ was not declared in this scope
src/ctonedim_methods.cpp:621: error: ‘domains_array’ was not declared in this scope
src/ctonedim_methods.cpp:621: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:622: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp: In function ‘PyObject* py_sim1D_setProfile(PyObject*, PyObject*)’:
src/ctonedim_methods.cpp:686: error: ‘PyArrayObject’ was not declared in this scope
src/ctonedim_methods.cpp:686: error: ‘pos_array’ was not declared in this scope
src/ctonedim_methods.cpp:686: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:687: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp:692: error: ‘v_array’ was not declared in this scope
src/ctonedim_methods.cpp:692: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:693: error: expected `;' before ‘PyArray_ContiguousFromObject’
src/ctonedim_methods.cpp: In function ‘PyObject* py_sim1D_setTimeStep(PyObject*, PyObject*)’:
src/ctonedim_methods.cpp:753: error: ‘PyArrayObject’ was not declared in this scope
src/ctonedim_methods.cpp:753: error: ‘nsteps_array’ was not declared in this scope
src/ctonedim_methods.cpp:753: error: expected primary-expression before ‘)’ token
src/ctonedim_methods.cpp:754: error: expected `;' before ‘PyArray_ContiguousFromObject’
In file included from src/pycantera.cpp:68:
src/ctmultiphase_methods.cpp: In function ‘PyObject* py_mix_setMoles(PyObject*, PyObject*)’:
src/ctmultiphase_methods.cpp:308: error: ‘PyArrayObject’ was not declared in this scope
src/ctmultiphase_methods.cpp:308: error: ‘n_array’ was not declared in this scope
src/ctmultiphase_methods.cpp:308: error: expected primary-expression before ‘)’ token
src/ctmultiphase_methods.cpp:308: error: expected `;' before ‘n’
src/ctmultiphase_methods.cpp: In function ‘PyObject* py_mix_getChemPotentials(PyObject*, PyObject*)’:
src/ctmultiphase_methods.cpp:388: error: ‘PyArrayObject’ was not declared in this scope
src/ctmultiphase_methods.cpp:388: error: ‘mu_array’ was not declared in this scope
src/ctmultiphase_methods.cpp:388: error: expected primary-expression before ‘)’ token
src/ctmultiphase_methods.cpp:388: error: expected `;' before ‘mu’
src/pycantera.cpp: In function ‘void init_cantera()’:
src/pycantera.cpp:96: 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
make: *** Waiting for unfinished jobs....
g++ -c fctxml.cpp -I../../src/base -I../../src/thermo -I../../src/kinetics 
  -I../../src/transport -I../../src/numerics -I../../src/oneD -I../../src/zeroD 
  -I../../src/equil -I../../src/converters  -O3 -Wall   
rm -f     /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/libfct.a
libtool -static -o /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.7.0/libfct.a 
  fct.o fctxml.o cantera_xml.o cantera_thermo.o cantera_kinetics.o 
  cantera_transport.o cantera_iface.o cantera_funcs.o cantera.o
libtool: file: cantera.o has no symbols
/usr/bin/install -c -c Cantera/fortran/src/*.mod build/include/cantera 

This is typically caused by the Numpy module being unavailable to Python.

Check your $NUMPY_INC_DIR (see above for details, you should replace the default $NUMPY_HOME with $NUMPY_INC_DIR). As you can see from the very first few lines, g++ is pointing at -I/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include/numpy for Numpy headers, but this directory is incorrect (as specified above, I installed Numpy to a custom location, /Users/charles/pkg/numpy-1.5.1). The problem turned out to be that I was pointing at an incorrect directory with $NUMPY_INC_DIR.

I fixed preconfig to point to the following location:

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

(following what I did for installing Cantera on Leopard), then ran:

make clean
./preconfig
make -j2 all

But I still got the same errors:

running build_ext
building 'Cantera._cantera' extension
creating build/temp.macosx-10.6-intel-2.7
creating build/temp.macosx-10.6-intel-2.7/src
g++ -DNDEBUG -g -O3 -O3 -Wall -fPIC -I../../build/include -Isrc 
  -I../clib/src -I/Users/charles/pkg/numpy-1.5.1/lib/python2.7/site-packages/numpy/core/include/numpy 
  -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 
  -c src/pycantera.cpp -o build/temp.macosx-10.6-intel-2.7/src/pycantera.o
src/pycantera.cpp:26:31: error: numpy/arrayobject.h: No such file or directory

[...a bunch more Python errors...]

Notice that the error is from numpy/arrayobject.h not existing: but I already have a trailing numpy/ on the location pointed to by $NUMPY_INC_DIR.

This turned out to be fixable by getting rid of the trailing numpy/:

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

make install problem: demos/cxx

I was able to successfully run make all, without errors, but when running make install, I ran into the following problem with /usr/bin/install:

/usr/bin/install -c -d /Users/charles/pkg/cantera/1.8.0/man1
/usr/bin/install -c -c man/ck2cti.1 /Users/charles/pkg/cantera/1.8.0/man1
/usr/bin/install -c -c man/mixmaster.1 /Users/charles/pkg/cantera/1.8.0/man1
(cd Cantera/cxx/demos; make install)
/usr/bin/install -c -d       /Users/charles/pkg/cantera/1.8.0/demos/cxx
/usr/bin/install -c Makefile -m ug+rw,o+r /Users/charles/pkg/cantera/1.8.0/demos/cxx
install: -m: No such file or directory
make[1]: *** [install] Error 71
make: *** [demo-install] Error 2 

Running the command /usr/bin/install -c Makefile -m ug+rw,o+r /Users/charles/pkg/cantera/1.8.0/demos/cxx by hand gave a slightly different error:

$ /usr/bin/install -c Makefile -m ug+rw,o+r /Users/charles/pkg/cantera/1.8.0/demos/cxx
install: ug+rw,o+r: No such file or directory

According to the man page for install, the -m flag is legit, and the argument being fed to the -m flag is also legit. So I tried rearranging the order of the flags:

$ /usr/bin/install -m ug+rw,o+r -c Makefile /Users/charles/pkg/cantera/1.8.0/demos/cxx

$

No problems! So the problem was just a weird issue with the order of flags. I fixed this by editing (by hand) the following Makefile:

$ vim Cantera/demos/cxx/Makefile

and changed the line containing this (broken):

install -c Makefile -m ug+rw,o+r /Users/charles/pkg/cantera/1.8.0/demos/cxx

to this (fixed):

install -m ug+rw,o+r -c Makefile /Users/charles/pkg/cantera/1.8.0/demos/cxx


make install problem: demos/cxx (UPDATED)

If you are having the same problem as described above, but the file Cantera/demos/cxx/Makefile does not exist, it may be in this location:

Cantera/cxx/demos/

Problem with python install

I got a message after running "make all" and "make install" that the installation of the Cantera Python package had failed:

 ######################################################################
    Warning: the Cantera Python package is not installed. If you
    intentionally skipped it, ignore this message. Otherwise, type
    'make python' and/or 'make python-install' and look for error messages.
    Note that you must first install the 'numarray' package before installing
    the Cantera package.
 ######################################################################

However, when I ran

$ make python
$ make python-install

there were no problems.

Problem with libtool -static option (unrecognized option -static)

After configuring Cantera, and during the "make" process, I was running into a problem with the libtool command not recognizing the option '-static':

gcc -c -DSkip_f2c_Undefs  -fPIC wsne.c
gcc -c -DSkip_f2c_Undefs  -fPIC xwsne.c
gcc -c -DSkip_f2c_Undefs  -fPIC dtime_.c
gcc -c -DSkip_f2c_Undefs  -fPIC etime_.c
libtool -static -o /Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0/libctf2c.a f77vers.o i77vers.o main.o s_rnge.o abort_.o exit_.o getarg_.o iargc_.o getenv_.o signal_.o s_stop.o s_paus.o system_.o cabs.o derf_.o derfc_.o erf_.o erfc_.o sig_die.o uninit.o pow_ci.o pow_dd.o pow_di.o pow_hh.o pow_ii.o pow_ri.o pow_zi.o pow_zz.o c_abs.o c_cos.o c_div.o c_exp.o c_log.o c_sin.o c_sqrt.o z_abs.o z_cos.o z_div.o z_exp.o z_log.o z_sin.o z_sqrt.o r_abs.o r_acos.o r_asin.o r_atan.o r_atn2.o r_cnjg.o r_cos.o r_cosh.o r_dim.o r_exp.o r_imag.o r_int.o r_lg10.o r_log.o r_mod.o r_nint.o r_sign.o r_sin.o r_sinh.o r_sqrt.o r_tan.o r_tanh.o d_abs.o d_acos.o d_asin.o d_atan.o d_atn2.o d_cnjg.o d_cos.o d_cosh.o d_dim.o d_exp.o d_imag.o d_int.o d_lg10.o d_log.o d_mod.o d_nint.o d_prod.o d_sign.o d_sin.o d_sinh.o d_sqrt.o d_tan.o d_tanh.o i_abs.o i_dim.o i_dnnt.o i_indx.o i_len.o i_mod.o i_nint.o i_sign.o lbitbits.o lbitshft.o h_abs.o h_dim.o h_dnnt.o h_indx.o h_len.o h_mod.o h_nint.o h_sign.o l_ge.o l_gt.o l_le.o l_lt.o hl_ge.o hl_gt.o hl_le.o hl_lt.o ef1asc_.o ef1cmc_.o f77_aloc.o s_cat.o s_cmp.o s_copy.o backspac.o close.o dfe.o dolio.o due.o endfile.o err.o fmt.o fmtlib.o ftell_.o iio.o ilnw.o inquire.o lread.o lwrite.o open.o rdfmt.o rewind.o rsfe.o rsli.o rsne.o sfe.o sue.o typesize.o uio.o util.o wref.o wrtfmt.o wsfe.o wsle.o wsne.o xwsne.o dtime_.o etime_.o
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[2]: *** [/Users/charles/pkg/_sources/cantera-1.8.0-beta/build/lib/i386-apple-darwin10.8.0/libctf2c.a] Error 1
make[1]: *** [all] Error 2
make: *** [kernel] Error 2

The origin of this was that I was using the wrong version of libtool. A simple "which libtool" revealed the problem:

$ which libtool
/Applications/MAMP/bin/apache2/bin/libtool

Wrong one! This was inadvertently installed when I installed MAMP, which is web hosting software for the Mac. A simple fix is:

$ export PATH="/usr/bin:$PATH"
$ which libtool
/usr/bin/libtool

All better. A better fix is to put the MAMP directory at the END of the $PATH variable, so it doesn't interfere with things.

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

MY INSTALLATION PROCESS WAS FLAWLESS. I AM A WINDOWS CANTERA NINJA.

Resources

On The Web

Following is a list of pertinent web resources related to Cantera, and what the page offers:

Doxygen for Cantera - http://cantera.github.io/docs/doxygen/html/index.html

  • Automatically-generated Doxygen documentation for Cantera

GitHub page for Cantera - http://cantera.github.com/docs/sphinx/html/index.html

  • Download Cantera 2.0 (beta)
  • Get new and improved documentation

Google Code page for Cantera - https://code.google.com/p/cantera/

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

Google Groups page for Cantera - https://groups.google.com/group/cantera-users?pli=1

  • Download old Cantera documentation (PDF files of formal documentation or of presentations about Cantera)
  • 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 the mechanical/chemical engineering combustion course (CHEN 6153) at the University of Utah (2010), 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: