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