Cantera: Difference between revisions
From charlesreid1
(→Mac) |
|||
| Line 59: | Line 59: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
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 | 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). | ||
== Windows == | == Windows == | ||
Revision as of 18:37, 6 October 2010
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.
Installation
Mac
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 (breaks):
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).
Windows
The following instructions for installing a binary version of Cantera on Windows have been tested on both Windows XP and Windows 7.
- Install Python 2.5 (you will need the Python 2.5.4 installer from here: http://www.python.org/download/releases/2.5.4 ).
- It is strongly recommended that you install Python to the root path "C:\Python25"
- 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)
- Download and run the Windows installer for Cantera 1.7 from Sourceforge: http://sourceforge.net/projects/cantera/
- It is strongly recommended that you install Cantera to the local path "C:\Cantera"
- 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.
- 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.
- Create a new user variable by clicking “New...”
- Set the first variable:
- For variable name, type
PYTHONPATH - For variable value, type
C:\Python25
- For variable name, type
- Set the first variable:
- Set the second variable:
- For variable name, type
PYTHON_CMD - For variable value, type
C:\Python25\python.exe
- For variable name, type
- Set the second variable:
- 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
- The toolbox does not need to be “installed” - it's just a collection of files that needs to be put somewhere
- It is strongly recommended that you put the Sundials toolbox in the directory
C:\sundialsTB
- Point Matlab to the Cantera and Sundials toolboxes
- Open Matlab and click File > Set Path...
- Click “Add with subdirectories”
- Add
C:\Cantera\MATLAB - Add
C:\sundialsTB
- 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_CMDenvironmental variable properly.
Resources
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