Cantera Workshop
Welcome to the First Workshop
on Cantera!
Timeline
1997 1998 1999 2000 2001 2002 2003 2004
1st Cantera Workshop
SourceForge
DARPA/NSF Virtual MixMaster released
Integrated
Prototyping Program 1D Flames
MATLAB Toolbox
Earliest private
versions of Transport Properties
Cantera
User's group established
7/25/04 Cantera Workshop
Preregistered Workshop Attendees
7/25/04 Cantera Workshop
Agenda
9:00 D. Goodwin Introduction to Cantera
9:20 D. Goodwin Defining and Using Phases and Interfaces
9:50 D. Goodwin Reactor Networks
10:15 Dibble, Mack, 20 Homework Problems in Combustion using MATLAB
Mehresh, and Chen, Cantera
UCB
10:40 Break
11:00 D. Goodwin One-Dimensional Flame Simulations
11:30 C. Pantano Using Cantera to Construct Flamelet Libraries for Large-
Caltech Eddy Simulation
12:00 Lunch
1:00 D, Goodwin Cantera C++ Programming
1:20 E. D. Huckaby, Extending Cantera
DOE/NETL
1:40 E. D. Huckaby, Coupling Cantera to Fluent
DOE/NETL
2:00 Discussion / Future directions
7/25/04 Cantera Workshop
Introduction to Cantera
David G. Goodwin
Division of Engineering and
Applied Science
California Institute of Technology
Cantera is a set of software tools for
problems involving kinetics
Some Capabilities: And Some Features:
Thermodynamic properties MATLAB Toolbox
Transport properties Python Interface
Chemical equilibrium C++ kernel
Homogeneous and Fast algorithms
heterogeneous chemistry Object-oriented
Reactor networks
Backward-compatible with
One-dimensional flames Chemkin-II
Electrochemistry
Run under Windows, linux,
Reaction path diagrams Mac OS X, unix, ...
open source
7/25/04 Cantera Workshop
A few things Cantera can do...
Counterflow Diffusion Flame
Non-premixed, ethane/air opposed-jet flame at 1 atm
pressure
7/25/04 Cantera Workshop
Heterogeneous chemistry
Oxidation of a1% methane in air mixture on a 1 cm2 Pt foil.
Pt catalytic combustion mechanism is from Deutschman et al., Proc.
26th Symp. (Intl.) on Combustion,1996, pp. 1747-1754
7/25/04 Cantera Workshop
Transport Properties
Prandtl number of an equilibrium H/O mixture
7/25/04 Cantera Workshop
Chemical Equilibrium
Adiabatic flame temperature for methane/air as a function of
equivalence ratio
7/25/04 Cantera Workshop
Reaction Path Diagrams
view chemical pathways at any point
in a flame, or at any time in a kinetics
simulation
7/25/04 Cantera Workshop
Cantera can be used from applications
written in Fortran, C, C++, ...
Use it to
evaluate thermodynamic and/or transport properties
compute chemical equilibrium
calculate homogeneous and heterogeneous reaction
rates
evaluate liquid/vapor equilibria
...
Use it with commercial CFD packages (Fluent, ...)
7/25/04 Cantera Workshop
Example: a 2D model of a single-chamber
fuel cell
Fortran 90 main program
Cantera used for
Transport properties
Heterogeneous reaction rates in porous electrodes
Multi-domain stiff solver
CH4
H2
CO
O2
CO2
H2O
7/25/04 Cantera Workshop
Another example: a transient model of
SOFC "pattern anode" experiments
C++ application
Cantera used for
thermodynamic properties
heterogeneous reaction rates on two 2D surface phases
and at the 1D "triple-phase boundary"
Surface chemistry
Surface
diffusion Adsorption /
desorption
External circuit
I(t)
Double layer charging
Electrochemistry at the TPB 2D ion current
7/25/04 Cantera Workshop
Validation and Benchmarks
Benchmark Validation
SENKIN / Chemkin-II vs. SENKIN / Cantera
Cantera and Chemkin-II
3000 versions are in excellent
agreement for all
2500 solution variables and
sensitivity coefficients.
2000
Temperature (K)
T(t)
1500 Typical relative
difference in any
1000
component at any time
500
max temperature is one part in 106 or 107
4 error = 0.014 K
10 (T cantera - T chemkin )
0
0 0.2 0.4 0.6 0.8 1
-500
Time (ms)
7/25/04 Cantera Workshop
Benchmark Performance
Constant P, H Problem with Sensitivity Analysis
Cantera is significantly faster for this benchmark on all platforms
tested
(Linux, Windows, OSF/1, IRIX)
Shown:
Compaq Visual Fortran
MS Visual C++
Note: these tests were conducted with an earlier 750 MHz Pii
7/25/04 version of Cantera. Cantera Workshop
Cantera Structure
Cantera Structure
7/25/04 Cantera Workshop
The Cantera MATLAB Toolbox
MATLAB is a widely-used technical r
e 0.8
problem solving environment b
m
u
N 0.7
l
t
Excellent capabilities for numerical d 0.6
n
a
mathematics r 0.5
P
Linear algebra 0.4
4000
ODEs, PDEs 3000
2000 0.6
0.8
1
1000 0.4
0.2
Temperature (K) 0 0
Elemental O/(O+H)
Toolboxes implement application-
specific capabilities
Example: Prandtl number for an
equilibrium O/H mixture, computed
The Cantera toolbox brings kinetics, using multicomponent transport
thermo, and transport functionality to properties
MATLAB
7/25/04 Cantera Workshop
The Cantera Python Interface
Python is an easy-to-use
object-oriented scripting
language
Easy to create graphical
applications
Python comes preinstalled
on most linux and Mac
machines; a version for
Windows is also available
Used in several large-
scale scientific computing
projects for top-level user
environment
Screen shot of MixMaster, a Cantera
application written in Python
7/25/04 Cantera Workshop
Cantera has a similar look and feel in all
environments
MATLAB
gas = GRI30;
set(gas,'T',300.0,'P',OneAtm,'X','CH4:1,O2:2,N2:7.52');
equilibrate(gas,'HP');
disp(gas)
Python
from Cantera import *
gas = GRI30()
gas.set(T = 300.0, P = OneAtm, X = 'CH4:1,O2:2,N2:7.52')
C++
gas.equilibrate('HP')
#include "Cantera.h" print gas
#include "GRI30.h"
#include "equilibrium.h"
main() {
GRI30 gas;
gas.setState_TPX(300.0, OneAtm, "CH4:1,O2:2,N2:7.52");
equilibrate(gas, "HP");
cout << gas;
}
7/25/04 Cantera Workshop
All three of these programs carry out the same
calculation, with the same results
CH2OH 4.114099e-17 4.654961e-17
CH3O 6.575072e-19 7.439468e-19
CH3OH 3.492911e-18 4.080466e-18
temperature 2225.52 K C2H 3.671127e-24 3.350115e-24
pressure 101325 Pa C2H2 9.146744e-22 8.683058e-22
density 0.150193 kg/m^3 C2H3 6.921523e-27 6.824995e-27
mean mol. weight 27.4283 amu C2H4 7.230037e-27 7.394897e-27
C2H5 7.843632e-32 8.310722e-32
1 kg 1 kmol C2H6 5.697162e-33 6.245789e-33
----------- ------------ HCCO 5.366464e-20 8.027556e-20
enthalpy -254590 -6.983e+06 J CH2CO 7.105980e-20 1.089078e-19
internal energy -929223 -2.549e+07 J HCCOH 6.968486e-23 1.068006e-22
entropy 9876.57 2.709e+05 J/K N 1.424539e-08 7.274647e-09
Gibbs function -2.22351e+07 -6.099e+08 J NH 2.359734e-09 1.291754e-09
heat capacity c_p 1514.35 4.154e+04 J/K NH2 9.409152e-10 5.496479e-10
heat capacity c_v 1211.21 3.322e+04 J/K NH3 2.686508e-09 1.668083e-09
NNH 7.555846e-10 7.994703e-10
X Y NO 1.888206e-03 2.065666e-03
------------- ------------ NO2 3.462822e-07 5.808190e-07
H2 3.604526e-03 2.649191e-04 N2O 1.001874e-07 1.607657e-07
H 3.903469e-04 1.434452e-05 HNO 3.366350e-08 3.806438e-08
O 2.156588e-04 1.257973e-04 CN 6.774013e-14 6.425636e-14
O2 4.622237e-03 5.392454e-03 HCN 1.930651e-11 1.902309e-11
OH 2.875407e-03 1.782938e-03 H2CN 5.477443e-18 5.598318e-18
H2O 1.834666e-01 1.205032e-01 HCNN 1.316652e-21 1.969694e-21
HO2 4.989233e-07 6.003949e-07 HCNO 1.020209e-16 1.600336e-16
H2O2 4.573249e-08 5.671420e-08 HOCN 1.131156e-12 1.774372e-12
C 2.217810e-17 9.711895e-18 HNCO 3.864622e-10 6.062186e-10
CH 3.361535e-18 1.595562e-18 NCO 1.543840e-11 2.364990e-11
CH2 9.827346e-18 5.025715e-18 N2 7.085838e-01 7.237005e-01
CH2(S) 5.956345e-19 3.046081e-19 AR 0.000000e+00 0.000000e+00
CH3 6.223564e-17 3.411442e-17 C3H7 3.540964e-47 5.562683e-47
CH4 3.032972e-17 1.773977e-17 C3H8 2.428377e-48 3.904100e-48
CO 8.987939e-03 9.178675e-03 CH2CHO 2.952869e-25 4.634145e-25
CO2 8.536422e-02 1.369701e-01 CH3CHO 5.854760e-26 9.403438e-26
HCO 7.949764e-10 8.410608e-10
CH2O 1.319499e-11 1.444479e-11
7/25/04 Cantera Workshop
The Cantera Kernel
C++ class libraries
Designed for performance
Property caching
Virtual methods used sparingly
Low-level methods written to maximize inlining
CPU-intensive code hand-optimized
Uses standard open-source numerical libraries
BLAS, LAPACK, CVODE, DASPK
7/25/04 Cantera Workshop
What's on the CD?
Documentation Third-party applications
HTML pages documenting Python 2.3.4, Numeric, and
The Cantera Python graphviz installers
Package (Win/Mac)
The C++ kernel
Documents and
presentations describing Binary installers for
input files, F77 interfacing, Windows and Mac platforms
installation procedures, etc. MATLAB toolbox
Some workshop materials Python Package
libraries and header files
Source Code for building C++ or Fortran
The latest version of the applications
full source distribution
7/25/04 Cantera Workshop