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