Cantera  2.3.0
ct_defs.h
Go to the documentation of this file.
1 /**
2  * @file ct_defs.h
3  * This file contains definitions of terms that are used in internal
4  * routines and are unlikely to need modifying (text for module physConstants (see \ref physConstants) is found here).
5  * This file is included
6  * in every file that is in the Cantera Namespace.
7  *
8  * All physical constants are stored here.
9  * The module physConstants is defined here.
10  */
11 
12 // This file is part of Cantera. See License.txt in the top-level directory or
13 // at http://www.cantera.org/license.txt for license and copyright information.
14 
15 #ifndef CT_DEFS_H
16 #define CT_DEFS_H
17 
18 #include "config.h"
19 
20 #include <cmath>
21 
22 // STL includes
23 #include <cstdlib>
24 #include <vector>
25 #include <map>
26 #include <string>
27 #include <algorithm>
28 #include <memory>
29 
30 /**
31  * Namespace for the Cantera kernel.
32  */
33 namespace Cantera
34 {
35 
36 using std::shared_ptr;
37 using std::make_shared;
38 
39 /*!
40  * All physical constants are stored here.
41  *
42  * @defgroup physConstants Physical Constants
43  * %Cantera uses the MKS system of units. The unit for moles
44  * is defined to be the kmol. All values of physical constants
45  * are consistent with the 2010 CODATA recommendations.
46  * @ingroup globalData
47  * @{
48  */
49 
50 //! Pi
51 const doublereal Pi = 3.14159265358979323846;
52 
53 /*!
54  * @name Variations of the Gas Constant
55  * %Cantera uses the MKS system of units. The unit for moles
56  * is defined to be the kmol.
57  */
58 //@{
59 
60 //! Avogadro's Number [number/kmol]
61 const doublereal Avogadro = 6.02214129e26;
62 
63 /// Universal Gas Constant. [J/kmol/K]
64 const doublereal GasConstant = 8314.4621;
65 
66 const doublereal logGasConstant = std::log(GasConstant);
67 
68 //! One atmosphere [Pa]
69 const doublereal OneAtm = 1.01325e5;
70 const doublereal OneBar = 1.0E5;
71 
72 //! Universal gas constant in cal/mol/K
73 const doublereal GasConst_cal_mol_K = GasConstant / 4184.0;
74 
75 //! Boltzmann's constant [J/K]
76 const doublereal Boltzmann = GasConstant / Avogadro;
77 
78 /// Planck's constant. [J-s]
79 const doublereal Planck = 6.62607009e-34; // J-s
80 const doublereal Planck_bar = Planck / (2 * Pi); // m2-kg/s
81 
82 /// log(k/h)
83 const doublereal logBoltz_Planck = std::log(Boltzmann / Planck); // ln(k_B/h)
84 /// Stefan-Boltzmann constant
85 const doublereal StefanBoltz = 5.670373e-8;
86 
87 //@}
88 /// @name Electron Properties
89 //@{
90 const doublereal ElectronCharge = 1.602176565e-19; // C
91 const doublereal ElectronMass = 9.10938291e-31; // kg
92 const doublereal Faraday = ElectronCharge * Avogadro;
93 //@}
94 
95 /// @name Electromagnetism
96 /// %Cantera uses the MKS unit system.
97 //@{
98 
99 /// Speed of Light (m/s).
100 const doublereal lightSpeed = 299792458.0;
101 
102 /// Permeability of free space \f$ \mu_0 \f$ in N/A^2.
103 const doublereal permeability_0 = 4.0e-7*Pi;
104 
105 /// Permittivity of free space \f$ \epsilon_0 \f$ in F/m.
106 const doublereal epsilon_0 = 1.0 / (lightSpeed*lightSpeed*permeability_0);
107 
108 //@}
109 //@}
110 
111 /*!
112  * @name Thermodynamic Equilibrium Constraints
113  * Integer numbers representing pairs of thermodynamic variables
114  * which are held constant during equilibration.
115  */
116 //@{
117 const int TV = 100, HP = 101, SP = 102, PV = 103, TP = 104, UV = 105,
118  ST = 106, SV = 107, UP = 108, VH = 109, TH = 110, SH = 111,
119  PX = 112, TX = 113;
120 const int VT = -100, PH = -101, PS = -102, VP = -103, PT = -104,
121  VU = -105, TS = -106, VS = -107, PU = -108, HV = -109,
122  HT = -110, HS = -111, XP = -112, XT = -113;
123 //@}
124 
125 //! smallest number to compare to zero.
126 const doublereal SmallNumber = 1.e-300;
127 //! largest number to compare to inf.
128 const doublereal BigNumber = 1.e300;
129 //! largest x such that exp(x) is valid
130 const doublereal MaxExp = 690.775527898;
131 
132 //! Fairly random number to be used to initialize variables against
133 //! to see if they are subsequently defined.
134 const doublereal Undef = -999.1234;
135 
136 //! Small number to compare differences of mole fractions against.
137 /*!
138  * This number is used for the interconversion of mole fraction and mass
139  * fraction quantities when the molecular weight of a species is zero. It's also
140  * used for the matrix inversion of transport properties when mole fractions
141  * must be positive.
142  */
143 const doublereal Tiny = 1.e-20;
144 
145 //! Map connecting a string name with a double.
146 /*!
147  * This is used mostly to assign concentrations and mole fractions to species.
148  */
149 typedef std::map<std::string, doublereal> compositionMap;
150 
151 //! Map from string names to doubles. Used for defining species mole/mass
152 //! fractions, elemental compositions, and reaction stoichiometries.
153 typedef std::map<std::string, doublereal> Composition;
154 
155 //! Turn on the use of stl vectors for the basic array type within cantera
156 //! Vector of doubles.
157 typedef std::vector<double> vector_fp;
158 //! Vector of ints
159 typedef std::vector<int> vector_int;
160 
161 //! A grouplist is a vector of groups of species
162 typedef std::vector<std::vector<size_t> > grouplist_t;
163 
164 //! index returned by functions to indicate "no position"
165 const size_t npos = static_cast<size_t>(-1);
166 
167 } // namespace
168 
169 #endif
std::map< std::string, doublereal > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:149
const doublereal StefanBoltz
Stefan-Boltzmann constant.
Definition: ct_defs.h:85
const doublereal OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:69
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
const doublereal Pi
Pi.
Definition: ct_defs.h:51
const doublereal Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:134
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:159
const doublereal BigNumber
largest number to compare to inf.
Definition: ct_defs.h:128
std::map< std::string, doublereal > Composition
Map from string names to doubles.
Definition: ct_defs.h:153
const doublereal logBoltz_Planck
log(k/h)
Definition: ct_defs.h:83
const doublereal Planck
Planck&#39;s constant. [J-s].
Definition: ct_defs.h:79
const doublereal MaxExp
largest x such that exp(x) is valid
Definition: ct_defs.h:130
const doublereal Avogadro
Avogadro&#39;s Number [number/kmol].
Definition: ct_defs.h:61
const doublereal SmallNumber
smallest number to compare to zero.
Definition: ct_defs.h:126
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:157
const doublereal Tiny
Small number to compare differences of mole fractions against.
Definition: ct_defs.h:143
const doublereal permeability_0
Permeability of free space in N/A^2.
Definition: ct_defs.h:103
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
const doublereal GasConst_cal_mol_K
Universal gas constant in cal/mol/K.
Definition: ct_defs.h:73
const doublereal epsilon_0
Permittivity of free space in F/m.
Definition: ct_defs.h:106
const doublereal lightSpeed
Speed of Light (m/s).
Definition: ct_defs.h:100
std::vector< std::vector< size_t > > grouplist_t
A grouplist is a vector of groups of species.
Definition: ct_defs.h:162
Namespace for the Cantera kernel.
Definition: application.cpp:29
const doublereal Boltzmann
Boltzmann&#39;s constant [J/K].
Definition: ct_defs.h:76