|
|
| (10 intermediate revisions by the same user not shown) |
| Line 1: |
Line 1: |
| 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.
| | #REDIRECT [[:Category:Cantera]] |
| | |
| | |
| = Installation =
| |
| | |
| == Mac ==
| |
| | |
| If you're installing Cantera on a Mac, you have to [[Compiling Software|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 <code>preconfig</code> file. This is a wrapper for configure (so when you are ready to configure, you don't run <code>./configure</code>, you run <code>./preconfig</code>). 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 <code>NUMPY_HOME</code> and adding a variable <code>NUMPY_INC_DIR</code>.
| |
| | |
| Before (broken):
| |
| <syntaxhighlight lang="bash">
| |
| NUMPY_HOME=${NUMPY_HOME:="/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/numpy/core/include"}
| |
| </syntaxhighlight>
| |
| | |
| After (fixed):
| |
| <syntaxhighlight lang="bash">
| |
| # 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
| |
| </syntaxhighlight>
| |
| | |
| You can find my preconfig file here: [[Cantera Preconfig]]
| |
| | |
| Your next steps are obvious:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| $ ./preconfig
| |
| $ make
| |
| $ make install
| |
| </syntaxhighlight>
| |
| | |
| === Mac Installation Errors ===
| |
| | |
| If you see this error:
| |
| | |
| <syntaxhighlight lang="bash">
| |
| 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
| |
| </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 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 ==
| |
| | |
| 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 <code>PYTHONPATH</code>
| |
| ### For variable value, type <code>C:\Python25</code>
| |
| ## Set the second variable:
| |
| ### For variable name, type <code>PYTHON_CMD</code>
| |
| ### For variable value, type <code>C:\Python25\python.exe</code>
| |
| ## Click “OK”several times until you've saved everything
| |
| # 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 <code>C:\sundialsTB</code>
| |
| # Point Matlab to the Cantera and Sundials toolboxes
| |
| ## Open Matlab and click File > Set Path...
| |
| ## Click “Add with subdirectories”
| |
| ## Add <code>C:\Cantera\MATLAB</code>
| |
| ## Add <code>C:\sundialsTB</code>
| |
| # To test your installation of Cantera, execute the following command:
| |
| <syntaxhighlight lang="matlab">
| |
| >> gas = GRI30;
| |
| </syntaxhighlight>
| |
| 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 <code>PYTHON_CMD</code> environmental variable properly.
| |
| | |
| = 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:
| |
| * Constant volume batch reactor http://files.charlesmartinreid.com/CanteraLecture_Batch.m
| |
| * Constant pressure batch reactor http://files.charlesmartinreid.com/CanteraLecture_BatchConstP.m
| |
| * Continuously Stirred combustor http://files.charlesmartinreid.com/CanteraLecture_CSTR.m
| |
| | |
| | |
| | |
| | |
| | |
| [[Category:Computers]]
| |
| [[Category:Programs]]
| |
| [[Category:Academic]]
| |