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 */
32 namespace Cantera
33{
34
35 using std::shared_ptr;
36 using std::make_shared;
37 using std::unique_ptr;
38 using 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
52 const double Pi = 3.14159265358979323846;
53
54//! Sqrt(2)
55 const 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]
66 const double Avogadro = 6.02214076e26;
67
68//! Boltzmann constant \f$ k \f$ [J/K]
69 const double Boltzmann = 1.380649e-23;
70
71//! Planck constant \f$ h \f$ [J-s]
72 const double Planck = 6.62607015e-34;
73
74//! Elementary charge \f$ e \f$ [C]
75 const double ElectronCharge = 1.602176634e-19;
76
77/// Speed of Light in a vacuum \f$ c \f$ [m/s]
78 const double lightSpeed = 299792458.0;
79
80//! One atmosphere [Pa]
81 const double OneAtm = 1.01325e5;
82
83//! One bar [Pa]
84 const 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$ []
95 const double fineStructureConstant = 7.2973525693e-3;
96
97//! Electron Mass \f$ m_e \f$ [kg]
98 const 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.
110 const double Planck_bar = Planck / (2 * Pi);
111
112//! Universal Gas Constant \f$ R_u \f$ [J/kmol/K]
113 const double GasConstant = Avogadro * Boltzmann;
114
115 const double logGasConstant = std::log(GasConstant);
116
117//! Universal gas constant in cal/mol/K
118 const double GasConst_cal_mol_K = GasConstant / 4184.0;
119
120//! log(k_b/h)
121//! @deprecated Unused. To be removed after Cantera 2.6.
122 const double logBoltz_Planck = std::log(Boltzmann / Planck);
123
124//! Stefan-Boltzmann constant \f$ \sigma \f$ [W/m2/K4]
125 const 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]
128 const double Faraday = ElectronCharge * Avogadro;
129
130//! Permeability of free space \f$ \mu_0 \f$ [N/A2]
131 const double permeability_0 = 2 * fineStructureConstant * Planck / (ElectronCharge * ElectronCharge * lightSpeed);
132
133//! Permittivity of free space \f$ \varepsilon_0 \f$ [F/m]
134 const double epsilon_0 = 1.0 / (lightSpeed * lightSpeed * permeability_0);
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//! @{
144 const 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;
147 const 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.
153 const double SmallNumber = 1.e-300;
154//! largest number to compare to inf.
155 const double BigNumber = 1.e300;
156//! largest x such that exp(x) is valid
157 const double MaxExp = 690.775527898;
158
159//! Fairly random number to be used to initialize variables against
160//! to see if they are subsequently defined.
161 const 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 */
170 const 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 */
176 typedef 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.
180 typedef 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.
184 typedef std::vector<double> vector_fp;
185//! Vector of ints
186 typedef std::vector<int> vector_int;
187
188//! A grouplist is a vector of groups of species
189 typedef std::vector<std::vector<size_t> > grouplist_t;
190
191//! index returned by functions to indicate "no position"
192 const size_t npos = static_cast<size_t>(-1);
193
194} // namespace
195
196#endif
Cantera::Pi
const double Pi
Pi.
Definition: ct_defs.h:52
Cantera::Sqrt2
const double Sqrt2
Sqrt(2)
Definition: ct_defs.h:55
Cantera
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:557
Cantera::npos
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
Cantera::Tiny
const double Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:170
Cantera::Boltzmann
const double Boltzmann
Boltzmann constant [J/K].
Definition: ct_defs.h:69
Cantera::grouplist_t
std::vector< std::vector< size_t > > grouplist_t
A grouplist is a vector of groups of species.
Definition: ct_defs.h:189
Cantera::Faraday
const double Faraday
Faraday constant [C/kmol].
Definition: ct_defs.h:128
Cantera::Undef
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
Cantera::Avogadro
const double Avogadro
Avogadro's Number [number/kmol].
Definition: ct_defs.h:66
Cantera::Planck
const double Planck
Planck constant [J-s].
Definition: ct_defs.h:72
Cantera::logBoltz_Planck
const double logBoltz_Planck
log(k_b/h)
Definition: ct_defs.h:122
Cantera::permeability_0
const double permeability_0
Permeability of free space [N/A2].
Definition: ct_defs.h:131
Cantera::OneAtm
const double OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:81
Cantera::Composition
std::map< std::string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:180
Cantera::SmallNumber
const double SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:153
Cantera::Planck_bar
const double Planck_bar
Reduced Planck constant [m2-kg/s].
Definition: ct_defs.h:110
Cantera::lightSpeed
const double lightSpeed
Speed of Light in a vacuum [m/s].
Definition: ct_defs.h:78
Cantera::vector_int
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:186
Cantera::StefanBoltz
const double StefanBoltz
Stefan-Boltzmann constant [W/m2/K4].
Definition: ct_defs.h:125
Cantera::vector_fp
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
Cantera::epsilon_0
const double epsilon_0
Permittivity of free space [F/m].
Definition: ct_defs.h:134
Cantera::GasConstant
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition: ct_defs.h:113
Cantera::ElectronCharge
const double ElectronCharge
Elementary charge [C].
Definition: ct_defs.h:75
Cantera::fineStructureConstant
const double fineStructureConstant
Fine structure constant [].
Definition: ct_defs.h:95
Cantera::GasConst_cal_mol_K
const double GasConst_cal_mol_K
Universal gas constant in cal/mol/K.
Definition: ct_defs.h:118
Cantera::OneBar
const double OneBar
One bar [Pa].
Definition: ct_defs.h:84
Cantera::BigNumber
const double BigNumber
largest number to compare to inf.
Definition: ct_defs.h:155
Cantera::compositionMap
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:176
Cantera::MaxExp
const double MaxExp
largest x such that exp(x) is valid
Definition: ct_defs.h:157
Cantera::ElectronMass
const double ElectronMass
Electron Mass [kg].
Definition: ct_defs.h:98