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