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