Cantera  2.0
ct_defs.h
Go to the documentation of this file.
1 /**
2  * @file ct_defs.h
3  * This file contains definitions of terms that are used in internal
4  * routines and are unlikely to need modifying (text for module physConstants (see \ref physConstants) is found here).
5  * This file is included
6  * in every file that is in the Cantera Namespace.
7  *
8  * All physical constants are stored here.
9  * The module physConstants is defined here.
10  */
11 // Copyright 2001 California Institute of Technology
12 
13 
14 #ifndef CT_DEFS_H
15 #define CT_DEFS_H
16 
17 #include "config.h"
18 
19 #include <cmath>
20 
21 // STL includes
22 #include <cstdlib>
23 #include <vector>
24 #include <map>
25 #include <string>
26 
27 // Warn about deprecated functions at compile time
28 #ifdef __GNUC__
29 #define DEPRECATED(func) func __attribute__ ((deprecated))
30 #elif defined(_MSC_VER)
31 #define DEPRECATED(func) __declspec(deprecated) func
32 #else
33 #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
34 #define DEPRECATED(func) func
35 #endif
36 
37 /**
38  * Namespace for the Cantera kernel.
39  */
40 namespace Cantera
41 {
42 
43 #undef CHEMKIN_COMPATIBILITY_MODE
44 
45 //! Creates a pointer to the start of the raw data for a vector
46 #ifndef DATA_PTR
47 #define DATA_PTR(vec) &vec[0]
48 #endif
49 
50 /*!
51  * All physical constants are stored here.
52  *
53  * @defgroup physConstants Physical Constants
54  * %Cantera uses the MKS system of units. The unit for moles
55  * is defined to be the kmol. All values of physical constants
56  * are consistent with the 2010 CODATA recommendations.
57  * @ingroup globalData
58  * @{
59  */
60 
61 //! Pi
62 const doublereal Pi = 3.14159265358979323846;
63 //! sqrt(Pi)
64 const doublereal SqrtPi = std::sqrt(Pi);
65 
66 /*!
67  * @name Variations of the Gas Constant
68  * %Cantera uses the MKS system of units. The unit for moles
69  * is defined to be the kmol.
70  */
71 //@{
72 
73 //! Avogadro's Number [number/kmol]
74 const doublereal Avogadro = 6.02214129e26;
75 
76 /// Universal Gas Constant. [J/kmol/K]
77 const doublereal GasConstant = 8314.4621;
78 
79 const doublereal logGasConstant = std::log(GasConstant);
80 
81 //! One atmosphere [Pa]
82 const doublereal OneAtm = 1.01325e5;
83 
84 //! Universal gas constant in cal/mol/K
85 const doublereal GasConst_cal_mol_K = GasConstant / 4184.0;
86 
87 //! Boltzmann's constant [J/K]
88 const doublereal Boltzmann = GasConstant / Avogadro;
89 
90 /// Planck's constant. [J-s]
91 const doublereal Planck = 6.62607009e-34; // J-s
92 const doublereal Planck_bar = Planck / (2 * Pi); // m2-kg/s
93 
94 /// log(k/h)
95 const doublereal logBoltz_Planck = std::log(Boltzmann / Planck); // ln(k_B/h)
96 /// Stefan-Boltzmann constant
97 const doublereal StefanBoltz = 5.670373e-8;
98 
99 //@}
100 /// @name Electron Properties
101 //@{
102 const doublereal ElectronCharge = 1.602176565e-19; // C
103 const doublereal ElectronMass = 9.10938291e-31; // kg
104 const doublereal Faraday = ElectronCharge * Avogadro;
105 //@}
106 
107 /// @name Electromagnetism
108 /// %Cantera uses the MKS unit system.
109 //@{
110 
111 /// Speed of Light (m/s).
112 const doublereal lightSpeed = 299792458.0;
113 
114 /// Permeability of free space \f$ \mu_0 \f$ in N/A^2.
115 const doublereal permeability_0 = 4.0e-7*Pi;
116 
117 /// Permittivity of free space \f$ \epsilon_0 \f$ in F/m.
118 const doublereal epsilon_0 = 1.0 / (lightSpeed*lightSpeed*permeability_0);
119 
120 //@}
121 //@}
122 
123 /*!
124  * @name Thermodynamic Equilibrium Constraints
125  * Integer numbers representing pairs of thermodynamic variables
126  * which are held constant during equilibration.
127  */
128 //@{
129 const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105,
130  ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
131  PX = 112, TX = 113;
132 const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104,
133  VU = -105, TS = -106, VS = -107, PU = -108, HV = -109,
134  HT = -110, HS = -111, XP = -112, XT = -113;
135 //@}
136 
137 //! 1/3
138 const doublereal OneThird = 1.0/3.0;
139 //! 5/16
140 const doublereal FiveSixteenths = 5.0/16.0;
141 //! sqrt(10)
142 const doublereal SqrtTen = std::sqrt(10.0);
143 //! sqrt(8)
144 const doublereal SqrtEight = std::sqrt(8.0);
145 //! sqrt(2)
146 const doublereal SqrtTwo = std::sqrt(2.0);
147 
148 //! smallest number to compare to zero.
149 const doublereal SmallNumber = 1.e-300;
150 //! largest number to compare to inf.
151 const doublereal BigNumber = 1.e300;
152 //! largest x such that exp(x) is valid
153 const doublereal MaxExp = 690.775527898;
154 
155 //! Fairly random number to be used to initialize variables against
156 //! to see if they are subsequently defined.
157 const doublereal Undef = -999.1234;
158 
159 //! Small number to compare differences of mole fractions against.
160 /*!
161  * This number is used for the interconversion of mole fraction and mass fraction quantities
162  * when the molecular weight of a species is zero. It's also used for the matrix inversion
163  * of transport properties when mole fractions must be positive.
164  */
165 const doublereal Tiny = 1.e-20;
166 
167 //! Map connecting a string name with a double.
168 /*!
169  * This is used mostly to assign concentrations and mole fractions
170  * to species.
171  */
172 typedef std::map<std::string, doublereal> compositionMap;
173 //! Turn on the use of stl vectors for the basic array type within cantera
174 //! Vector of doubles.
175 typedef std::vector<double> vector_fp;
176 //! Vector of ints
177 typedef std::vector<int> vector_int;
178 
179 //! A grouplist is a vector of groups of species
180 typedef std::vector<std::vector<size_t> > grouplist_t;
181 
182 //! index returned by functions to indicate "no position"
183 const size_t npos = static_cast<size_t>(-1);
184 
185 } // namespace
186 
187 #endif