Home
Cantera User's Guide
Contents
1. logLevel Input A log file in XML format transport_log xml is generated during construction of the transport manager containing polynomial fit coefficients etc The value of logLevel 0 4 determines how much detail to write to the log file integer Result Returns an object of type transport_t Description This constructor creates a new transport manager that implements a mixture averaged transport model for ideal gas mixtures The model is very similar to the mixture averaged model desribed by Kee et al 1986 In general the results of this model are less accurate than those of Multi Transport but are far less expensive to compute This manager does not implement expressions for thermal diffusion coefficients If thermal diffusion is important in a problem use the MultiTransport transport manager Example type mixture t mix type transport t tr mix GRIMech30 tr MixTransport mix gri30 tran dat 0 76 Chapter 5 Transport Properties draft November 29 2001 109 setTransport Set the transport manager to one that was previously created by a call to initTransport Syntax call setTransport mix transportMgr Arguments mix Input Output Mixture object type mixture_t transportMgr Input Output Transport manager type transport_ t Description Transport managers may be swapped in or out of a mixture object This capability makes it possible for example to use a multicomponent
2. 7 1 Procedures 7 2 Constructors These functions construct new flow devices 146 MassFlowController Create a new mass flow controller A mass flow controller maintains a specified mass flow rate independent of all other conditions Syntax object MassFlowController Result Returns an object of type lowdev t 99 draft November 29 2001 147 PressureController Create a new pressure controller Syntax object PressureController Result Returns an object of type lowdev t Description This device attempts to maintain a specified upstream pressure by adjusting its mass flow rate It is designed to regulate the exhaust flow rate from a reactor not the inlet flow rate to a reactor i e to decrease the pressure the valve opens wider It should be installed on an outlet of the reactor to be controlled This device will only function correctly if the reactor also has one or more inlets with positive flow rates It also acts as a check valve and does not permit reverse flow under any conditions 7 3 Assignment 148 copy Perform a shallow copy of one flo device to another The contents of dest are overwritten Syntax call copy src dest Arguments src Input Flow controller object type flowdev_t dest Output Flow controller object type flowdev_t 7 4 Setting Options 149 setSetpoint Set the setpoint The units depend on the type of flow control device May be called at any time Syn
3. end do The resulting output is 5 53 325 elements O H E N AR species H2 H O 02 OH H20 H202 C CH CH2 CH2 S CH3 CO CO2 HCO CH20 CH20H CH30 C2H C2H2 C2H3 C2H4 C2H5 C2H6 CH2CO HCCOH N NH NH2 NH3 NO NO2 N20 HNO CN HCN HCNN HCNO HOCN HNCO NCO N2 C3H7 C3H8 CH2CHO CH3 CHO first 10 reactions 204 MM lt gt 02 M O H M lt gt OH M O H2 lt gt H OH O HO2 lt gt OH 02 O H202 lt gt OH HO O CH lt gt H CO O CH2 lt gt H HCO O CH2 S lt gt H2 O CH2 S lt gt H H O CH3 lt gt H CH20 These attributes are in fact correct for GRI Mech 3 0 HO2 CH4 CH30H HCCO NNH H2CN AR Sometimes the constructor function can fail For example constructor GRIMech30 will fail if you don t have CANTERA ROOT set properly since it uses this to find data files it needs to build the mixture 8 Chapter 1 Getting Started draft November 29 2001 Cantera implements a LOGICAL function ready to test whether or not an object is ready to use Before calling a constructor for some object objct ready objct returns FALSE After successful construc tion it returns TRUE Some object constructors also write log files which may contain warning or error messages If the construc tion process fails for no apparent reason check the log file if one exists 1 7 Methods In object oriented languages every class of objects has an associated set of methods or member functi
4. getSpeciesFluxes subroutine 79 getSpeciesNames subroutine 31 getSpeciesViscosities subroutine 79 getThermalDiffCoeffs subroutine 83 gibbs_mass function 55 gibbs_mole function 53 install subroutine 101 intEnergy_mass function 55 96 intEnergy_mole function 52 massFlowRate function 102 massFraction function 34 mass function 97 maxError function 104 maxTemp function 50 114 draft November 29 2001 meanMolecularWeight function 37 mean_X function 36 mean_Y function 36 minTemp function 50 mixture_t constructors 16 20 26 molarDensity function 51 moleFraction function 34 molecularWeight function 31 nAtoms function 29 nElements function 25 nReactions function 26 nSpecies function 25 netStoichCoeff function 68 potentialEnergy function 57 pressure function 52 97 printSummary subroutine 107 productStoichCoeff function 67 reactantStoichCoeff function 66 ready function 22 103 refPressure function 50 reset subroutine 103 residenceTime function 94 restoreState subroutine 24 satPressure function 59 Index satTemperature function 58 saveState subroutine 23 setArea subroutine 89 setConcentrations subroutine 34 setDensity subroutine 42 setEmissivity subroutine 92 setEquationOfState subroutine 60 setExtPressure subroutine 92 setExtRadTemp subroutine 90 setExtTemp subroutine 90 setGains subroutine 103 setHeatTransferCo
5. t Mixture object 6 2 Procedures 6 3 Constructors 119 StirredReactor Construct a stirred reactor for zero dimensional kinetics simulations Syntax object StirredReactor Result Returns an object of type cstr_t 85 draft November 29 2001 Description Objects created using StirredReactor represent generic stirred reactors Depending on the com ponents attached or the values set for options it may represent a closed batch reactor a reactor with a steady flow through it or one reactor in a network The reactor object internally integrates rate equations for volume species and energy in primitive form with no assumption regarding the equation of state It uses the CVODE stiff ODE integrator and can handle typical large reaction mechanisms A reactor object can be viewed as a cylinder with a piston Currently you can set a time constant of the piston motion By choosing an appropriate value you can carry out constant volume simulations constant pressure ones or anything in between The reactor also has a heat transfer coefficient that can be set A value of zero default results in an adiabatic simulation while a very large value produces an isothermal simulation In C more general control of the volume and heat transfer coefficient vs time is possible allowing construction of engine simulators for example Surface chemistry can be included also This will soon be added to the Fortran interface
6. thermodynamic property manager 14 thermodynamic state 38 thermodynamic state setting 39 transport property manager 14 viscosity 79 viscosity bulk 79 volume setting 47 Index 117
7. H20 OH H202 lt gt HO2 H20 2 HO2 lt gt O2 H202 2 HO2 lt gt O2 H202 OH HO2 lt gt 02 H20 TEn Hi odi oH M OMOMGHgHagdaddadudooooN tt Dom t O0 M oo oo 0 0 00 00 00 00 0 0 00 00 0 00000 0 0 44094E 03 51156E 03 36968E 01 13797E 01 42931E 03 16806E 02 13767E 02 11154E 00 21897E 01 66073E 01 19043E 03 32781E 05 55931E 03 28712E 01 13263E 02 13544E 01 28319E 01 22868E 03 70669E 04 21063E 02 15268E 00 32276E 02 48157E 01 23253E 03 13444E 00 26438E 06 27669E 04 18695E 00 getEquilibriumConstants C9 O CO CO O GO O O O D CO CX O GO O O O O O O Co D D QOO O O rxn frop i rrop i netrop i format a 3e14 5 94026 223776 41079 89268 18608 12072 98895 80119 15729 14401 79650 13711 23394 57896 81148 78862 139935 89198 18741 0155 11609 14003 13518 43728 25281 39466 41303 52480 Lm n m n m n m E m n m n m n m n m n m n m E m n m n m n m n m n m E m n m n m E m E T n m n m n m E T n m n m n 06 05 01 03 03 03 04 02 02 02 06 07 05 04 04 03 02 04 05 02 01 02 02 04 01 07 05 02 OOOO OO C9 O O O O O O OO O Oc CX O C CX 10 60 O O 6 O 44000E 03 50919E 03 41109E 00 12904E 01 24323E
8. State 47 draft November 29 2001 t Input Specific entropy J kg K double precision P Input Specific volume m kg double precision Description See the discussion of procedure setState_HP procedure number 59 2 13 Species Ideal Gas Properties The procedures in this section return non dimensional ideal gas thermodynamic properties of the pure species at the standard state pressure F and the mixture temperature T As discussed in Section the properties of any non ideal mixture can be determined given the mechanical equation of state P T p and the pure species properties evaluated for the low density ideal gas limit The procedures below return ar rays of pure species ideal gas properties For those that depend on ln p the values are scaled to a density p Po RT where Pp is the standard state pressure 63 getEnthalpy_RT Get the array of pure species non dimensional enthalpies hy T Po RT k 1 K 2 6 Syntax call getEnthalpy_RT mix h_RT Arguments mix Input Mixture object type mixture_t h_RT Output Array of non dimensional pure species enthalpies double precision array Must be dimensioned at least as large as the number of species in mix 64 getGibbs_RT Get the array of pure species non dimensional Gibbs functions k T Po RT k 1 K 2 7 Syntax call getGibbs_RT mix g_RT 48 Chapter 2 Mixtures draft November 29 2001 Arguments mix Input Mixture object type m
9. The reactor may have an arbitrary number of inlets and outlets each of which may be connected to a flow device such as a mass flow controller a pressure regulator etc Additional reactors may be connected to the other end of the flow device allowing construction of arbitrary reactor networks If an object constructed by StirredReactor is used with default options 1t will simulate an adiabatic constant volume reactor with gas phase chemistry but no surface chemistry More documentation coming soon Example use Cantera type cstr t reactr reactr StirredReactor 120 Reservoir A reservoir is like a reactor except that the state never changes after being initialized No chemistry occurs and the temperature pressure composition and all other properties of the contents remain at their initial values unless explicitly changed These are designed to be connected to reactors to provide specified inlet conditions Syntax object Reservoir Result Returns an object of type cstr_t 86 Chapter 6 Stirred Reactors draft November 29 2001 Example use cantera type cstr t reactr type cstr t upstr type lowdev t mfc install a reservoir upstream from the reactor and connect them through a mass flow controller reactr StirredReactor upstr Reservoir mfc MassFlowController call install mfc upstr reactr 6 4 Assignment 2 1 copy Copy one reactor object to another The contents of dest are over
10. as constructors In Cantera constructors are Fortran functions that return an object The syntax to construct an object is shown below type mixture t gasmix gasmix GRIMech30 After the object is declared but before its first use it is assigned the return value of a constructor function In this example constructor GRIMech30 is called which returns an object representing a gas mixture that conforms to the widely used natural gas combustion mechanism GRI Mech version 3 0 Smith et al 1997 Object construction is always done by assignment as shown here The assignment simple copies the handle from the object returned by GRIMech30 to object gasmix Once this has been done the handle inside gasmix points to a real C object and it is one that models a gas mixture containing the 53 species and 325 reactions of GRI Mech 3 0 1 6 The cantera Module 7 draft November 29 2001 We can check this by printing some attributes of the mixture use cantera type mixture t mix character 10 elnames 5 spnames 53 character 20 rxn mix GRIMech30 write nElements mix nSpecies mix nReactions mix call getElementNames mix elnames write elements write elnames m m 1 nElements mix call getSpeciesNames mix spnames write species write spnames k k 1 nSpecies mix write first 10 reactions do i 1 10 call getReactionString mix i rxn write rxn
11. get the mixture composition Additional procedures that set the composition are described in the next chapter 28 setMoleFractions Set the species mole fractions holding the temperature and mass density fixed Syntax call setMoleFractions mix moleFracs Arguments mix Input Output Mixture object type mixture_t moleFracs Input Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix 29 setMoleFractions_NoNorm Set the species mole fractions without normalizing them to sum to 1 Syntax call setMoleFractions_NoNorm mix moleFracs Arguments 32 Chapter 2 Mixtures draft November 29 2001 mix Input Output Mixture object type mixture_t moleFracs Input Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix Description This procedure is designed for use when perturbing the composition for example when computing Jacobians 30 setMassFractions Set the species mass fractions holding the temperature and mass density fixed Syntax call setMassFractions mix massFracs Arguments mix Input Output Mixture object type mixture_t massFracs Input Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix 31 setMassFractions_NoNorm Set the species mass fractions without normalizing them to sum to 1 Sy
12. integer Internal flag used to signify whether or not the object has been properly constructed 5 2 Procedures 107 Multi Transport Construct a new multicomponent transport manager Syntax object Multi Transport mix database logLevel Arguments mix Input Output Mixture object whose transport properties the transport manager will compute type mixture_t database Input Transport database file character logLevel Input A log file in XML format transport_log xml is generated during construction of the transport manager containing polynomial fit coefficients etc The value of logLevel 0 4 determines how much detail to write to the log file integer 75 draft November 29 2001 Result Returns an object of type transport_t Description This constructor creates a new transport manager that implements a multicomponent transport model for ideal gas mixtures The model is based on that of and Kee et al 1986 See Section for more details Example type mixture t mix type transport t tr mix GRIMech30 tr MultiTransport mix gri30 tran dat 0 108 Mix Transport Construct a new transport manager that uses a mixture averaged formulation Syntax object MixTransport mix database log Level Arguments mix Input Output Mixture object whose transport properties the transport manager will compute type mixture_t database Input Transport database file character
13. reactions and those above a threshold are printed If the temperature had not been changed then the forward and reverse rates of progress would be equal for all reversible reactions getFwdRatesOfProgress getRevRatesOfProgress Example use cantera real 8 frop 500 rrop 500 netrop 500 type mixture t mix character 40 rxn mix GRIMech30 call setState TPX mix 2500 d0 OneAtm H2 2 02 1 5 AR 8 call equilibrate mix TP call setState TP mix 2000 d0 0neAtm call getFwdRatesOfProgress mix frop call getRevRatesOfProgress mix rrop call getNetRatesOf Progress mix netrop 70 Chapter 4 Homogeneous Kinetics 103 draft November 29 2001 do i if abs frop i abs rrop i 1 nReactions mix 4g gis 1 d 10 1 d 10 OF then call getReactionString mix i rxn write 20 20 end if end do Output M lt gt 02 M H M lt gt OH M H2 lt gt H OH HO2 lt gt OH 02 H202 lt gt OH HO2 02 M lt gt HO2 M 2 02 lt gt HO2 02 02 H20 lt gt HO2 H20 02 AR lt gt HO2 AR 02 lt gt O OH M lt gt H2 M H2 lt gt 2 H2 H20 lt gt H2 H20 OH M lt gt H20 M HO2 lt gt O H20 HO2 lt gt 02 H2 HO2 lt gt 2 OH H202 lt gt HO2 H2 H202 lt gt OH H20 OH H2 lt gt H H20 2 OH M lt gt H202 2 OH lt gt O H20 OH HO2 lt gt 02 H20 OH H202 lt gt HO2
14. single phase Note that a phase does not need to be thermodynamically globally stable Diamond is a valid phase of carbon at atmospheric pressure even though graphite is the thermodynamically stable phase 109 draft November 29 2001 110 draft November 29 2001 BIBLIOGRAPHY R T Jacobsen R B Stewart and A F Myers An equation of state for oxygen and nitrogen Adv Cryo Engrg 18 248 1972 R J Kee G Dixon Lewis J Warnatz M E Coltrin and J A Miller A Fortran computer code pack age for the evaluation of gas phase multicomponent transport properties Technical Report SAND86 8246 Sandia National Laboratories 1986 An electronic version of this report may be downloaded from http stokes lance colostate edu chemkinmanualslist html R J Kee F M Rupley and J A Miller Chemkin II A Fortran chemical kinetics package for the analysis of gas phase chemical kinetics Technical Report SAND89 8009 Sandia National Laboratories 1989 W C Reynolds Thermodynamic properties in si Technical report Department of Mechanical Engineering Stanford University 1979 Gregory P Smith David M Golden Michael Frenklach Nigel W Moriarty Boris Eiteneer Mikhail Gold enberg C Thomas Bowman Ronald K Hanson Soonho Song William C Gardiner Jr Vitali V Lis sianski and Zhiwei Qin GRI Mech version 3 0 1997 see http Awww me berkeley edu gri_mech 111 112 draft November 29 2001 addD
15. the transport manager needs a thermodynamic property the mixture object gets it from the thermodynamic property manager and hands it to the transport manager The managers have no direct links making it possible to swap one out for another one of the same type without disrupting the operation of the other property managers The mixture object does handle a few things itself It serves as the interface to the application program maintains lists of species and element properties stores and retrieves data specifying the state internally represented by temperature density and mass fractions and orchestrates property updating when the state has changed mixture_t Object type for mixtures nel integer Number of elements nsp integer Number of species nrxn integer Number of reactions hndl integer Handle encoding pointer to the C object 2 2 Procedures 2 3 Constructors 2 3 1 Reacting Gas Mixtures To carry out a kinetics simulation with Cantera an object representing a chemically reacting mixture is required While such an object can be created using the basic Mixture constructor and explicitly adding all necessary components it is usually more convenient to call a constructor that does all that for you and returns a finished object ready to use in simulations In this section constructors that return objects that model reacting gas mixtures are described These con structors typically parse an input file or files which
16. transport manager before installing a different one Example see the example for procedure 112 viscosity The dynamic viscosity Pa s Syntax result viscosity mix Arguments mix Input Mixture object type mixture_t 78 Chapter 5 Transport Properties draft November 29 2001 Result Returns adouble precision value Description The stress tensor in a Newtonian fluid is given by the expression Ov Ov Ox 2 On Tij P dij tu 0 jApdivv 5 1 where ju is the viscosity and A is the bulk viscosity This function returns the value of 4 computed by the currently installed transport manager 118 getSpeciesViscosities Get the pure species viscosities Pa s Syntax call getSpeciesViscosities mix visc Arguments mix Input Mixture object type mixture_t visc Input Output Array of pure species viscosities double precision array Must be dimensioned at least as large as the number of species in mix Description A common approach to computing the viscosity of a mixture is to use a mixture rule to generate a weighted average of the viscosities of the pure species This procedure returns the viscosities of the pure species that are used in the mixture rule Transport managers that do not compute viscosity using a mixture rule may not implement this procedure 114 getSpeciesFluxes Compute the species net mass fluxes due to diffusion Syntax call getSpeciesFluxes mix ndim grad_
17. 003 130992e 006 622863e 007 018755e 008 319442e 015 076590e 013 165586e 020 000000e 000 073236e 017 850695e 013 988446e 011 411713e 012 271270e 001 000000e 000 000000e 000 000000e 000 000000e 000 000000e 000 63 64 draft November 29 2001 draft November 29 2001 CHAPTER FOUR Homogeneous Kinetics A discussion of homogeneous kinetics models kinetics managers etc will soon replace this box 4 1 Procedures 96 getReactionString Reaction equation string Syntax call getReactionString mix i rxnString Arguments mix Input Mixture object type mixture t i Input Reaction index integer rxnString Output Reaction equation string character Description This procedure generates the reaction equation as a character string The notation of Kee et al 1989 is used In particular 1 The reactants and products are separated by lt gt for reversible reactions and by gt for irreversible ones 2 For pressure dependent falloff reactions in which any species can act as a third body collision partner the participation of the third body is denoted by M If only one species acts as the third body the species name replaces M for example H20 3 For reactions involving a third body but which are always in the low pressure limit rate propor tional to third body concentration the participation of the third body is denote by M
18. 03 15599E 02 12779E 02 10352E 00 20324E 01 77937E 01 18964E 03 32644E 05 55697E 03 28654E 01 12452E 02 12755E 01 24325E 01 13948E 03 68795E 04 10908E 02 14107E 00 18273E 02 46806E 01 18881E 03 10916E 00 22492E 06 23539E 04 18170E 00 Get the equilibrium constants of the reactions in concentration units kmol n 47 where An is the net change in mole numbers in going from reactamts to products 4 1 Procedures 71 draft November 29 2001 Syntax call getEquilibriumConstants mix kc Arguments mix Input Mixture object type mixture_t ke Output Equilibrium constants double precision array Must be dimensioned at least as large as the number of species in mix 104 getCreationRates Get the species chemical creation rates kmol m s Syntax call getCreationRates mix cdot Arguments mix Input Mixture object type mixture_t cdot Output Creation rates double precision array Must be dimensioned at least as large as the number of species in mix Description The creation rate of species k is Cr F YP Op vi Qu 4 2 i Example see the example for procedure 106 105 getDestructionRates Get the species chemical destruction rates kmol m s Syntax call getDestructionRates mix ddot Arguments mix Input Mixture object type mixture_t ddot Output Destruction rates double precision array Must be dimensioned at least as large as the numbe
19. 1245184 0 800000000000000 155555 372874368 0 200000000000000 13 restoreState Restore the mixture state from the data in array state written by a prior call to saveState Syntax call restoreState mix state Arguments mix Input Mixture object type mixture_t state Output Array where state information will be stored double precision array Must be dimensioned at least as large as the number of species in mix 2 Example see the example for procedure 12 24 Chapter 2 Mixtures draft November 29 2001 2 5 Number of Elements Species and Reactions 14 nElements Number of elements Syntax result nElements mix Arguments mix Input Mixture object type mixture_t Result Returns a integer value Example nel nElements mix 15 nSpecies Number of species Syntax result nSpecies mix Arguments mix Input Mixture object type mixture_t Result Returns a integer value Example use cantera type mixture t mix mix GRIMech30 write number of species nSpecies mix Output number of species 53 2 5 Number of Elements Species and Reactions 25 draft November 29 2001 16 nReactions Number of reactions Syntax result nReactions mix Arguments mix Input Mixture object type mixture_t Result Returns a integer value Example use cantera type mixture t mix mix GRIMech30 write number of reactions nReactions mix Output number of
20. 2o h20 Water write Tsat 0 1 atm satTemperature h2o OneAtm Output Tsat 1 atm 373 177232956890 92 satPressure The saturation pressure vapor pressure at temperature t K An error results if T gt T i Syntax result satPressure mix t Arguments mix Input Mixture object type mixture_t t Input Temperature K double precision Result Returns adouble precision value Example use cantera type mixture t h2o h20 Water write Psat 300 K satPressure h20 300 d0 Output Psat 300 K 3528 21380534104 2 19 Equations of State 93 equationOfState Return the equation of state object Syntax result equationOfState mix 2 19 Equations of State 59 draft November 29 2001 Arguments mix Input Output Mixture object type mixture_t Result Returns a type eos_t value 94 setEquationOfState Set the equation of state Syntax call setEquationOfState mix eos Arguments mix Input Output Mixture object type mixture_t eos Input Output Equation of state object type eos_t 60 Chapter 2 Mixtures draft November 29 2001 CHAPTER THREE Chemical Equilibrium A discussion of chemical equilibrium the solver algorithm etc will soon replace this box 95 equilibrate Chemically equilibrate a mixture Syntax call eguilibrate mix propPair Arguments mix Input Output Mixture object type mixture_t propPair Input Proper
21. 5e 018 686218e 020 627499e 020 000000e 000 000000e 000 000000e 000 000000e 000 000000e 000 N2 7 52 OOGOGOGCO0R Rp JPNDNRPOOUVUNnNRO RRA RNRPRPO 6 371e 006 2 412e 007 2 692e 005 5 809e 008 4 109e 004 3 277e 004 802905e 005 276898e 006 380495e 004 136037e 002 651391e 003 106474e 001 186585e 006 059304e 008 804749e 019 011257e 020 259063e 020 000000e 000 212273e 019 414648e 019 355844e 003 333077e 001 7477780e 011 641078e 013 270211e 018 890919e 020 831259e 020 000000e 000 000000e 000 000000e 000 000000e 000 000000e 000 Chapter 3 Chemical Equilibrium Cj Cj uU K K K C2H6 HCCO CH2CO HCCOH NH NH2 NH3 NNH NO NO2 N20 HNO CN HCN H2CN HCNN HCNO HOCN HNCO NCO N2 AR C3H7 C3H8 CH2 CHO CH3 CHO O OO0O 00 1hNiBUi n 0007 e PN N t N99 UB OOOO draft November 29 2001 000000e 000 000000e 000 000000e 000 000000e 000 723857e 009 297876e 010 590979e 010 043624e 010 194905e 010 077021e 003 281909e 006 649231e 007 693730e 008 467159e 015 246531e 013 061030e 020 000000e 000 903304e 018 190410e 013 138356e 011 247139e 012 183390e 001 000000e 000 000000e 000 000000e 000 000000e 000 000000e 000 OOOO ON WNIT FPFRPOWANINWNHNWNHNUWONN DOO OC FO 000000e 000 000000e 000 000000e 000 000000e 000 390824e 009 874303e 010 211144e 011 488376e 010 301699e 010 336222e
22. 65 draft November 29 2001 Example use cantera character 30 str type mixture t mix mix GRIMech30 do i 1 20 call getReactionString mix i str write 10 i str 10 format i2 a end do return Output 1 2 O M lt gt 02 M 2 O H M lt gt OH M 3 O H2 lt gt H OH 4 O HO2 lt gt OH O2 5 O H202 lt gt OH HO2 6 O CH lt gt H CO 7 O CH2 lt gt H HCO 8 O CH2 S lt gt H2 CO 9 O CH2 S lt gt H HCO 10 O CH3 lt gt H CH20 11 O CH4 lt gt OH CH3 12 O CO M lt gt CO2 M 13 O HCO lt gt OH CO 14 O HCO lt gt H CO2 15 O CH20 lt gt OH HCO 16 O CH20H lt gt OH CH20 17 O CH30 lt gt OH CH20 18 O CH30H lt gt OH CH20H 19 O CH30H lt gt OH CH30 20 O C2H lt gt CH CO 97 reactantStoichCoeff The stoichiometric coefficient for species k as a reactant in reaction i Syntax result reactantStoichCoeff mix k i Arguments mix Input Mixture object type mixture_t 66 Chapter 4 Homogeneous Kinetics draft November 29 2001 k Input Species index integer i Input Reaction index integer Result Returns adouble precision value Description A given species may participate in a reaction as a reactant a product or both This function returns the number of molecules of the kt species appearing on the reactant side of the reaction equation It does n
23. Atm x1 call getSpeciesFluxes mix 3 gradx gradt fluxes don 1 3 write 10 n n gradt n n 10 format coordinate direction i1 dT dx i1 gL3 5 species 15x dX dx il mass flux do k 1 nsp write 20 name k gradx k n fluxes k n 20 format a 2e14 5 end do end do Output coordinate direction 1 dT dx1 1000 0 species dX dx1 mass flux O 0 10000E 00 0 72034E 05 02 0 10000E 00 0 88312E 05 N 0 10000E 00 0 56038E 05 NO 0 10000E 00 0 81268E 05 NO2 0 10000E 00 0 14005E 04 N20 0 10000E 00 0 86180E 05 N2 0 10000E 00 0 90551E 05 AR 0 10000E 00 0 10291E 04 5 2 Procedures 81 draft November 29 2001 coordinate direction 2 dT dx2 500 00 species dX dx2 mass flux O 0 10000E 00 0 67305E 05 02 0 00000E 00 0 21224E 05 N 0 30000E 00 0 18372E 04 NO 0 20000E 00 0 19739E 04 NO2 0 00000E 00 0 32196E 05 N20 0 20000E 00 0 17896E 04 N2 0 00000E 00 0 18281E 05 AR 0 20000E 00 0 20653E 04 coordinate direction 3 dT dx3 800 00 species dX dx3 mass flux O 0 00000E 00 0 15068E 04 02 0 10000E 00 0 10916E 04 N 0 20000E 00 0 11766E 04 NO 0 30000E 00 0 27733E 04 NO2 0 10000E 00 0 97117E 05 N20 0 10000E 00 0 82877E 05 N2 0 10000E 00 0 74848E 05 AR 0 10000E 00 0 98637E 05 115 getMultiDiffCoeffs Get the multicomponent diffusion coefficients m s This procedure may not be implemented by all trans port managers If not the multiDiff array will b
24. Cantera User s Guide Fortran Version Release 1 2 D G Goodwin November 2001 Division of Engineering and Applied Science California Institute of Technology Pasadena CA E mail dgoodwin caltech edu draft November 29 2001 CONTENTS 1 Getting Started 3 Wile Whatis Cantera s ai a a Sew Sw Sh he ee ee ede ce ne ke as 3 12 Typical Applications s s os is 3 1 3 Installing Cantera ose oe hee be ca he ed 2 1 4 Running Stand Alone Applications ks 6 1 5 The Cantera Fortran 90 Interface lt lt es 6 L6 The cantera Module sisuta eao oe ths Boe HS AL Ga em de aint ai a od as 6 MER Ico 5506 A as m ene Sie Bo en a Soe Gi Gee Gud oe Gi Sige G aoe e 9 I IM TT TIT 10 1 9 UsetubConstaBts oe ee sooo monem oem Xe Rem onde te og Rm Rogat go e EM 10 1 10 An Example Program cae Be k k de ee Qt a X t oi 10 LIT Summary 202 c2 Gs ee es Boi te Be a Ros e obse ee A a det 11 2 Mixtures 13 2 1 iMuxture ODJects ies oats e Ca oe addin amie AC qe EUR UR eee a Ven dg 13 2 24 Procedures s r sx poce S eG wee we a he we we o9 14 2 3 GConstruetOfS 45 s suo omes daca Me Ab OS RO GS CR OE S Ree Be A we RR we RA eat cx 14 2 44 JM lities iom E uo aos mos euo eon are oe eL he d Doce a ds 21 2 5 Number of Elements Species and Reactions lt o e pee eee 25 2 0 Mixture Creati h s s s s so goe o SE ERG bee Bia ee RU ee bad 26 2 7 Properties ofthe Elements lt oos ocs acesar er RR E 27 2 8 Properties of th
25. Mech30 17 Hydrogen 19 MassFlowController 99 Methane 19 MixTransport 76 Mixture 26 MultiTransport 75 Nitrogen 18 Oxygen 20 PressureController 100 Reservoir 86 StirredReactor 85 Water 18 density 51 density molar 51 setting 42 energy internal 47 potential 56 enthalpy molar 52 non dimensional 48 pure species 48 setting 46 116 draft November 29 2001 specific 54 entropy molar 53 non dimensional 49 settting 47 specific 55 environment variables CANTERA_DATA_DIR 22 equation of state 59 equation of state specifying 60 equilibrium chemical 61 format CK 16 free energy Gibbs 48 Giibs 55 molar Gibbs 53 generic names 10 Gibbs function molar 53 non dimensional 48 pure species 48 specific 55 handle 7 heat capacity constant pressure 53 constant volume 54 molar 53 54 internal energy molar 52 setting 47 specific 55 Jacobian 46 kernel 6 kinetics manager 14 member functions 9 methods 9 mixture rule 79 mixtures 13 Newton 46 Index draft November 29 2001 potential chemical 54 potential energy 56 pressure 52 pressure reference 50 setting 47 standard 50 properties molar 52 species thermodynamic 48 specific 54 thermodynamic 38 specific heat constant pressure 49 56 constant volume 56 non dimensional 49 state thermodynamic 38 temperature 51 temperature maximum 50 minimum 50 setting 42
26. Syntax result maxTemp mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value 69 refPressure The reference standard state pressure R Species thermodynamic property data are specified as a function of temperature at pressure 75 Usually P is 1 atm but some property data sources use 1 bar Any choice is acceptable as long as the data for all species in the mixture use the same one Syntax result refPressure mix Arguments mix Input Output Mixture object type mixture_t Result Returns a double precision value 50 Chapter 2 Mixtures draft November 29 2001 2 15 Mixture Thermodynamic Properties 2 15 1 Temperature Pressure and Density 70 temperature The temperature K Syntax result temperature mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 71 density The density kg m Syntax result density mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 72 molarDensity The number of moles per unit volume kmol m Syntax result molarDensity mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value 2 15 Mixture Thermodynamic Properties 51 draft November 29 2001 73 pressure The pressure Pa Syntax result pressure mix Arguments mix Input Mixtur
27. X grad_T fluxes Arguments mix Input Mixture object type mixture_t ndim Input Dimensionality 1 2 or 3 integer 5 2 Procedures 79 draft November 29 2001 grad_X Input Output Array of species mole fraction gradients The k n entry is the gradient of species k in coordinate direction n double precision grad_T Input Temperature gradient array By default thermal diffusion is included using the temperature gradient specified here Set to zero to compute the result without thermal diffusion double precision fluxes Output Array of species diffusive mass fluxes double precision Description This procedure returns the diffusive mass fluxes for all species given the local gradients in mole fraction and temperature The diffusive mass flux vector for species k is given by Jk PV kYk 5 2 where V is the diffusion velocity of species k The diffusive mass flux satisfies dco 5 3 k The inputs to this procedure are a mixture object which defines the local thermodynamic state the array of mole fraction gradients with elements OX grad X k n t 5 4 OL and the one dimensional temperature gradient array OT grad_T n 5 5 OL Thermal diffusion is included if any component of the temperature gradient is non zero There are several advantages to calling this procedure rather than evaluating the transport properties and then forming the flux expression in your application
28. a folder There you will find project and workspace files for Cantera To load the Cantera Fortran workspace into Visual Studio open file Cantera_F90 dsw 1 3 2 unix linux If you use unix or linux you will need to download the source code and build Cantera yourself unless the web site contains a binary version for your platform To build everything you will need both a C compiler and a Fortran 90 compiler A configuration script is used to set parameters for Makefiles In most cases the script correctly configures Cantera without problem 1 3 3 The Macintosh Cantera has not been ported to the Macintosh platform but there is no reason it cannot be If you successfully port it to the Macintosh please let us know and we will add the necessary files to the standard distribution Note that the Cantera Fortran interface requires Fortran 90 so if you are using the free g77 compiler you will need to upgrade 1 3 4 Environment Variables Before using Cantera environment variable CANTERA ROOT should be set to the top level Can tera directory If you are using Cantera on a PC running Windows you can alternatively set WIN CANTERA ROOT This is defined so that users of unix like environments that run under Win dows e g CygWin can define CANTERA ROOT in unix like format usr local cantera 1 2 and WIN CANTERA ROOT in DOS like format C NCANTERA 1 2 In addition you can optionally set CANTERA DATA DIR to a director
29. absolute entropy have been adjusted to match the values in the JANAF tables These objects should therefore be thermodymamically consistent with most gas mixture objects that use thermodynamic data obtained from fits to JANAF data 3 Water Constructs an object representing pure water H5O Syntax object Water Result Returns an object of type mixture_t Description The equation of state parameterization is taken from the compilation by Reynolds 1979 The original source is The standard state enthalpy of formation and the absolute entropy have been adjusted to match the values in the JANAF tables Example type substance t h2o h20 Water 4 Nitrogen Construct an object representing nitrogen Np Syntax object 2 Nitrogen Result Returns an object of type mixture t 18 Chapter 2 Mixtures draft November 29 2001 Description The equation of state parameterization is taken from the compilation by Reynolds 1979 The original source is Jacobsen et al 1972 The standard state enthalpy of formation and the absolute entropy have been adjusted to match the values in the JANAF tables Example type substance t subst subst Nitrogen 5 Methane Construct a pure substance object representing methane CH4 Syntax object Methane Result Returns an object of type mixture_t Description The equation of state parameterization is taken from the compilation by Reynolds 1979 The original s
30. and mole fractions holding the density fixed Syntax call setState TX mix t moleFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision moleFracs Input Output Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix 44 Chapter 2 Mixtures draft November 29 2001 56 setState_TY Set the temperature and mass fractions holding the density fixed Syntax call setState_TY mix t massFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision massFracs Input Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix 57 setState RX Set the density and mole fractions holding the temperature fixed Syntax call setState RX mix density moleFracs Arguments mix Input Output Mixture object type mixture_t density Input Density kg m double precision moleFracs Input Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix 58 setState_RY Set the density and mass fractions holding the temperature fixed Syntax call setState RY mix density y Arguments mix Input Output Mixture object type mixture_t density Input Density kg m double precision y Input Species mass fra
31. 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 SI unit cgs unit SI to cgs multiplier Temperature K K 1 Pressure Pa dyne cm 10 Density kg m gm cm 0 001 Quantity kmol mol 1000 Concentration kmol m mol cm 0 001 Viscosity Pa s gm cm s 10 Thermal Conductivity W m K erg cm s K 10 1 9 Useful Constants The cantera module defines several useful constants including the ones listed here Constant Value Description OneAtm 1 01325 x 10 Atmospheric pressure in Pascals Avogadro 6 022136736 x 10 Number of particles in one kmol GasConstant 8314 0 The universal ideal gas constant R StefanBoltz 5 6705 x 1078 The Stephan Boltzmann constant c W n K Boltzmann GasConstant Avogadro Boltzma
32. ates mix cdot call getDestructionRates mix ddot 4 1 Procedures 73 draft November 29 2001 call getNetProductionRates mix wdot call getSpeciesNames mix names call getConcentrations mix conc do k 1 nSpecies mix if wdot k gt 1 d 10 then write 20 names k cdot k ddot k wdot k conc k ddot k 20 format a 4e14 5 end if end do Output H 0 39176E 02 0 21081E 02 0 18095E 02 0 51077E 06 O 0 42994E 02 0 32117E 02 0 10877E 02 0 58471E 06 02 0 14675E 02 0 67536E 01 0 79217E 01 0 40874E 04 H20 0 53859E 02 0 24310E 02 0 29549E 02 0 44237E 04 H202 0 17831E 00 0 14701E 00 0 31294E 01 0 11045E 07 Example 4 1 In the example below getNetProductionRates is used to evaluate the right hand side of the species equation for a constant volume kinetics simulation dY dt vx My p type mixture t mix parameter KMAX 100 double precision wdot KMAX double precision wt KMAX call getNetProductionRates mix wdot call getMolecularWeights mix wt rho density mix do k 1 nSpecies mix ydot k wdot k wt k rho end do 74 Chapter 4 Homogeneous Kinetics draft November 29 2001 CHAPTER FIVE Transport Properties A discussion of the theory of transport properties and the transport models implemented in Cantera will soon replace this box 5 1 Derived Types transport_t Derived type for transport managers hndl integer Handle encoding pointer to the C object ok
33. ation is used to represent the thermodynamic properties of the individual species See Kinetics The CK_Kinetics kinetics manager is used for homogeneous kinetics See Chapter Transport The NullTransport transport manager is installed disabling evaluation of transport prop erties until another manager is installed by calling setTransport Other compatible transport managers include MultiTransport and MixTransport Homogeneous Kinetics The CK_Kinetics model for homogeneous kinetics is used See chapter for more information on this kinetics model Transport Properties Transport properties are disabled by default since many applications do not require them Any supported transport property model can be used including MultiTransport and MixTrans port which are compatible with the multicomponent and mixture averaged models respectively de scribed by Kee et al 1986 Syntax object CKGas inputFile thermoFile iValidate Arguments inputFile Input Input file The input file defines the elements species and reactions the mixture will contain It is a text file and must be in the format specified in Kee et al 1989 This file format is widely used to describe gas phase reaction mechanisms and several web sites have reaction mechanisms in CK format available for download A partial list of such sites is maintained at the Cantera User s Group site http groups yahoo com group cantera If omitted an empty mixture o
34. ay of species molar property values double precision array Must be di mensioned at least as large as the number of species in mix Result Returns a double precision value 39 mean Y Return gt Qi Ys the mass fraction weighted mean value of pure species specific property Q Syntax result mean Y mix O Arguments mix Input Mixture object type mixture t Q Input Array of species specific property values double precision array Must be dimensioned at least as large as the number of species in mix Result Returns a double precision value 36 Chapter 2 Mixtures draft November 29 2001 40 meanMolecularWeight The mean molecular weight amu Syntax result meanMolecularWeight mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value Description The mean molecular weight is defined by M X MX 2 1 k An equivalent alternative expression is 1 Yk ea 2 2 2 x 2 2 See Also molecularWeight 41 sum_xlogQ Given a vector Q returns gt Xy log Qk Syntax result sum_xlogQ mix O Arguments mix Input Mixture object type mixture_t Q Output Array of species property values double precision array Must be dimen sioned at least as large as the number of species in mix Result Returns a double precision value 2 10 Mean Properties 37 draft November 29 2001 This box will be replaced by an introduction discussing equations of sta
35. ber 29 2001 1 Put the statement use cantera at the top of any program unit where you want to use Cantera 2 Declare one or more objects 3 Construct the objects that you declared by assigning them the return value of a constructor function 4 Use the object in your program In the following chapters the objects Cantera implements their constructors and their methods will be described in detail Many examples will also be given You should try programming a few of these yourself to verify that you get the same results as shown here Once you have done that you re ready to use Cantera for your own applications 12 Chapter 1 Getting Started draft November 29 2001 CHAPTER TWO Mixtures Some of the most useful objects Cantera provides are ones representing mixtures Mixture objects have a modular structure allowing many different types of mixtures to be simulated by combining different mixture components You can build a mixture object to suit your needs by selecting an equation of state a model for homogeneous kinetics optional and one for transport properties also optional You can then specify the elements that may be present in the mixture add species composed of these elements and add reactions among these species Mixture objects also can be used to model pure substances by adding only one species to the mixture If you like you can carry out this process of mixture construction by calling Fortran procedur
36. bject is returned Cantera actually defines several extensions to the format of Kee et al 1989 See Appendix for a complete description of CK format with Cantera extensions character thermoFile Input CK format species property database Species property data may be specified either in the THERMO block of the input file or in thermoFile If species data is present in both files for some species the input file takes precedence Note that while thermoFile may be any CK format file only its THERMO section will be read If thermoFile is an empty string then all species data must be contained in the input file character We refer to this format as CK format 16 Chapter 2 Mixtures draft November 29 2001 iValidate Input This flag determines the degree to which the reaction mechanism is validated as the file is parsed If omitted or zero only basic validation that can be performed quickly is done If non zero extensive and possibly slow validation of the mechanism will be performed integer Result Returns an object of type mixture_t Example type mixture t mix1 mix2 mix3 all species data in mymech inp mixl CKGas mymech inp look for species data in thrm dat if not in mech2 inp mix2 CKGas mech2 inp thrm dat turn on extra mechanism validation mix3 CKGas mech3 inp 1 See Also addDirectory GRIMech30 2 GRIMech30 This constructor builds a mixture object correspo
37. c not yet implemented 2 Properties of the Elements The elements in a mixture are the entities that species are composed from and must be conserved by re actions Usually these correspond to elements of the periodic table or one of their isotopes However for reactions involving charged species it is useful to define some charged entity usually an electron as an element to insure that all reactions conserve charge 19 getElementNames Get the names of the elements 2 7 Properties of the Elements 27 draft November 29 2001 Syntax call getElementNames mix enames Arguments mix Input Mixture object type mixture_t enames Output Element names character array Must be dimensioned at least as large as the number of elements in mix Description The element names may be strings of any length If they names are longer than the number of charac ters in each entry of the enames array the returned names will be truncated 20 elementindex Index number of an element Syntax result elementIndex mix name Arguments mix Input Mixture object type mixture_t name Input Element name character Result Returns a integer value If the element is not present in the mixture the value 1 is returned Description The index number corresponds to the order in which the element was added to the mixture The first element added has index number 1 the second has index number 2 and so on All arrays
38. ctions double precision array Must be dimensioned at least as large as the number of species in mix 2 12 The Thermodynamic State 45 59 draft November 29 2001 setState_HP Set the specific enthalpy and pressure holding the composition fixed Syntax call setState HP mix t p Arguments mix Input Output Mixture object type mixture_t t Input Specific enthaply J kg double precision P Input Pressure Pa double precision Description This procedure uses a Newton method to find the temperature at which the specific enthalpy has the desired value The iteration proceeds until the temperature changes by less than 0 001 K At this point the state is set to the new temperature value and the procedure returns The iterations are done at constant pressure and composition This algorithm always takes at least one Newton step Therefore small perturbations to the input enthalpy should produce a first order change in temperature even if it is well below the temperature error tolerance allowing its use in routines that calculate derivatives or Jacobians To test this in the example below the specific heat is calculated numerically using this procedure and compared to the value obtained directly from its parameterization here a polynomial Note that this is not the most direct way to calculate c numerically normally T would be perturbed not A Example use cantera real 8 h0 t1 t2 state 100 ty
39. culated from Qout hA T To eA T T p 6 1 See also setArea setEmissivity setExtRadTemp Can be changed at any time Syntax call setExtTemp reac ts Arguments reac Input Output Reactor object type cstr_t ts Input External temperature double precision Example use cantera type cstr t r r StirredReactor call setExtTemp r 500 d0 27 setExtRadTemp Set the external temperature for radiation By default this is the same as the temperature set by setExtTemp But if setExtRadTemp is called then subsequent calls to setExtTemp do not modify the value set here Can be changed at any time See Eq 6 1 Syntax call setExtRadTemp reac trad Arguments reac Input Output Reactor object type cstr_t trad Input External temperature for radiation double precision Example use cantera type cstr t jet jet StirredReactor call setExtTemp jet 1000 d0 call setExtRadTemp jet 300 d0 90 Chapter 6 Stirred Reactors draft November 29 2001 128 setHeatTransferCoeff Set the heat transfer coefficient W m K Default 0 d0 See Eq 6 1 May be changed at any time Syntax call setHeatTransferCoeff reac h Arguments reac Input Output Reactor object type cstr_t h Input Heat transfer coefficient double precision Example use cantera type cstr t r r StirredReactor call setHeatTransferCoeff r 10 d0 129 setVDotCoeff The equation used to compute the rate at which th
40. dimension the mean beam length in the optically thin limit In the very optically thick limit it is unlikely that the radiative loss can be computed with a stirred reactor model since the wall boundary layers may be optically thick Example use cantera type cstr t r r StirredReactor call setEmissivity r 0 001 131 setExtPressure Set the external pressure Pa Syntax call setExtPressure reac pO Arguments reac Input Output Reactor object type cstr_t po Input External pressure double precision Description This pressure is used to form the pressure difference used to evaluate the rate at which the volume changes Example use cantera type cstr t r r StirredReactor call setExtPressure r OneAtm 92 Chapter 6 Stirred Reactors draft November 29 2001 6 6 Specifying the Mixture 132 setMixture Specify the mixture contained in the reactor Syntax call setMixture reac mix Arguments reac Input Output Reactor object type cstr_t mix Input Output Mixture object type mixture_t Description Note that a pointer to this substance is stored and as the integration proceeds the state of the mixture is modified Nevertheless one mixture object can be used for multiple reactors When advance is called for each reactor the mixture state is set to the appropriate state for that reactor Example use cantera type mixture t gas type cstr t reactrl reactr2 create the gas mi
41. e Species cues eoe daa 29 2 9 Mixture Composition k p ek a aa pe e a k e E Ea e e Ee Aia 32 2 10 Mean Properties o o ee 36 2 11 Procedures x Vk e nd a in d a RC CENE a a 38 2 12 The Thermodynamic State s se dde om ra a a 2 a prs 38 2 13 Species Ideal Gas Properties es 48 2 14 Attributes of the Parameterization se sa les 49 2 15 Mixture Thermodynamic Properties 2 2 ee 51 2 16 Potential Energy cee oz oko dada ee OX Soy 8 ee 56 2 17 Critical State Properties eis ase do aia ee 57 2 18 Satur tion Propertiess 4 us gon ao aa AAA Go qus 58 2 19 Equations Of State 2 0 08 gooie Een a uem d 9 a a er Rode a be 59 3 Chemical Equilibrium 4 Homogeneous Kinetics 4l Procedures 45 2 s o owe war ew Gee eure a E exe Ged 5 Transport Properties 5 Derived Types vik ge aem tA Ee Aceh PA ow dus eR BEA 5 2 Procedures doi x ees AA Ge Au De B A Bee a Cue e ee 6 Stirred Reactors 6 1 Reactor ObJeCIS sose so as k a ae X ROAD ML cs 6 2 Procedures 3 3 asthe a ek a wad SX e WU NONE Ed 6 3 CONSTTUC LS 2 2 4 24 ce een a Oe Oe a Aa da OA JAssighim nt 4 0 ue GRO AAA RE RE E EE A 65 Setting Options vk secadero ek a RR Oe RE A E E A 66 Specifying the Mixture s socra vow x kee eR oko vain 6 7 Operation so ue oko eae Et PA quu x oe m a tipi gae 6 8 Reactor Attributes lens 6 9 Mixture Attributes lll less 7 Flow Devices Tel Procedures 5 pas fe b A SER A A at ee e B AED E Gea 7 2 Con
42. e left unchanged and ierr will be set to a negative number Syntax call getMultiDiffCoeffs mix ldim multiDiff Arguments mix Input Mixture object type mixture_t Idim Input Leading dimension of multiDiff Must be at least as large as the number of species in mix integer multiDiff Input Two dimensional array of multicomponent diffusion coefficients double preci sion array Must be dimensioned at least as large as the number of species in mix 82 Chapter 5 Transport Properties draft November 29 2001 116 thermalConductivity Thermal conductivity W m K Syntax result thermalConductivity mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 117 getThermalDiffCoeffs Get the array of thermal diffusion coefficients Syntax call getThermalDiffCoeffs mix dt Arguments mix Input Mixture object type mixture t dt Output Thermal diffusion coefficients double precision array Must be dimensioned at least as large as the number of species in mix 118 setOptions Set transport options Syntax call setOptions linearSolver GMRES m GMRES eps Arguments linearSolver Input Linear algebra solver to use Valid values are LU LU decomposition and GMRES GMRES iterative solver This setting only affects those transport managers that solve systems of linear equations in order to compute the transport properties Specifying GM RES
43. e object type mixture_t Result Returns a double precision value 2 15 2 Molar Mixture Properties The procedures in this section all return molar thermodynamic properties The names all end in_ mole which should be read as per mole 74 enthalpy_mole Molar enthalpy J kmol Syntax result enthalpy_mole mix Arguments mix Input Output Mixture object type mixture_t Result Returns adouble precision value 75 intEnergy_mole Molar internal energy J kmol Syntax result intEnergy mole mix Arguments mix Input Output Mixture object type mixture_t 52 Chapter 2 Mixtures draft November 29 2001 Result Returns adouble precision value 76 entropy_mole Molar entropy J kmol K Syntax result entropy_mole mix Arguments mix Input Output Mixture object type mixture_t Result Returns a double precision value 77 gibbs mole Molar Gibbs function J kmol K Syntax result gibbs_mole mix Arguments mix Input Output Mixture object type mixture_t Result Returns adouble precision value 78 cp_mole Molar heat capacity at constant pressure J kmol K Syntax result cp_mole mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 2 15 Mixture Thermodynamic Properties 53 draft November 29 2001 79 cv mole Molar heat capacity at constant volume J kmol K Syntax result cv mole
44. e reactor volume changes in response to a pressure differ ence is Pop V K Y 6 2 Pext where V is the initial volume The inclusion of V in this expression is done only so that K will have units of s May be changed at any time Syntax call setVDotCoeff reac k Arguments reac Input Output Reactor object type cstr_t k Input Coefficient determining rate at which volume changes in response to a pressure difference double precision Description The default value is zero which results in the volume being held constant To conduct a constant pressure simuulation set P x to the initial pressure and set K faster than characteristic rates for your problem It is always a good idea to examine the constancy of the pressure in the output Example use cantera type cstr t r r StirredReactor call setVdotCoeff r 1 d8 6 5 Setting Options 91 draft November 29 2001 130 setEmissivity Set the emissivity May be changed at any time See Eq 6 1 May be changed at any time Syntax call setEmissivity reac emis Arguments reac Input Output Reactor object type cstr_t emis Input Emissivity double precision Description The treatment of radiation here is approximate at best The emissivity is defined here such that the net radiative power loss from the gas to the walls is eAc T TA Note that this is the emissivity of the gas not the walls and will depend on a characteristic reactor
45. eff subroutine 91 setInitialTime subroutine 88 setInitialVolume subroutine 87 setMassFractions_NoNorm subroutine 33 setMassFractions subroutine 33 setMaxStep subroutine 88 setMixture subroutine 93 setMoleFractions_NoNorm subroutine 32 setMoleFractions subroutine 32 setOptions subroutine 83 setPotentialEnergy subroutine 56 setPressure subroutine 44 setSetpoint subroutine 100 Index draft November 29 2001 setState_HP subroutine 46 setState_PX subroutine 43 setState_PY subroutine 43 setState_RX subroutine 45 setState_RY subroutine 45 setState_SP subroutine 47 setState SV subroutine 47 setState TPX subroutine 39 setState TPY subroutine 40 41 setState TP subroutine 43 setState TRX subroutine 41 setState TRY subroutine 42 setState TR subroutine 44 setState TX subroutine 44 setState TY subroutine 45 setState UV subroutine 47 setTemperature subroutine 42 setTransport subroutine 77 setVDotCoeff subroutine 91 speciesIndex function 30 sum_xlogQ function 37 temperature function 51 96 thermalConductivity function 83 time function 95 115 transportMgr function 78 transport_t constructors 75 76 update subroutine 102 upstream function 101 viscosity function 78 volume function 95 bulk viscosity 79 CANTERA_DATA_DIR 22 chemical equilibrium 61 chemical potential 54 CK format 16 concentration 51 constructors 7 CKGas 16 GRI
46. era real 8 pcoeff type mixture t mix mix GRIMech30 inh speciesIndex mix NH write Reactions in GRI Mech 3 0 with NH as a product do i 1 nReactions mix pcoeff productStoichCoeff mix inh i if pcoeff gt 0 d0 write reaction i end do Output Reactions in GRI Mech 3 0 with NH as a product reaction 200 reaction 202 reaction 203 reaction 208 reaction 223 reaction 232 reaction 242 reaction 243 reaction 262 reaction 269 99 netStoichCoeff The net stoichiometric coefficient for species k in reaction i 68 Chapter 4 Homogeneous Kinetics draft November 29 2001 Syntax result netStoichCoeff mix k i Arguments mix Input Mixture object type mixture_t k Input Species index integer i Input Reaction index integer Result Returns a double precision value Description This function returns the difference between the product and reactant stoichiometric coefficients 100 getFwdRatesOfProgress Get the forward rates of progress QU for the reactions kmol m s Syntax call getFwdRatesOfProgress mix fwdrop Arguments mix Input Mixture object type mixture t fwdrop Output Forward rates of progress double precision array Must be dimensioned at least as large as the number of reactions in mix Description The expressions for the reaction rates of progress are determined by the kinetics model used See section Example see the example for procedu
47. es for each step But Cantera also provides a set of turn key constructors that do all of this for you For example if you want an object representing pure water including vapor liquid and saturated states all you need to do is call constructor Water It takes care of installing the right equation of state and installing a single species composed of two atoms of hydrogen and one of oxygen Or if you want an object that allows you to do kinetics calculations in in a way that is compatible with the the CHEMKIN package just call constructor CKGas with your reaction mechanism input file as the argument CKGas installs the appropriate kinetics model equation of state and pure species property parameterizations and then adds the elements species and reactions specified in your input file Using CKGas a complete object representing your reaction mechanism ready for use in kinetics simulations can be constructed with a single function call In this chapter we will take a first look at objects representing mixtures and pure substances We will have much more to say about mixture objects in the next few chapters where we will cover their thermodynamic properties kinetic rates and transport properties 2 1 Mixture Objects 2 1 1 The Fortran Mixture Object The basic object type used to represent matter is type mixture_t As this name suggests Cantera regards all material systems as mixtures although the term is used somewhat loosely
48. features scheduled to be implemented in an upcom ing release are non ideal and multiphase reacting mixtures surface and interfacial chemistry sensitivity analysis models for simple reacting flows laminar flames boundary layers flow in channels etc and electrochemistry Other capabilities or interfaces to other applications may also be added depending on available time support etc If you have specific things you want to see Cantera support you are encouraged to become a Cantera developer or support Cantera development in other ways to make it possible See http Avww cantera org support for more information 4 Chapter 1 Getting Started draft November 29 2001 1 3 Installing Cantera If you ve read this far maybe you re thinking you d like to try Cantera out All you need to do is download a version for your platform from http www cantera org and install it 1 3 4 Windows If you want to install Cantera on a PC running Windows download and run cantera12 msi If for some reason this doesn t work you can download cantera12 zip instead If you only intend to run the stand alone applications that come with Cantera then you don t need a compiler The executable programs are in folder bin within the main Cantera folder If you intend to use Cantera in your own Fortran applications you need to have Compaq formerly Digital Visual Fortran 6 0 or later If you do look in the win32 folder within the main Canter
49. i nh3 speciesIndex mix NH3 i h2 speciesIndex mix H2 x i nh3 2 d0 x i h2 1 d0 call setState TPX mix t p x 43 setState_TPX Set the temperature pressure and mole fractions 2 12 The Thermodynamic State 39 draft November 29 2001 Syntax call setState_TPX mix t p moleFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision P Input Pressure Pa double precision moleFracs Input Species mole fraction string character Description There are two versions of setState_TPX This one uses a string to specify the mole fractions and the other above uses an array The string should contain comma separated name value pairs each of which is separated by a colon such as CH4 1 02 2 N2 7 52 The values do not need to sum to 1 0 they will be internally normalized The mole fractions of all other species in the mixture are set to zero Example real 8 t p character 50 x t 300 d0 p OneAtm x H2 3 SIH4 0 1 AR 60 call setState TPX t p x 44 setState_TPY Set the temperature pressure and mass fractions Syntax call setState_TPY mix t p massFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision P Input Pressure Pa double precision massFracs Input Species mass fractions double precision array Must be dimensioned at least as large a
50. ic state of a mixture or modify its current state Procedures that set the mole fractions or mass fractions take an array of X values even though only K 1 are independent Unless otherwise noted these input values will be internally normalized to satisfy Ae 2 4 k or Y si 2 5 k For those procedures that take as an argument the internal energy enthalpy or entropy the value per unit mass must be used 38 Chapter 2 Mixtures draft November 29 2001 2 12 1 Setting the State The procedures described below set the full thermodynamic state of a mixture They take as arguments two thermodynamic properties and an array or string that specifies the composition The state of the mixture after calling any of these is independent of its state prior to the call 42 setState_TPX Set the temperature pressure and mole fractions Syntax call setState_TPX mix t p moleFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision P Input Pressure Pa double precision moleFracs Input Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix Description There are two versions of setState_TPX This one uses an array to specify the mole fractions and the other below uses a string Example double precision x 100 t 1700 d0 p 0 1 OneAtm do k 1 nSpecies mix x k 0 d0 end do
51. irectory subroutine 21 addElement subroutine 27 advance subroutine 94 atomicWeight function 29 charge function 30 contents function 93 copy subroutine 23 87 100 cp_mass function 56 cp_mole function 53 critPressure function 58 critTemperature function 57 cstr t constructors 85 86 cv_mass function 56 cv_mole function 54 delete subroutine 22 78 density function 51 95 disableChemistry subroutine 98 downstream function 102 element Index draft November 29 2001 INDEX function 28 enableChemistry subroutine 97 enthalpy_mass function 54 96 enthalpy_mole function 52 entropy_mass function 55 entropy_mole function 53 equationOfState function 59 equilibrate subroutine 61 flowdev_t constructors 99 100 getChemPotentials_RT subroutine 54 getConcentrations subroutine 35 getCp_R subroutine 49 getCreationRates subroutine 72 getDestructionRates subroutine 72 getElementNames subroutine 27 getEnthalpy_RT subroutine 48 getEntropy_R subroutine 49 getEquilibriumConstants subroutine 71 getFwdRatesOfProgress subroutine 69 113 getGains subroutine 104 getGibbs_RT subroutine 48 getMassFractions subroutine 35 getMoleFractions subroutine 35 getMolecularWeights subroutine 32 getMultiDiffCoeffs subroutine 82 getNetProductionRates subroutine 73 getNetRatesOfProgress subroutine 70 getReactionString subroutine 65 getRevRatesOfProgress subroutine 69
52. it double precision a h o z double precision pres 5 v 5 data pres 1 d0 3 d0 10 d0 30 d0 100 d0 type substance t s s Nitrogen open 10 file plot csv form formatted t minTemp s do n 1 100 t 2t L 0 do j 1 5 call setState TP s t OneAtm pres 3 v j 1 0 density s end do 20 Chapter 2 Mixtures draft November 29 2001 1 atm 3 atm 510 x me e E o 10 atm E 2 o gt 2 5 10 30 atm o o o 100 atm 75 100 125 150 Temperature K Figure 2 2 Isobars at 1 3 10 30 and 100 atm for nitrogen write 10 20 t v j j 1 5 20 format 6 e14 5 end do close 10 stop end 2 4 Utilities The procedures in this section provide various utility functions 8 addDirectory Add a directory to the path to be searched for input files Syntax call addDirectory dirname Arguments dirname Input Directory name character 2 4 Utilities 21 draft November 29 2001 Description Constructor functions may require data in external files Cantera searches for these files first in the local directory If not found there and environment variable CANTERA_DATA_DIR is set to a directory name then this directory will be searched Additional directories may be added to the search path by calling this subroutine Example call addDirectory usr local my filea 9 delete Deletes the kernel mixture object Syntax call delete mix A
53. ixture_t g RT Output Array of non dimensional pure species Gibbs functions double precision ar ray Must be dimensioned at least as large as the number of species in mix 65 getCp_R Get the array of pure species non dimensional heat capacities at constant pressure Galt Pay R k 1 K 2 8 Syntax call getCp_R mix cp_R Arguments mix Input Mixture object type mixture_t cp_R Output Array of non dimensional pure species heat capacities at constant pressure double precision array Must be dimensioned at least as large as the number of species in mix 66 getEntropy_R Get the array of pure species non dimensional entropies amp k T Po R k 1 K 2 9 Syntax call getEntropy_R mix s_R Arguments mix Input Mixture object type mixture_t s_R Output Array of non dimensional pure species entropies double precision array Must be dimensioned at least as large as the number of species in mix 2 14 Attributes of the Parameterization These procedures return attributes of the thermodynamic property parameterization used 2 14 Attributes of the Parameterization 49 draft November 29 2001 67 minTemp Lowest temperature for which the thermodynamic properties are valid K Syntax result minTemp mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 68 maxTemp Highest temperature for which the thermodynamic properties are valid K
54. k is that objects can be combined together to build more complex dynamic system and process models For example it is a simple matter to quickly put together a complex network of stirred reactors complete with sensors actuators and closed loop controllers if desired 1 6 The cantera Module To use Cantera from Fortran 90 put the statement use cantera at the top of any program unit where you need to access a Cantera object constant or procedure Module cantera contains the Cantera Fortran 90 interface specification and handles calling the C kernel pro cedures It in turn uses othe Cantera modules You do nor have to include a use statement for these others in your program but the module information files must be available for them All module files are located in directory Cantera fortran modules You should either tell your Fortran compiler to look for module files there or else copy them all to the directory where your application files are 1 6 1 Declaring an Object Cantera represents objects in Fortran 90 using Fortran derived types Derived types are not part of the older Fortran 77 which is one reason why Cantera implements a Fortran 90 interface but not one for Fortran 77 A few of the object types Cantera defines are mixture_t Reacting mixtures 6 Chapter 1 Getting Started draft November 29 2001 cstr t Continuously stirred tank reactors flowdev t Flow control devices eos t Equation of
55. lation codes to evaluate properties and chemical source terms that appear in the governing equations Can tera places no limits on the size of a reaction mechanism or on the number of mechanisms that you can work with at one time it can compute transport properties using a full multicomponent formu lation and uses fast efficient numerical algorithms It even lets you switch reaction mechanisms or transport property models dynamically during a simulation to adaptively switch between inexpen sive approximate models and expensive accurate ones based on local flow conditions It is well suited for numerical models of laminar flames flow reactors chemical vapor deposition reactors fuel cells engines combustors etc Any existing code that spends most of its time evaluating kinetic rates a common situation when large reaction mechanisms are used may run substantially faster if ported to Cantera Cantera s kinetics algorithm in particular runs anywhere from two to four times faster depending on the platform than that used in some other widely used packages Use it for exploratory calculations Sometimes you just need a quick answer to a simple question for example e if air is heated to 3000 K suddenly how much NO is produced in 1 sec e What is the adiabatic flame temperature of a stoichiometric acetylene air flame e What are the principal reaction paths in silane pyrolysis draft November 29 2001 With Cantera answering any
56. may significantly accelerate transport property evaluation in some cases However if trans port properties are evaluated within functions for which numerical derivatives are computed then using any iterative method may cause convergence difficulties In many cases transport property evaluation can be done outside the function If not then LU decomposition should be used Default LU decomposition character 5 2 Procedures 83 draft November 29 2001 GMRES m Input GMRES m parameter Number of inner iterations between outer iterations Default 100 integer GMRES_eps Input GMRES convergence parameter Default 1077 double precision Description This procedure sets various transport options All arguments but the first one are optional The recommended way to call this procedure is using keywords as shown in the example Example use cantera transport t tr call setOptions tr linearSolver GMRES set any one or more call setOptions tr GMRES eps 1 e 3 GMRES m 50 84 Chapter 5 Transport Properties draft November 29 2001 CHAPTER SIX Stirred Reactors This box will soon be replaced by documentation 6 1 Reactor Objects 6 1 1 Type cstr_t Objects representing zero dimensional stirred reactors are implemented in Fortran 90 by the derived type cstr t defined below cstr t Stirred reactors hndl integer Handle encoding pointer to the C object mix type mixture
57. mix Arguments mix Input Mixture object type mixture t Result Returns a double precision value 80 getChemPotentials RT Get the species chemical potentials J kmol Syntax call getChemPotentials_RT mix mu Arguments mix Input Mixture object type mixture_t mu Output Species chemical potentials double precision array Must be dimensioned at least as large as the number of species in mix 2 15 3 Specific Mixture Properties The procedures in this section all return thermodynamic properties per unit mass The names all end in mass which should be read as per unit mass 81 enthalpy_mass Specific enthalpy J kg Syntax result enthalpy_mass mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 54 Chapter 2 Mixtures draft November 29 2001 82 intEnergy_mass Specific internal energy J kg Syntax result intEnergy_mass mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 83 entropy_mass Specific entropy J kg K Syntax result entropy_mass mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 84 gibbs_mass Specific Gibbs function J kg Syntax result gibbs_mass mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value 2 15 Mixture Thermodynamic Proper
58. n array Must be dimensioned at least as large as the number of species in mix 2 12 The Thermodynamic State 41 draft November 29 2001 47 setState_TRY Set the temperature density and mass fractions Syntax call setState_ TRY mix t density massFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision density Input Density kg m double precision massFracs Input Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix 2 12 2 Modifying the Current State The procedures in this section set only one or two properties leaving the temperature density and or com position unchanged 48 setTemperature Set the temperature holding the mass density and composition fixed Syntax call setTemperature mix temp Arguments mix Input Output Mixture object type mixture_t temp Input Temperature K double precision 49 setDensity Set the density holding the temperature and composition fixed Syntax call setDensity mix density Arguments mix Input Output Mixture object type mixture_t density Input Density kg m double precision 42 Chapter 2 Mixtures draft November 29 2001 50 setState_TP Set the temperature and pressure holding the composition fixed Syntax call setState_TP mix t p Arguments mix Input Output Mixture object type mix
59. nding to the widely used natural gas combustion mecha nism GRI Mech version 3 0 Smith et al 1997 The mixture object created contains 5 elements 53 species and 325 reactions Syntax object GRIMech30 Result Returns an object of type mixture_t Description The natural gas combustion mechanism GRI Mech version 3 0 Smith et al 1997 is widely used for general combustion calculations more At present this constructor simply calls the CKGas constructor with input file grimech30 inp This file is located in directory data CK mechanisms within the cantera 1 2 tree For this to work correctly environment variable CANTERA_ROOT must be set as described in Chapter 1 In a future relese calling this constructor will generate a hard coded version of GRI Mech 3 0 that may be faster than the one generated by calling CKGas For more information on GRI Mech see http www me berkeley edu gri_mech 2 3 Constructors 17 draft November 29 2001 Example type mixture t mix mixl GRIMech30 2 3 2 Pure Substance Constructors In addition to the ideal gas mixtures discussed above Cantera implements several non ideal pure fluids These use accurate equations of state and are valid in the vapor liquid and mixed liquid vapor regions of the phase diagram In most cases the equation of state parameterizations are taken from the compilation by Reynolds Reynolds 1979 The standard state enthalpy of formation and
60. ne of the best ways to obtain insight into the most important chemical pathways in a complex reaction mechanism is to make a reaction path diagram showing the fluxes of a conserved element through the species due to chemistry But producing these by hand is a slow tedious process Cantera can automatically generate reaction path diagrams at any time during a simulation It is even possible to create reaction path diagram movies showing how the chemical pathways change with time as reactants are depleted and products are formed Create stirred reactor networks Cantera implements a general purpose stirred reactor model that can be linked to other ones in a network Reactors can have any number of inlets and outlets can have a time dependent volume and can be connected through devices that regulate the flow rate between them in various ways Closed loop controllers may be installed to regulate pressure temperature or other properties Using these basic components you can build models of a wide variety of systems ranging in com plexity from simple constant pressure or constant volume reactors to complete engine simulators Simulate multiphase pure fluids Cantera implements several accurate equations of state for pure fluids allowing you to compute properties in the liquid vapor mixed liquid vapor and supercritical states This will soon be expanded to include multiphase mixture models These capabilities are only the beginning Some new
61. nn s constant k J K 1 10 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 draft November 29 2001 program eq use cantera implicit double precision a h o z character 50 xstring character 2 propPair type mixture t mix mix GRIMech30 if not ready mix then write error encountered constructing mixture stop end if write enter T K and P atm read temp pres pres OneAtm pres convert to Pascals the initial composition should be entered as a string of name lt moles gt pairs for example CH4 3 02 2 N2 7 52 The values will be normalized internally write enter initial composition read 10 xstring 10 format a set the initial mixture state call setState TPX temp pres xstring determine what to hold constant write enter one of HP TP UV or SP to specify the write properties to hold constant read 10 propPair equilibrate the mixture call equilibrate mix propPair print a summary of the new state call printSummary mix stop end Each of the functions or subroutines used here is described in detail in later chapters 1 11 Summary So in summary the procedure to write a Cantera based Fortran 90 program is simple 1 11 Summary 11 draft Novem
62. ntax call setMassFractions NoNorm mix y Arguments mix Input Output Mixture object type mixture_t y Input Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix Description This procedure is designed for use when perturbing the composition for example when computing Jacobians 2 9 Mixture Composition 33 draft November 29 2001 32 setConcentrations Set the species concentrations holding the temperature fixed Syntax call setConcentrations mix conc Arguments mix Input Output Mixture object type mixture_t conc Input Species concentrations kmol m double precision array Must be dimen sioned at least as large as the number of species in mix 22 moleFraction Mole fraction of one species Syntax result moleFraction mix name Arguments mix Input Mixture object type mixture_t name Input Species name character Result Returns adouble precision value Description The mole fraction of the species with name name is returned If no species in the mixture has this name the value zero is returned 34 massFraction Mass fraction of one species Syntax result massFraction mix name Arguments mix Input Mixture object type mixture_t 34 Chapter 2 Mixtures draft November 29 2001 name Input Species name character Result Returns a double precision value Description The mass f
63. of element properties e g names atomic weights are ordered by index number Example vl contains element properties ordered as listed in mechl inp copy these values to the the positions in array v2 which is ordered as in mech2 inp type mixture t mix mix2 mixl CKGas mechl inp mix2 CKGas mech2 inp do i 1 nElements mix1 ename elementName i loc2 elementIndex mix2 ename v2 10c2 vil il end do 28 Chapter 2 Mixtures draft November 29 2001 See Also speciesIndex 21 atomicWeight The atomic weight of the mt element kg kmol Syntax result atomicWeight mix m Arguments mix Input Mixture object type mixture_t m Input Element index integer Result Returns adouble precision value Example character 20 names 10 call getElementNames mix names dom 1 nElements mix write names m atomicWeight mix m end do 2 8 Properties of the Species The species are defined so that any achievable chemical composition for the mixture can be represented by specifying the mole fraction of each species In gases the species generally correspond to distinct molecules atoms or ions and each is composed of integral numbers of atoms of the elements However if the gas mixture contains molecules with populated metastable states then to fully represent any possible mixture composition these states or groups of them must also be defined as species Common examples of
64. of these requires only writing a few lines of code If you are comfortable with Fortran or C you can use either of these or you can write a short Python script which has the advantage that it can be run immediately without compilation Python can also be used interac tively Or you can use one of the stand alone applications that come with Cantera which requires no programming at all other than writing an input file Use it in teaching Cantera is ideal for use in teaching courses in combustion reaction engineering trans port processes kinetics or similar areas Every student can have his or her own copy and use it from whatever language or application he or she prefers There are no issues of cost site licenses license managers etc as there are for most commercial packages For this reason Cantera based applications are also a good choice for software that accompanies textbooks in these fields Run simulations with your own kinetics transport or thermodynamics models Cantera is designed to be customized and extended You are not locked in to using a particular equation of state or reaction rate expressions or anything else If you need a different kinetics model than one provided you can write your own and link it in The same goes for transport models equations of state etc Currently this requires C programming but in an upcoming release this will be possible to do from Fortran Make reaction path diagrams and movies O
65. ons that operate specifically on objects of that class An object that has a temperature attribute might have method set Temperature t to set the value and temperature to read it The syntax to invoke these methods on an object in C or Java would be x setTemperature 300 0 set temp of x to 300 K y setTemperature x temperature set y temp to x temp Here object y might belong to an entirely different class than x and the process of setting its temperature might involve entirely different internal operations Both classes can define methods with the same name since it is always clear which one should be called the one that belongs to the class of the object it is attached to Fortran is not an object oriented language and has only functions and subroutines not object specific meth ods Therefore the Cantera Fortran 90 interface uses functions and subroutines to serve the role of methods Thus the temperature attribute of an object is retrieved by calling function temperature object What happens if you try to access a temperature attribute as object temperature Actually the compiler will complain that the object has no member temperature and will abort Property values are not stored in the Fortran derived type objects They are either stored in the kernel object or computed on the fly depending on which attribute you request Mixtures and reactors are two of the Cantera object types that have a temperat
66. ot include any species k molecules that act as third body collision partners but are not written in the reaction equation Non integral values are allowed Example use cantera real 8 rcoeff type mixture t mix mix GRIMech30 inh speciesIndex mix NH write Reactions in GRI Mech 3 0 with NH as a reactant do i 1 nReactions mix rcoeff reactantStoichCoeff mix inh i if rcoeff gt 0 d0 write reaction i end do Output Reactions in GRI Mech 3 0 with NH as a reactant reaction 190 reaction 191 reaction 192 reaction 193 reaction 194 reaction 195 reaction 196 reaction 197 reaction 198 reaction 199 reaction 280 See Also productStoichCoeff 98 productStoichCoeff The stoichiometric coefficient for species k as a product in reaction i 4 1 Procedures 67 draft November 29 2001 Syntax result productStoichCoeff mix k i Arguments mix Input Mixture object type mixture_t k Input Species index integer i Input Reaction index integer Result Returns adouble precision value Description A given species may participate in a reaction as a reactant a product or both This function returns the number of molecules of the K species appearing on the product side of the reaction equation It does not include any species k molecules that act as third body collision partners but are not written in the reaction equation Non integral values are allowed Example use cant
67. ot neces sarily finely divided and intermixed Liquid water with dissolved oxygen and nitrogen is a mixture as are sand air wood beer and most other everyday materials In fact since even highly purified substances contain measurable trace impurities it is exceptionally rare to encounter anything that is not a mixture i e anything that is truly a substance solution A mixture in which the constituents are fully mixed on a molecular scale In a solution all molecules of a given constituent or all sites of a given type are statistically equivalent and the configurational entropy of the mixture is maximal Mixtures of gases are solutions as are mixtures of mutually soluble liquids or solids For example silicon and germanium form a crystalline solid solution Si Ge _ where x is continuously variable over a range of values phase A macroscopic sample of matter with a homogeneous composition and structure that is stable to small perturbations Example water at a temperature below its critical temperature and above its triple point can exist in two stable states a low density state vapor or a high density one liquid There is no stable homogeneous state at intermediate densities and any attempt to prepare such a state will result in its spontaneous segregation into liquid and vapor regions Liquid water and water vapor are two phases of water below its critical temperature Above it these two phases merge and there is only a
68. ource is The standard state enthalpy of formation and the absolute entropy have been adjusted to match the values in the JANAF tables Example type substance t subst subst Methane 6 Hydrogen Construct a pure substance object representing hydrogen H Syntax object Hydrogen Result Returns an object of type mixture_t Description The equation of state parameterization is taken from the compilation by Reynolds 1979 The original source is The standard state enthalpy of formation and the absolute entropy have been adjusted to match the values in the JANAF tables 2 3 Constructors 19 draft November 29 2001 Example type substance t subst subst Hydrogen 7 Oxygen Construct a pure substance object representing oxygen O Syntax object Oxygen Result Returns an object of type mixture_t Description The equation of state parameterization is taken from the compilation by Reynolds 1979 The original source is The standard state enthalpy of formation and the absolute entropy have been adjusted to match the values in the JANAF tables Example type substance t subst subst Oxygen Example 2 1 Constant pressure lines for nitrogen are shown on a volume temperature plot in Fig 2 2 The data for this plot were generated by the program below Note that the state of the nitrogen object may correspond to liquid vapor or saturated liquid vapor program plotn2 use cantera implic
69. ow device This only needs to be called for those flow controllers that have an internal state such as pressure controllers that use a PID controller Syntax call update flowDev Arguments flowDev Input Output Flow controller object type flowdev_t 102 Chapter 7 Flow Devices draft November 29 2001 155 reset Reset the controller Call this procedure before operating any flow controller that uses a PID controller Syntax call reset flowDev Arguments flowDev Input Output Flow controller object type flowdev_t 156 ready Returns true if flow controller is ready for use Syntax result ready flowDev Arguments flowDev Input Output Flow controller object type flowdev_t Result Returns a integer value 157 setGains Some flow control devices use a PID proportional integral derivative controller This procedure can be used to set the gains for the PID controller Syntax call setGains flowDev gains Arguments flowDev Input Output Flow controller object type flowdev_t gains Input gains double precision array Must be dimensioned at least 4 7 4 Setting Options 103 draft November 29 2001 158 getGains Some flow control devices use a PID proportional integral derivative controller This procedure can be used to retrieve the current gain settings for the PID controller Syntax call getGains flowDev gains Arguments flowDev Input Ou
70. pe mixture t mix mix GRIMech30 call setState TPX mix 2000 d0 OneAtm CH4 1 02 2 call saveState mix state ho enthalpy mass mix call setState HP mix h0 OneAtm tl temperature mix call setState HP mix h0 h0 1 d 8 OneAtm t2 temperature mix call restoreState mix state write h0 1 d 8 t2 t1 cp mass mix return Output 2199 12043414729 2199 12045953925 46 Chapter 2 Mixtures draft November 29 2001 60 setState_UV Set the specific internal energy and specific volume holding the composition constant Syntax call setState UV mix t p Arguments mix Input Output Mixture object type mixture_t t Input Specific internal energy J kg double precision P Input Specific volume m kg double precision Description See the discussion of procedure setState_HP procedure number 59 61 setState_SP Set the specific entropy and pressure holding the composition constant Syntax call setState_SP mix t p Arguments mix Input Output Mixture object type mixture_t t Input Specific entropy J kg K double precision P Input Pressure Pa double precision Description See the discussion of procedure setState HP procedure number 59 62 setState SV Set the specific entropy and specific volume holding the composition constant Syntax call setState SV mix t p Arguments mix Input Output Mixture object type mixture_t 2 12 The Thermodynamic
71. pe mixture_t k Input Species index integer Result Returns a double precision value 2 17 Critical State Properties These procedures return parameters of the critical state Not all equation of state managers implement these in which case the value Undefined is returned 89 critTemperature The critical temperature K Syntax result critTemperature mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value 2 17 Critical State Properties 57 draft November 29 2001 90 critPressure The critical pressure Pa Syntax result critPressure mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value Example use cantera type mixture t h2o h20 Water write Perit critPressure h20 Output Perit 22089000 0000000 2 18 Saturation Properties These procedures are only implemented by models that treat saturated liquid vapor states Calling them with any other equation of state manager installed will result in an error 91 satTemperature The saturation temperature at pressure p K An error results if P gt Rrit Syntax result satTemperature mix p Arguments mix Input Mixture object type mixture_t P Input Pressure Pa double precision Result Returns a double precision value Example 58 Chapter 2 Mixtures draft November 29 2001 use cantera type mixture t h
72. program These are Performance For multicomponent transport models this procedure uses an algorithm that does not require evaluating the multicomponent diffusion coefficient matrix first and thereby eliminates the need for matix inversion resulting in somewhat better performance Generality The expression for the flux in terms of mole fraction and temperature gradients is not the same for all transport models Using this procedure allows switching easily between multicom ponent and Fickian diffusion models Example use cantera implicit double precision a h o z type mixture t mix character 80 infile thermofile xstring model trdb double precision gradx 10 3 gradt 3 fluxes 10 3 double precision x1 8 x2 8 x3 8 character 20 name 10 data x1 8 0 1d0 80 Chapter 5 Transport Properties draft November 29 2001 data x2 0 d0 0 2d0 0 d0 0 2d0 0 d0 0 2d0 0 d0 0 2d0 data x3 0 1d0 0 2d0 0 3d0 0 4d0 0 d0 0 d0 0 d0 0 d0 mix CKGas air inp therm dat call getSpeciesNames mix name call initTransport mix Multicomponent gri30 tran dat 0 nsp nSpecies mix generate dummy gradient data do k 1 nsp gradx k 1 x1 k x2 k todX k dxl gradx k 2 x2 k x3 k Lh ARSS gradx k 3 x3 k x1 k dX k dx3 x1 k O 5 xl k x2 k end do gradt 1 1000 d0 dT dx1 gradt 2 500 d0 V GT AR2 gradt 3 800 d0 dT dx3 call setState TPX mix 1800 d0 One
73. r of species in mix 72 Chapter 4 Homogeneous Kinetics draft November 29 2001 Description The destruction rate of species k is D gt ve Qs vi Qn 4 3 i Example see the example for procedure 106 106 getNetProductionRates Get the species net chemical production rates kmol m s Syntax call getNetProductionRates mix wdot Arguments mix Input Mixture object type mixture_t wdot Output Net production rates double precision array Must be dimensioned at least as large as the number of species in mix Description This procedure returns the net production rates for all species which is the difference between the species creation and destruction rates ie Cy Dr 4 4 V Qi 4 5 If only the net rates are required it is usually more efficient to call this procedure than to first compute the creation and destruction rates separately and take the difference In the example below the creation destruction and net production rates are computed for the same conditions as in the example for procedure Also shown is the characteristic chemical time defined as the concentration divided by the destruction rate Example use Cantera real 8 cdot 100 ddot 100 wdot 100 conc 100 type mixture t mix character 10 names 100 mix GRIMech30 call setState TPX mix 2500 d0 OneAtm H2 2 02 1 5 AR 8 call equilibrate mix TP call setState TP mix 2000 d0 0neAtm call getCreationR
74. raction of the species with name name is returned If no species in the mixture has this name the value zero is returned 35 getMoleFractions Get the array of species mole fractions Syntax call getMoleFractions mix moleFracs Arguments mix Input Mixture object type mixture_t moleFracs Input Output Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix 36 getMassFractions Get the array of species mass fractions Syntax call getMassFractions mix massFracs Arguments mix Input Mixture object type mixture t massFracs Input Output Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix 22 getConcentrations Get the array of species concentrations 2 9 Mixture Composition 35 draft November 29 2001 Syntax call getConcentrations mix concentrations Arguments mix Input Mixture object type mixture_t concentrationsInput Output Species concentrations kmol n double precision array Must be dimensioned at least as large as the number of species in mix 2 10 Mean Properties These procedures return weighted averages of pure species properties 38 mean_X Return 7 0 X the mole fraction weighted mean value of pure species molar property Q Syntax result mean X mix Q Arguments mix Input Mixture object type mixture t Q Input Arr
75. re 101 getRevRatesOfProgress Get the reverse rates of progress Qs for the reactions kmol m s Syntax call getRevRatesOfProgress mix revrop Arguments mix Input Mixture object type mixture_t 4 1 Procedures 69 draft November 29 2001 revrop Output Reverse rates of progress double precision array Must be dimensioned at least as large as the number of reactions in mix Description The reverse rate of progress is non zero only for reversible reactions The expressions for the reaction rates of progress are determined by the kinetics model used See section Example see the example for procedure 102 getNetRatesOfProgress Get the net rates of progress for the reactions kmol m s Syntax call getNetRatesOfProgress mix netrop Arguments mix Input Mixture object type mixture_t netrop Output Net rates of progress double precision array Must be dimensioned at least as large as the number of reactions in mix Description The net rates of progress are the difference between the forward and the reverse rates Q Q QP 4 1 The expressions for the rates of progress are determined by the kinetics model used See section In the example below a mixture is first created containing hydrogen oxygen and argon and then set to the chemical equilibrium state at 2500 K and 1 atm The temperature is then lowered and the forward reverse and net rates of progress are computed for all
76. reactions 325 2 6 Mixture Creation The procedures in this section are designed to allow creation of arbitrary custom mixtures from Fortran To use these procedures first construct a skeleton mixture object using constructor Mixture This returns an empty mixture one that has no constituents and with do nothing null property managers installed By adding elements and species and installing managers for thermodynamic properties kinetics and transport properties arbitrary mixtures can be constructed Release Note These capabilities are not yet fully functional in the Fortran yet More pro cedures will be added soon 175 Mixture Construct an empty mixture object with no constituents or property managers Syntax object Mixture Result Returns an object of type mixture t 26 Chapter 2 Mixtures draft November 29 2001 Description This constructor creates a skeleton object to which individual components may be added by calling the procedures below Example type mixture t mix mix Mixture 18 addElement Add an element to the mixture Syntax call addElement mix name atomicWt Arguments mix Input Mixture object type mixture_t name Input Element name character atomicWt Input Atomic weight in amu double precision Example type mixture t mix mix Mixture call addElement Si 28 0855 call addElement H 1 00797 add species reactions et
77. rguments mix Input Mixture object type mixture_t Description When a mixture constructor is called a kernel mixture object is dynamically allocated This object stores all data required to compute the mixture thermodynamic kinetic and transport properties For mixtures of many species or ones with a large reaction mechanism the size of the object may be large Calling this subroutine frees this memory After deleting a mixture the object must be constructed again before using it 10 ready Returns true if the mixture has been successfully constructed and is ready for use Syntax result ready mix Arguments mix Input Mixture object type mixture_t Result Returns a logical value 22 Chapter 2 Mixtures draft November 29 2001 11 copy Copies one mixture object to another Syntax call copy dest src Arguments dest Output Mixture object type mixture_t src Input Mixture object type mixture_t Description Performs a shallow copy of one mixture object to another Note that the kernel object itself is not copied only the handle Therefore after calling copy both objects point to the same kernel object The contents of dest are overwritten Assigning one mixture to another invokes this procedure Example use cantera type mixture t fluid1 fluid2 fluid3 fluidi Water fluid2 Methane write fluidl ready ready fluidl call delete fluidl fluidl is now empty wri
78. s the number of species in mix Description There are two versions of setState_TPY This one uses an array to specify the mass fractions and the other below uses a string 40 Chapter 2 Mixtures draft November 29 2001 45 setState_TPY Set the temperature pressure and mass fractions Syntax call setState_TPY mix t p massFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision P Input Pressure Pa double precision massFracs Input Species mass fraction string character Description There are two versions of setState_TPY This one uses a string to specify the mole fractions and the other above uses an array The string should contain comma separated name value pairs each of which is separated by a colon such as CH4 2 02 1 N2 10 the values do not need to sum to 1 0 they will be internally normalized The mass fractions of all other species in the mixture will be set to zero Example real 8 t p character 50 x t 300 d0 p OneAtm x H20 5 NH3 0 1 N2 20 call setState TPY t p x 46 setState_TRX Set the temperature density and mole fractions Syntax call setState_TRX mix t density moleFracs Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision density Input Density kg m double precision moleFracs Input Species mole fractions double precisio
79. so that this type can represent pure substances too A pure substance is simply regarded as a mixture that happens to contain only one species Objects representing mixtures are implemented in Fortran 90 by the derived type mixture_t Like all Cantera objects the mixture_t object itself is very thin It contains only 4 integers the handle that is 13 draft November 29 2001 used to access the underlying C object created by the constructor the number of elements the number of species and the number of reactions All other information about the mixture is stored in the kernel level C object 2 1 2 The Kernel Mixture Object As mentioned above the kernel mixture object has a modular structure with interchangeable parts The basic structure is shown in Figure A mixture object contains three major components each of which has specific responsibilities The thermodynamic property manager handles all requests for thermodynamic properties of any type the transport property manager is responsible for everything to do with transport properties and the kinetics manager deals with everything related to homogeneous kinetics We refer to these three internal objects as the property managers The mixture object itself does not compute thermodynamic transport or kinetic properties it simply directs incoming requests for property values to the appropriate manager It also mediates communication between the property managers if
80. specify the elements species and reactions to be in cluded and provide all necessary parameters needed by kinetic thermodynamic and transport managers 14 Chapter 2 Mixtures draft November 29 2001 Application Program 7 Interface to application program Mixture Traffic director State related operations Manages elements and species Property updating Thermodyamic properties temperature pressure enthalpy internal energy entropy chemical potentials Homogeneous Kinetics a reaction rates of progress Transport properties species creation and destruction rates viscosity thermal conductivity equilibrium constants binary diffusion coefficients multicomponent diffusion coefficients Figure 2 1 Top level structure of mixture objects Each 2 3 Constructors 15 draft November 29 2001 Release Note In this early release the only reacting mixture model implemented is one compatible with the model described in Kee et al 1989 The capability to define other models is present in the kernel however 1 CKGas Constructor CKGas implements a mixture model consistent with that described by Kee et al 1989 This model is designed to be used to represent low density reacting gas mixtures The mixture components installed by this constructor are listed below Equation of State Manager The IdealGasEOS equation of state manager is installed Species Thermodynamic Properties The NASA polynomial parameteriz
81. state managers kinetics t Kinetics managers transport t Transport managers By convention all type names end in _t This serves as a visual reminder that these are object types and is consistent with the C C naming convention e g size_t clock t Objects may be declared using a syntax very similar to that used to declare simple variables type mixture t mixl mix2 a b c type cstr t rl r2 d e f The primary difference is that the type name is surrounded by type 1 6 2 Constructing An Object The objects that are visible in your program are really only a Fortran facade covering an object belonging to one of the Cantera C classes which we will call a kernel object The Fortran object is typically very small in many cases it holds only a single integer which is the address of the C object converted to a form representable by a Fortran variable usually an integer We call this internally stored variable the handle of the C object When a Fortran derived type object is declared no initialization is done and there is no underlying C object for the handle to point to Therefore the first thing you need to do before using an object is call a procedure that constructs an appropriate kernel object stores its address converted to an integer in the Fortran object s handle and performs any other initialization needed to produce a valid functioning object We refer to such procedures
82. structors As 1 3 GNSSISTIMENE e fo cg Heke ce ae a due Rer a a a 7 4 Setting Options lt 8 Utility Functions 9 Utilities ON AntroducttOm zea eum wba e Shc des amp he ed pee ones eX ROVER RS 012 Proced fes xc ra kre Fo beegeuewo we ek Ee DEES we 9 3 Procedures 44 smedt ee ea XeXee wes Eh EE hee ee A Glossary Index draft November 29 2001 draft November 29 2001 This document is the Fortran 90 version of the Cantera tutorial If you are interested in using Cantera from C or Python versions of this document exist for those languages as well Contents draft November 29 2001 draft November 29 2001 CHAPTER ONE Getting Started 1 1 What is Cantera Cantera is a collection of object oriented software tools for problems involving chemical kinetics ther modynamics and transport processes Among other things it can be used to conduct kinetics simulations with large reaction mechanisms to compute chemical equilibrium to evaluate thermodynamic and transport properties of mixtures to evaluate species chemical production rates to conduct reaction path analysis to create process simulators using networks of stirred reactors and to model non ideal fluids Cantera is still in development and more capabilities continue to be added 1 2 Typical Applications Cantera can be used in many different ways Here are a few Use it in your own reacting flow codes Cantera can be used in Fortran or C reacting flow simu
83. such long lived metastable states include singlet A oxygen and singlet methylene In solid or liquid solutions it may be necessary to define species composed of non integral numbers of elements This is acceptable as long as all realizable states of the mixture correspond to some set of mole fractions for the species so defined 22 nAtoms Number of atoms of element m in species k 2 8 Properties of the Species 29 draft November 29 2001 Syntax result nAtoms mix k m Arguments mix Input Mixture object type mixture_t k Input Species index integer m Input Element index integer Result Returns adouble precision value Non integral and or negative values are allowed For example if an electron is defined to be an element then a positive ion has a negative number of atoms of this element 23 charge Electrical charge of the kt species in multiples of e the magnitude of the electron charge Syntax result charge mix k Arguments mix Input Output Mixture object type mixture_t k Input Species index integer Result Returns a double precision value In most cases the charge is integral but non integral values are allowed 24 specieslndex Index number of a species Syntax result speciesIndex mix name Arguments mix Input Mixture object type mixture_t name Input Species name character 30 Chapter 2 Mixtures draft November 29 2001 Result Re
84. tax call setSetpoint flowDev setpnt Arguments 100 Chapter 7 Flow Devices draft November 29 2001 flowDev Input Output Flow controller object type flowdev_t setpnt Input Setpoint double precision Description For mass flow controllers this sets the mass flow rate kg s For pressure controllers it sets the pressure setpoint Pa 150 install Install a flow control device between two reactors Syntax call install flowDev upstream downstream Arguments flowDev Input Output Flow controller object type flowdev_t upstream Input Output Upstream reactor object type cstr_t downstream Input Output Downstream reactor object type cstr_t 151 upstream Return a reference to the upstream reactor Syntax result upstream flowDev Arguments flowDev Input Output Flow controller object type flowdev_t Result Returns a type cstr_t value 7 4 Setting Options 101 draft November 29 2001 152 downstream Return a reference to the downstream reactor Syntax result downstream flowDev Arguments flowDev Input Output Flow controller object type flowdev_t Result Returns a type cstr_t value 153 massFlowRate Mass flow rate kg s Syntax result massFlowRate flowDev Arguments flowDev Input Output Flow controller object type flowdev_t Result Returns adouble precision value 154 update Update the state of the fl
85. te fluidl ready ready fluidl call copy fluidl fluid2 now fluidl is Methane too write fluidl ready ready fluidl fluid3 fluid2 assignment calls copy write critTemperature fluidl write critTemperature fluid2 write critTemperature fluid3 Output fluidl ready T fluidl ready F fluidl ready T 190 555000000000 190 555000000000 190 555000000000 12 saveState Write the interal thermodynamic state information to an array 2 4 Utilities 23 draft November 29 2001 Syntax call saveState mix state Arguments mix Input Mixture object type mixture_t state Output Array where state information will be stored double precision array Must be dimensioned at least as large as the number of species in mix 2 Description calling saveState writes the internal data defining the thermodynamic state of a mixture object to an array It can later be restored by calling restoreState Example use cantera real 8 state 60 dimension at least of species 2 type mixture t mix mix GRIMech30 call setState TPX mix 400 d0 OneAtm N2 0 2 H2 0 8 write entropy mole mix moleFraction mix N2 call saveState mix state call setState TPX mix 1000 d0 1 d3 N2 0 8 CH4 0 2 write entropy mole mix moleFraction mix N2 call restoreState mix state write entropy mole mix moleFraction mix N2 Output 155555 372874368 0 200000000000000 236274 03
86. te models imple mented in Cantera etc In the last chapter we saw how to create a basic mixture object In this chapter we ll look at how to set the thermodynamic state in various ways and compute various thermodynamic properties eos_t hndl integer Handle encoding pointer to the C object 2 11 Procedures 2 12 The Thermodynamic State Although a long list of properties of a mixture can be written down most of them are not independent once a few values have been specified all the rest are fixed The number of independent properties is equal to the number of different ways any one property can be altered If we consider the Gibbs equation written for dU dU TdS PdV gt uk Ne 2 3 k we see that U can be changed by heat addition TdS or by compression PdV or by changing any one of K mole numbers Therefore the number of degrees of freedom is K 2 However if we are interested only in the intensive state there are only K 1 independently variable parameters since one degree of freedom simply sets the total mass or number of moles The thermodynamic state is determined by specifying any K 1 independent property values Of these K 1 specify the composition and are usually taken to be either mole fractions or mass fractions although the chemical potentials can be used too The two remaining can be any two independent mixture properties These procedures described here set the thermodynam
87. ties 55 draft November 29 2001 85 cp_mass Specific heat at constant pressure J kg K Syntax result cp_mass mix Arguments mix Input Mixture object type mixture_t Result Returns adouble precision value 86 cv_mass Specific heat at constant volume J kg K Syntax result cv_mass mix Arguments mix Input Mixture object type mixture_t Result Returns a double precision value 2 16 Potential Energy For problems in which external conservative fields play an important role it may be desirable to assign potential energies to the species The potential energy adds to the internal energy but does not affect the entropy Species specific potential energies for example proportional to charge can alter the reaction equilibrium constants and therefore both kinetics and the chemical equilibrium composition These effects are important in electrochemistry 87 setPotentialEnergy Set the potential energy of species k J kmol due to external conservative fields electric gravitational or other Default 0 0 56 Chapter 2 Mixtures draft November 29 2001 Syntax call setPotentialEnergy mix k pe Arguments mix Input Output Mixture object type mixture_t k Input Species index integer pe Input Potential energy double precision 88 potentialEnergy The potential energy of species k Syntax result potentialEnergy mix k Arguments mix Input Output Mixture object ty
88. tput Flow controller object type flowdev_t gains Output gains double precision array Must be dimensioned at least 4 159 maxError Maximum absolute value of the controller error signal input setpoint since the last call to reset Syntax result maxError flowDev Arguments flowDev Input Output Flow controller object type flowdev_t Result Returns a double precision value ct api 104 Chapter 7 Flow Devices draft November 29 2001 CHAPTER EIGHT Utility Functions draft November 29 2001 106 draft November 29 2001 CHAPTER NINE Utilities 9 1 Introduction These procedures carry out various utility functions 9 2 Procedures 9 3 Procedures 160 printSummary Write to logical unit lu a summary of the mixture state Syntax call printSummary mix lu Arguments mix Input Mixture object type mixture_t lu Input Fortran logical unit for output integer 107 draft November 29 2001 108 draft November 29 2001 APPENDIX A Glossary substance A macroscopic sample of matter with a precise characteristic composition Pure water is a substance since it is always made up of H20 molecules any pure element is also a substance compound A substance containing more than one element Sodium chloride water and silicon carbide are all compounds mixture A macroscopic sample of matter made by combining two or more substances usually but n
89. tput Reactor object type cstr_t 88 Chapter 6 Stirred Reactors draft November 29 2001 maxstep Input Maximum step size double precision Description Note that on the first call to advance if the maximum step size has not been set the maximum step size is set to not exceed the specified end time This effectively keeps the integrator from integrating out to a large time and then interpolating back to the desired final time This is done to avoid difficul ties when simulating problems with sudden changes like ignition problems If used it must be called before calling advance for the first time Example use cantera type cstr t r r StirredReactor call setMaxStep r 1 d 3 125 setArea Set the reactor surface area m2 Can be changed at any time Syntax call setArea reac area Arguments reac Input Output Reactor object type cstr_t area Input Area double precision Description Note that this does not update automatically if the volume changes but may be changed manually at any time The area affects the total heat loss rate Example use cantera type cstr t r r StirredReactor a spherical reactor radius 2 0 vol 4 d0 3 d0 Pi radius 3 ar 4 d0 Pi radius 2 call setInitialVolume r vol call setArea r ar 6 5 Setting Options 89 draft November 29 2001 126 setExtTemp Set the external temperature T used for heat loss calculations The heat loss rate is cal
90. tr_t Result Returns a double precision value 94 Chapter 6 Stirred Reactors draft November 29 2001 136 time The current time s Syntax result time reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 137 volume The reactor volume m Syntax result volume reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 6 9 Mixture Attributes These procedures return properties of the reactor contents at the time reached by the last call to advance These values are stored in the reactor object and are not affected by changes to the mixture object after advance was last called 138 density The density kg m Syntax result 2 density reac Arguments 6 9 Mixture Attributes 95 draft November 29 2001 reac Input Output Reactor object type cstr_t Result Returns a double precision value 139 temperature The temperature K Syntax result temperature reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 140 enthalpy mass The specific enthalpy J kg Syntax result enthalpy mass reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 141 intEnergy mass The specific internal energy J kg Syntax result intEnerg
91. transport formulation in flow regions where gradients are large and switch to a much less expensive model for other regions This procedure re installs a transport manager previously created with initTransport and saved with transport Note that transport managers cannot be shared between mixture objects Example use cantera type mixture t mix type transport t trl tr2 mix GRIMech30 call initTransport mix Multicomponent gri30 tran dat 0 trl transport mix write thermalConductivity mix call initTransport mix CK Multicomponent gri30 tran dat 0 tr2 transport mix write thermalConductivity mix call setTransport mix tr1 write thermalConductivity mix return Output 0 186896997850329 0 186818124230130 0 186896997850329 See Also transport initTransport 5 2 Procedures 77 draft November 29 2001 110 delete Delete a transport manager Syntax call delete transportMgr Arguments transportMgr Input Output Transport manager object type transport t Description Deleting a transport manager releases the memory associated with its kernel object 111 transportMgr Return the transport manager object Syntax result 2 transportMgr mix Arguments mix Input Mixture object type mixture t Result Returns a type transport t value Description This function returns a reference to the currently installed transport manager object It may be used to store a
92. ture_t t Input Temperature K double precision p Input Pressure Pa double precision 51 setState_PX Set the pressure and mole fractions holding the temperature fixed Syntax call setState_PX mix p x Arguments mix Input Output Mixture object type mixture_t P Input Pressure Pa double precision x Input Species mole fractions double precision array Must be dimensioned at least as large as the number of species in mix 52 setState_PY Set the pressure and mass fractions holding the temperature fixed Syntax call setState_PY mix p massFracs Arguments mix Input Output Mixture object type mixture_t p Input Pressure Pa double precision massFracs Input Species mass fractions double precision array Must be dimensioned at least as large as the number of species in mix 2 12 The Thermodynamic State 43 draft November 29 2001 53 setPressure Set the pressure holding the temperature and composition fixed Syntax call setPressure mix p Arguments mix Input Output Mixture object type mixture_t P Input Pressure Pa double precision 54 setState TR Set the temperature and density holding the composition fixed Syntax call setState TR mix t rho Arguments mix Input Output Mixture object type mixture_t t Input Temperature K double precision rho Input Density kg m double precision 55 setState TX Set the temperature
93. turns a integer value Description The index number corresponds to the order in which the species was added to the mixture All species property arrays are ordered by index number 25 getSpeciesNames Get the array of species names Syntax call getSpeciesNames mix snames Arguments mix Input Mixture object type mixture_t snames Output Array of species names character array Must be dimensioned at least as large as the number of species in mix Description The species names may be strings of any length If the species names are longer than the number of characters in each element of the snames array the returned names will be truncated 26 molecularWeight The molecular weight of species k amu Syntax result molecularWeight mix k Arguments mix Input Mixture object type mixture_t k Input Species index integer Result Returns adouble precision value 2 8 Properties of the Species 31 draft November 29 2001 27 getMolecularWeights Get the array of species molecular weights Syntax call getMolecularWeights mix molWts Arguments mix Input Output Mixture object type mixture_t molWts Output Species molecular weights double precision array Must be dimensioned at least as large as the number of species in mix 2 9 Mixture Composition The mixture composition may be specified by mole fractions mass fractions or concentrations The proce dures described here set or
94. ty pair to hold fixed character Description This subroutine sets the mixture to a state of chemical equilibrium holding two thermodynamic prop erties fixed at their initial values The pair of properties is specified by a two character string as shown in the table below String TP TV HP SP SV UV Example use cantera Property 1 temperature temperature specific enthalpy specific entropy specific entropy specific internal energy type mixture t mix mix GRIMech30 Property 2 pressure specific volume pressure pressure specific volume specific volume call setState TPX mix 300 d0 OneAtm 61 CH4 0 9 02 2 draft November 29 2001 call eguilibrate mix HP call printSummary mix 6 Output temperature pressure density mean mol weight enthalpy internal energy entropy Gibbs function heat capacity c p heat capacity c v H2 02 OH H20 HO2 H202 CH CH2 CH2 S CH3 CH4 CO CO2 HCO CH20 CH20H CH30 CH30H C2H C2H2 C2H3 C2H4 C2H5 62 COO o00 1n n 0 10 Nl2NUIO P d 0 0n NN Pm N pmP 0 2134 24 101325 0 158033 27 6748 230208 871370 9727 6 2 09912e 007 1484 63 1184 22 339031e 004 174265e 004 387901e 004 847396e 002 687186e 003 699745e 001 949030e 007 557154e 008 158314e 019 275343e 020 037590e 019 000000e 000 912788e 019 440321e 019 327608e 003 382804e 002 389023e 011 885994e 013 13270
95. ure attribute We would like to be able to write something like this use cantera type mixture t mix type cstr t reactor write temperature mix temperature reactor This presents an immediate problem but one that Fortran 90 fortunately provides a solution for If we just define function temperature in the usual way we would have to specify the argument type If the function were then called with an argument of a different type then depending on the compiler and compile options the compile might abort good or the compiler might warn you ok or it might accept it bad resulting in code that runs but gives erroneous results To fix this problem we could define seperate function names for each mixture temperature cstr temperature etc but this would be awkward at best This is precisely what we would have to do in Fortran 77 1 7 Methods 9 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 amixture_t object an entirely different function reac_temperature that does the same for cst r_t objects and so on But in module cantera temperature is declared to be a generic name that
96. written Syntax call copy src dest Arguments src Input Reactor object type mixture_t dest Output Reactor object type mixture_t Description This procedure performs a shallow copy the handle is copied but not the object it points to 6 5 Setting Options These procedures set various optional reactor characteristics 122 setinitial Volume Set the initial reactor volume m By default the initial volume is 1 0 n Syntax call setInitial Volume reac vol Arguments 6 4 Assignment 87 draft November 29 2001 reac Input Output Reactor object type cstr_t vol Input Initial volume double precision Example use cantera type cstr t r r StirredReactor call setInitialVolume r 3 0 123 setlnitialTime Set the initial time s Default 0 0 s Syntax call setInitialTime reac time Arguments reac Input Output Reactor object type cstr_t time Input Initial time double precision Description Restarts integration from this time using the current substance state as the initial condition Note that this routine does no interpolation It simply sets the clock to the specified time takes the current state to be the value for that time and restarts Example use cantera type cstr t r r StirredReactor call setInitialTime r 0 02 124 setMaxStep Set the maximum step size for integration Syntax call setMaxStep reac maxstep Arguments reac Input Ou
97. xture and set its state gas CKGas mymech inp if not ready mix stop call setState TPX mix 1200 d0 OneAtm amp C2H2 1 0 NH3 2 0 02 0 5 create a reactor object and insert the gas reactrl StirredReactor call setMixture reactrl gas use the same gas object for another reactor call setState TPX mix 100 d0 OneAtm amp C2H2 1 0 NH3 2 0 02 0 5 reactr2 StirredReactor call setMixture reactr2 gag 133 contents Get the mixture contained in the reactor 6 6 Specifying the Mixture 93 draft November 29 2001 Syntax result contents reac Arguments reac Input Output Reactor object type cstr_t Result Returns a type mixture_t value 6 7 Operation 134 advance Advance the state of the reactor forward in time to time Syntax call advance reac time Arguments reac Input Output Reactor object type cstr_t time Input Final time s double precision Description Note that this method changes the state of the mixture object On the first call initialization is carried out and the maximum integrator step size is set By default this is set to time To specify a different maximum step size precede the call to advance with a call to setMaxStep Note that this cannot be reset after advance has been called 6 8 Reactor Attributes 183 residenceTime The residence time s Syntax result residenceTime reac Arguments reac Input Output Reactor object type cs
98. y mass reac Arguments 96 Chapter 6 Stirred Reactors draft November 29 2001 reac Input Output Reactor object type cstr_t Result Returns adouble precision value 142 pressure The pressure Pa Syntax result pressure reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 143 mass The total mass pV Syntax result mass reac Arguments reac Input Output Reactor object type cstr_t Result Returns a double precision value 144 enableChemistry Enable chemistry Syntax call enableChemistry reac Arguments reac Input Output Reactor object type cstr_t 6 9 Mixture Attributes 97 draft November 29 2001 145 disableChemistry Disable chemistry Syntax call disableChemistry reac Arguments reac Input Output Reactor object type cstr_t ct api 98 Chapter 6 Stirred Reactors draft November 29 2001 CHAPTER SEVEN Flow Devices Flow devices are objects that regulate fluid flow These objects are designed to be used in conjunction with the stirred Perhaps these is a better name for these than flow devices Any suggestions flowdev_t Object type used to represent flow control devices hndl integer Handle encoding pointer to the C object upstream type cstr_t Upstream reactor downstream type cstr t Downstream reactor type integer Flow controller type
99. y where input files should be looked for if not found in the local directory By default Cantera will look in CANTERA ROOT data 1 3 Installing Cantera 5 draft November 29 2001 1 4 Running Stand Alone Applications Cantera is distributed with a few simple application programs These are located in the apps subdirectory For example one such program is zero a general purpose zero dimensional kinetics simulator All of these applications include the source code unix Makefiles and Visual Studio project files so they can also function as starting points to build your own applications 1 5 The Cantera Fortran 90 Interface Cantera consists of a kernel written in C and a set of language interface libraries that allow using Cantera from other programming languages The kernel is object oriented and defines a set of classes that represent important entities for a reacting flow simulation The kernel is described in more detail elsewhere Much of the object oriented character of the C kernel is retained even in languages that are not themselves object oriented like Fortran Fortran 90 actually does implement a number of things that allow some degree of object oriented programming as a front end for C objects it works very well From Fortran 90 you can create objects that represent reacting mixtures or various types of reactors or ODE integrators or many other useful things A great advantage of an object oriented framewor
Download Pdf Manuals
Related Search
Related Contents
Les clés d`accès à Base Élèves Naii。naー 取扱説自害 DENON ST7MDT20-T32/DVP Installation Manual Samsung 24" LED moniteur C24A650X Manuel de l'utilisateur South Shore Furniture 3159229 Instructions / Assembly ニトリル歯科用グローブ - ハリヤード・ヘルスケア・インク NEC LCD1860NX Car Video System User Manual VOTRAN GOLD GUÍA DEL USUARIO RESERVA SERVICIO AL Copyright © All rights reserved.
Failed to retrieve file