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