Cantera  2.5.1
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 
12 // This file is part of Cantera. See License.txt in the top-level directory or
13 // at https://cantera.org/license.txt for license and copyright information.
14 
15 #ifndef CT_DEFS_H
16 #define CT_DEFS_H
17 
18 #include "config.h"
19 
20 #include <cmath>
21 
22 // STL includes
23 #include <cstdlib>
24 #include <vector>
25 #include <map>
26 #include <string>
27 #include <algorithm>
28 #include <memory>
29 
30 /**
31  * Namespace for the Cantera kernel.
32  */
33 namespace Cantera
34 {
35 
36 using std::shared_ptr;
37 using std::make_shared;
38 using std::unique_ptr;
39 using std::isnan; // workaround for bug in libstdc++ 4.8
40 
41 /*!
42  * All physical constants are stored here.
43  *
44  * @defgroup physConstants Physical Constants
45  * %Cantera uses the MKS system of units. The unit for moles
46  * is defined to be the kmol. All values of physical constants
47  * are consistent with the 2018 CODATA recommendations.
48  * @ingroup globalData
49  * @{
50  */
51 
52 //! Pi
53 const double Pi = 3.14159265358979323846;
54 
55 /*!
56  * @name Defined Constants
57  * These constants are defined by CODATA to have a particular value.
58  * https://physics.nist.gov/cuu/Constants/index.html
59  */
60 //@{
61 
62 //! Avogadro's Number \f$ N_{\mathrm{A}} \f$ [number/kmol]
63 const double Avogadro = 6.02214076e26;
64 
65 //! Boltzmann constant \f$ k \f$ [J/K]
66 const double Boltzmann = 1.380649e-23;
67 
68 //! Planck constant \f$ h \f$ [J-s]
69 const double Planck = 6.62607015e-34;
70 
71 //! Elementary charge \f$ e \f$ [C]
72 const double ElectronCharge = 1.602176634e-19;
73 
74 /// Speed of Light in a vacuum \f$ c \f$ [m/s]
75 const double lightSpeed = 299792458.0;
76 
77 //! One atmosphere [Pa]
78 const double OneAtm = 1.01325e5;
79 
80 //! One bar [Pa]
81 const double OneBar = 1.0E5;
82 
83 //@}
84 
85 /*!
86  * @name Measured Constants
87  * These constants are measured and reported by CODATA
88  */
89 //@{
90 
91 //! Fine structure constant \f$ \alpha \f$ []
92 const double fineStructureConstant = 7.2973525693e-3;
93 
94 //! Electron Mass \f$ m_e \f$ [kg]
95 const double ElectronMass = 9.1093837015e-31;
96 
97 //@}
98 
99 /*!
100  * @name Derived Constants
101  * These constants are found from the defined and measured constants
102  */
103 //@{
104 
105 //! Reduced Planck constant \f$ \hbar \f$ [m2-kg/s]
106 const double Planck_bar = Planck / (2 * Pi);
107 
108 //! Universal Gas Constant \f$ R_u \f$ [J/kmol/K]
109 const double GasConstant = Avogadro * Boltzmann;
110 
111 const double logGasConstant = std::log(GasConstant);
112 
113 //! Universal gas constant in cal/mol/K
114 const double GasConst_cal_mol_K = GasConstant / 4184.0;
115 
116 //! log(k_b/h)
117 const double logBoltz_Planck = std::log(Boltzmann / Planck);
118 
119 //! Stefan-Boltzmann constant \f$ \sigma \f$ [W/m2/K4]
120 const double StefanBoltz = Pi * Pi * std::pow(Boltzmann, 4.0) / (60.0 * std::pow(Planck_bar, 3.0) * lightSpeed * lightSpeed); // 5.670374419e-8
121 
122 //! Faraday constant \f$ F \f$ [C/kmol]
123 const double Faraday = ElectronCharge * Avogadro;
124 
125 //! Permeability of free space \f$ \mu_0 \f$ [N/A2]
127 
128 //! Permittivity of free space \f$ \varepsilon_0 \f$ [F/m]
129 const double epsilon_0 = 1.0 / (lightSpeed * lightSpeed * permeability_0);
130 
131 //@}
132 //@}
133 
134 /*!
135  * @name Thermodynamic Equilibrium Constraints
136  * Integer numbers representing pairs of thermodynamic variables
137  * which are held constant during equilibration.
138  */
139 //@{
140 const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105,
141  ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
142  PX = 112, TX = 113;
143 const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104,
144  VU = -105, TS = -106, VS = -107, PU = -108, HV = -109,
145  HT = -110, HS = -111, XP = -112, XT = -113;
146 //@}
147 
148 //! smallest number to compare to zero.
149 const double SmallNumber = 1.e-300;
150 //! largest number to compare to inf.
151 const double BigNumber = 1.e300;
152 //! largest x such that exp(x) is valid
153 const double 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 double 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
162  * fraction quantities when the molecular weight of a species is zero. It's also
163  * used for the matrix inversion of transport properties when mole fractions
164  * must be positive.
165  */
166 const double Tiny = 1.e-20;
167 
168 //! Map connecting a string name with a double.
169 /*!
170  * This is used mostly to assign concentrations and mole fractions to species.
171  */
172 typedef std::map<std::string, double> compositionMap;
173 
174 //! Map from string names to doubles. Used for defining species mole/mass
175 //! fractions, elemental compositions, and reaction stoichiometries.
176 typedef std::map<std::string, double> Composition;
177 
178 //! Turn on the use of stl vectors for the basic array type within cantera
179 //! Vector of doubles.
180 typedef std::vector<double> vector_fp;
181 //! Vector of ints
182 typedef std::vector<int> vector_int;
183 
184 //! A grouplist is a vector of groups of species
185 typedef std::vector<std::vector<size_t> > grouplist_t;
186 
187 //! index returned by functions to indicate "no position"
188 const size_t npos = static_cast<size_t>(-1);
189 
190 } // namespace
191 
192 #endif
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:188
const double Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:166
const double Boltzmann
Boltzmann constant [J/K].
Definition: ct_defs.h:66
std::vector< std::vector< size_t > > grouplist_t
A grouplist is a vector of groups of species.
Definition: ct_defs.h:185
const double Faraday
Faraday constant [C/kmol].
Definition: ct_defs.h:123
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:157
const double Avogadro
Avogadro's Number [number/kmol].
Definition: ct_defs.h:63
const double Planck
Planck constant [J-s].
Definition: ct_defs.h:69
const double logBoltz_Planck
log(k_b/h)
Definition: ct_defs.h:117
const double permeability_0
Permeability of free space [N/A2].
Definition: ct_defs.h:126
const double OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:78
std::map< std::string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:176
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:149
const double Planck_bar
Reduced Planck constant [m2-kg/s].
Definition: ct_defs.h:106
const double lightSpeed
Speed of Light in a vacuum [m/s].
Definition: ct_defs.h:75
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:182
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
Definition: ct_defs.h:120
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:180
const double epsilon_0
Permittivity of free space [F/m].
Definition: ct_defs.h:129
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:109
const double ElectronCharge
Elementary charge [C].
Definition: ct_defs.h:72
const double fineStructureConstant
Fine structure constant [].
Definition: ct_defs.h:92
const double GasConst_cal_mol_K
Universal gas constant in cal/mol/K.
Definition: ct_defs.h:114
const double OneBar
One bar [Pa].
Definition: ct_defs.h:81
const double Pi
Pi.
Definition: ct_defs.h:53
const double BigNumber
largest number to compare to inf.
Definition: ct_defs.h:151
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:172
const double MaxExp
largest x such that exp(x) is valid
Definition: ct_defs.h:153
const double ElectronMass
Electron Mass [kg].
Definition: ct_defs.h:95
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:264