Download Cantera User's Guide

Transcript
(draft November 29, 2001)
Fortunately, Fortran 90 provides a mechanism so that we can call functions temperature(object),
setTemperature(object,t) (or any other function) for any type of object. This is done using generic
names. Cantera really does define different function names for each type of object — there is a function
mix temperature() that returns the temperature attribute of a mixture t object, an entirely different
function reac temperature() that does the same for cstr t objects, and so on. But in module
cantera, temperature is declared to be a generic name that any of these functions can be called by.
When a call to temperature is made, the compiler looks at the argument list, and then looks to see if
any function that takes these argument types has been associated with this generic name. If so, the call to
temperature is replaced by one to the appropriate function, and if not, a compile error results.
This procedure is analogous to using generic names for intrinsic Fortran function — if you call sin(x)
with a double precision argument, function dsin(x) is actually called; if x has type real(4), then
function asin(x) is called. Fortran 90 simply extends this capability to any function.
1.8
Units
Cantera uses the SI unit system. The SI units for some common quantities are listed in Table 1.8, along with
conversion factors to cgs units.
Property
Temperature
Pressure
Density
Quantity
Concentration
Viscosity
Thermal Conductivity
1.9
SI unit
K
Pa
kg/m3
kmol
kmol/m3
Pa-s
W/m-K
cgs unit
K
dyne/cm2
gm/cm3
mol
mol/cm3
gm/cm-s
erg/cm-s-K
SI to cgs multiplier
1
10
0.001
1000
0.001
10
105
Useful Constants
The cantera module defines several useful constants, including the ones listed here.
Constant
OneAtm
Avogadro
GasConstant
StefanBoltz
Boltzmann
1.10
Value
1.01325 × 105
6.022136736 × 1026
8314.0
5.6705 × 10−8
GasConstant / Avogadro
Description
Atmospheric pressure in Pascals.
Number of particles in one kmol.
The universal ideal gas constant R̂.
The Stephan-Boltzmann constant σ [W/m2 -K4 ].
Boltzmann’s constant k [J/K].
An Example Program
To see how this all works, let’s look at a complete, functioning Cantera Fortran 90 program. This program
is a simple chemical equilibrium calculator.
10
Chapter 1. Getting Started