ct_defs.h

Go to the documentation of this file.
00001 /**
00002  * @file ct_defs.h
00003  * This file contains definitions of terms that are used in internal 
00004  * routines and are unlikely to need modifying (text for module physConstants (see \ref physConstants) is found here). 
00005  * This file is included
00006  * in every file that is in the Cantera Namespace.
00007  *
00008  * All physical constants are stored here.
00009  * The module physConstants is defined here.
00010  */
00011 
00012 /*
00013  * $Revision: 368 $
00014  * $Date: 2010-01-03 19:46:26 -0500 (Sun, 03 Jan 2010) $
00015  */
00016 
00017 // Copyright 2001  California Institute of Technology
00018 
00019 
00020 #ifndef CT_DEFS_H
00021 #define CT_DEFS_H
00022 
00023 #include <cmath>
00024 #include "config.h"
00025 
00026 // STL includes
00027 #include <iostream>
00028 #include <fstream>
00029 #include <vector>
00030 #include <map>
00031 #include <numeric>
00032 #include <string>
00033 #include <algorithm>
00034 
00035 /**
00036  * Namespace for the Cantera kernel.
00037  */
00038 namespace Cantera {
00039 
00040 
00041 #ifdef WIN32
00042 #define TYPENAME_KEYWORD
00043 #pragma warning(disable:4267)
00044 #else
00045 //! create a define for the typename command
00046 #define TYPENAME_KEYWORD typename
00047 #endif
00048 
00049 #undef CHEMKIN_COMPATIBILITY_MODE
00050 
00051 //! Creates a pointer to the start of the raw data for a ctvector
00052 #ifndef DATA_PTR
00053 #define DATA_PTR(vec) &vec[0]
00054 #endif
00055 
00056  /*!
00057   * All physical constants are stored here.
00058   *
00059   * @defgroup physConstants Physical Constants
00060   * %Cantera uses the MKS system of units. The unit for moles 
00061   * is defined to be the kmol. All values of physical constants
00062   * are consistent with the 2006 CODATA recommendations.
00063   * @ingroup globalData
00064   * @{
00065   */
00066   //! Pi
00067     const doublereal Pi = 3.1415926;
00068   //! sqrt(Pi)
00069     const doublereal SqrtPi = std::sqrt(Pi);
00070 
00071   
00072   /*!
00073    *   @name Variations of the Gas Constant
00074    * %Cantera uses the MKS system of units. The unit for moles 
00075    * is defined to be the kmol.
00076    */
00077   //@{
00078 
00079     /// Avogadro's Number
00080     const doublereal Avogadro = 6.02214179e26; //   /kmol
00081 
00082     /// Universal Gas Constant. 2006 CODATA value.
00083     const doublereal GasConstant = 8314.47215; // J/kmol/K
00084 
00085     const doublereal logGasConstant = 9.025752908;
00086 
00087     /// One atmosphere
00088     const doublereal OneAtm = 1.01325e5;             // Pa
00089 
00090     /// Universal gas constant in cal/mol/K
00091     const doublereal GasConst_cal_mol_K = 1.987;
00092 
00093     /// Boltzmann's constant
00094     const doublereal Boltzmann = GasConstant / Avogadro;
00095 
00096     /// Planck's constant. Units of J-s
00097     const doublereal Planck = 6.62606896e-34;           // J-s
00098     const doublereal Planck_bar = 1.05457162853e-34;    // m2-kg/s
00099 
00100     /// log(k/h)
00101     const doublereal logBoltz_Planck = 23.7599032;  // ln(k_B/h)
00102     /// Stefan-Boltzmann constant
00103     const doublereal StefanBoltz = 5.6704004e-8;
00104 
00105     //@}
00106     /// @name Electron Properties
00107     //@{
00108     const doublereal ElectronCharge = 1.60217648740e-19; // C
00109     const doublereal ElectronMass = 9.1093821545e-31; // kg
00110     const doublereal Faraday = ElectronCharge * Avogadro;
00111     //@}
00112 
00113     /// @name Electromagnetism
00114     /// %Cantera uses the MKS unit system.
00115     //@{
00116 
00117     /// Permittivity of free space \f$ \epsilon_0 \f$ in F/m.
00118     const doublereal epsilon_0 = 8.85417817e-12;  // Farads/m = C^2/N/m^2
00119 
00120     /// Permeability of free space \f$ \mu_0 \f$ in N/A^2.
00121     const doublereal permeability_0 = 4.0e-7*Pi; // N/A^2
00122 
00123     /// Speed of Light (m/s).
00124     const doublereal lightSpeed = 1.0/std::sqrt(epsilon_0 * permeability_0);
00125 
00126     //@}
00127  //@}
00128  
00129   /*!
00130    * @name Thermodynamic Equilibrium Constraints
00131    * Integer numbers representing pairs of thermodynamic variables
00132    * which are held constant during equilibration.
00133    */
00134   //@{
00135     const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105, 
00136               ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
00137               PX = 112, TX = 113;
00138     const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104, 
00139               VU = -105, TS = -106, VS = -107, PU = -108, HV = -109, 
00140               HT = -110, HS = -111, XP = -112, XT = -113;
00141   //@}
00142 
00143   //! 1/3
00144     const doublereal OneThird = 1.0/3.0;
00145   //! 5/16
00146     const doublereal FiveSixteenths = 5.0/16.0;
00147   //! sqrt(10)
00148     const doublereal SqrtTen = std::sqrt(10.0);
00149   //! sqrt(8)
00150     const doublereal SqrtEight = std::sqrt(8.0);
00151   //! sqrt(2)
00152     const doublereal SqrtTwo = std::sqrt(2.0);
00153 
00154   //! smallest number to compare to zero.
00155     const doublereal SmallNumber = 1.e-300;
00156   //! largest number to compare to inf.
00157     const doublereal BigNumber = 1.e300;
00158   //! largest x such that exp(x) is valid
00159     const doublereal MaxExp = 690.775527898;         
00160 
00161   //! Fairly random number to be used to initialize variables against
00162   //! to see if they are subsequently defined.
00163     const doublereal Undef = -999.1234;
00164   //! Small number to compare differences of mole fractions against.
00165     const doublereal Tiny = 1.e-20;
00166 
00167   //! inline function to return the max value of two doubles.
00168   /*!
00169    * @param x  double value
00170    * @param y  second double value
00171    */
00172   inline doublereal fmaxx(doublereal x, doublereal y)
00173   { return (x > y) ? x : y; }
00174 
00175   //! inline function to return the min value of two doubles.
00176   /*!
00177    * @param x  double value
00178    * @param y  second double value
00179    */
00180   inline doublereal fminn(doublereal x, doublereal y)
00181   { return (x < y) ? x : y; }
00182   
00183 
00184   //! Map connecting a string name with a double.
00185   /*!
00186    * This is used mostly to assign concentrations and mole fractions
00187    * to species.
00188    */
00189     typedef std::map<std::string, doublereal> compositionMap;
00190 //! Turn on the use of stl vectors for the basic array type within cantera
00191 #define USE_STL_VECTOR
00192 #ifdef USE_STL_VECTOR
00193   //! Vector of doubles.
00194     typedef std::vector<double>        array_fp;
00195   //! Vector of doubles.
00196     typedef std::vector<double>        vector_fp;
00197   //! Vector of ints
00198     typedef std::vector<int>           array_int;
00199   //! Vector of ints
00200     typedef std::vector<int>           vector_int;
00201 #else
00202     typedef ct::ctvector_fp            array_fp;
00203     typedef ct::ctvector_fp            vector_fp;
00204     typedef ct::ctvector_int           array_int;
00205     typedef ct::ctvector_int           vector_int;
00206 #endif
00207   //! typedef for a group of species.
00208   /*!
00209    * A group of species is a subset of the species in a phase.
00210    */
00211     typedef vector_int         group_t;
00212   //! typedef for a vector of groups of species.
00213   /*!
00214    * A grouplist of species is a vector of groups.
00215    */
00216   typedef std::vector<group_t>    grouplist_t;
00217  
00218   //! Typedef for a pointer to temporary work storage
00219     typedef doublereal* workPtr;
00220   //! typedef for a pointer to temporary work storage which is treated as constant
00221     typedef const doublereal* const_workPtr;
00222 
00223 
00224 }  // namespace
00225 
00226 #endif
00227 
00228 
00229 
Generated by  doxygen 1.6.3