thermo.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::thermo
29
30Description
31 Basic thermodynamics type based on the use of fitting functions for
32 cp, h, s obtained from the template argument type thermo. All other
33 properties are derived from these primitive functions.
34
35SourceFiles
36 thermoI.H
37 thermo.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef thermo_H
42#define thermo_H
43
45using namespace Foam::constant::thermodynamic;
46
47// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48
49namespace Foam
51namespace species
52{
53
54// Forward declaration of friend functions and operators
55
56template<class Thermo, template<class> class Type> class thermo;
57
58template<class Thermo, template<class> class Type>
59inline thermo<Thermo, Type> operator+
60(
63);
64
65template<class Thermo, template<class> class Type>
66inline thermo<Thermo, Type> operator*
67(
68 const scalar,
70);
71
72template<class Thermo, template<class> class Type>
73inline thermo<Thermo, Type> operator==
74(
77);
78
79template<class Thermo, template<class> class Type>
80Ostream& operator<<
81(
82 Ostream&,
84);
85
86
87/*---------------------------------------------------------------------------*\
88 Class thermo Declaration
89\*---------------------------------------------------------------------------*/
90
91template<class Thermo, template<class> class Type>
92class thermo
93:
94 public Thermo,
95 public Type<thermo<Thermo, Type>>
96{
97 // Private data
98
99 //- Convergence tolerance of energy -> temperature inversion functions
100 static const scalar tol_;
101
102 //- Max number of iterations in energy->temperature inversion functions
103 static const int maxIter_;
104
105
106 // Private Member Functions
107
108 //- Return the temperature corresponding to the value of the
109 // thermodynamic property f, given the function f = F(p, T)
110 // and dF(p, T)/dT
111 inline scalar T
112 (
113 scalar f,
114 scalar p,
115 scalar T0,
116 scalar (thermo::*F)(const scalar, const scalar) const,
117 scalar (thermo::*dFdT)(const scalar, const scalar) const,
118 scalar (thermo::*limit)(const scalar) const
119 ) const;
120
121
122public:
123
124 //- The thermodynamics of the individual species'
126
127
128 // Constructors
129
130 //- Construct from components
131 inline thermo(const Thermo& sp);
132
133 //- Construct from dictionary
134 thermo(const dictionary& dict);
135
136 //- Construct as named copy
137 inline thermo(const word& name, const thermo&);
138
139
140 // Member Functions
141
142 //- Return the instantiated type name
143 static word typeName()
144 {
145 return
146 Thermo::typeName() + ','
147 + Type<thermo<Thermo, Type>>::typeName();
148 }
149
150 //- Name of Enthalpy/Internal energy
151 static inline word heName();
152
153
154 // Fundamental properties
155 // (These functions must be provided in derived types)
156
157 // Heat capacity at constant pressure [J/(kg K)]
158 // inline scalar Cp(const scalar p, const scalar T) const;
159
160 // Sensible enthalpy [J/kg]
161 // inline scalar Hs(const scalar p, const scalar T) const;
162
163 // Chemical enthalpy [J/kg]
164 // inline scalar Hc() const;
165
166 // Absolute Enthalpy [J/kg]
167 // inline scalar Ha(const scalar p, const scalar T) const;
168
169 // Heat capacity at constant volume [J/(kg K)]
170 // inline scalar Cv(const scalar p, const scalar T) const;
171
172 // Sensible internal energy [J/kg]
173 // inline scalar Es(const scalar p, const scalar T) const;
174
175 // Absolute internal energy [J/kg]
176 // inline scalar Ea(const scalar p, const scalar T) const;
177
178 // Entropy [J/(kg K)]
179 // inline scalar S(const scalar p, const scalar T) const;
180
181
182 // Mass specific derived properties
183
184
185 //- Heat capacity at constant pressure/volume [J/(kg K)]
186 inline scalar Cpv(const scalar p, const scalar T) const;
187
188 //- Gamma = Cp/Cv []
189 inline scalar gamma(const scalar p, const scalar T) const;
190
191 //- Ratio of heat capacity at constant pressure to that at
192 // constant pressure/volume []
193 inline scalar CpByCpv(const scalar p, const scalar T) const;
194
195 //- Enthalpy/Internal energy [J/kg]
196 inline scalar HE(const scalar p, const scalar T) const;
197
198 //- Gibbs free energy [J/kg]
199 inline scalar G(const scalar p, const scalar T) const;
200
201 //- Helmholtz free energy [J/kg]
202 inline scalar A(const scalar p, const scalar T) const;
203
204
205 // Mole specific derived properties
206
207 //- Heat capacity at constant pressure [J/(kmol K)]
208 inline scalar cp(const scalar p, const scalar T) const;
209
210 //- Absolute Enthalpy [J/kmol]
211 inline scalar ha(const scalar p, const scalar T) const;
212
213 //- Sensible enthalpy [J/kmol]
214 inline scalar hs(const scalar p, const scalar T) const;
215
216 //- Chemical enthalpy [J/kmol]
217 inline scalar hc() const;
218
219 //- Entropy [J/(kmol K)]
220 inline scalar s(const scalar p, const scalar T) const;
221
222 //- Enthalpy/Internal energy [J/kmol]
223 inline scalar he(const scalar p, const scalar T) const;
224
225 //- Heat capacity at constant volume [J/(kmol K)]
226 inline scalar cv(const scalar p, const scalar T) const;
227
228 //- Sensible internal energy [J/kmol]
229 inline scalar es(const scalar p, const scalar T) const;
230
231 //- Absolute internal energy [J/kmol]
232 inline scalar ea(const scalar p, const scalar T) const;
233
234 //- Gibbs free energy [J/kmol]
235 inline scalar g(const scalar p, const scalar T) const;
236
237 //- Helmholtz free energy [J/kmol]
238 inline scalar a(const scalar p, const scalar T) const;
239
240
241 // Equilibrium reaction thermodynamics
242
243 //- Equilibrium constant [] i.t.o fugacities
244 // = PIi(fi/Pstd)^nui
245 inline scalar K(const scalar p, const scalar T) const;
246
247 //- Equilibrium constant [] i.t.o. partial pressures
248 // = PIi(pi/Pstd)^nui
249 // For low pressures (where the gas mixture is near perfect) Kp = K
250 inline scalar Kp(const scalar p, const scalar T) const;
251
252 //- Equilibrium constant i.t.o. molar concentration
253 // = PIi(ci/cstd)^nui
254 // For low pressures (where the gas mixture is near perfect)
255 // Kc = Kp(pstd/(RR*T))^nu
256 inline scalar Kc(const scalar p, const scalar T) const;
257
258 //- Equilibrium constant [] i.t.o. mole-fractions
259 // For low pressures (where the gas mixture is near perfect)
260 // Kx = Kp(pstd/p)^nui
261 inline scalar Kx
262 (
263 const scalar p,
264 const scalar T
265 ) const;
266
267 //- Equilibrium constant [] i.t.o. number of moles
268 // For low pressures (where the gas mixture is near perfect)
269 // Kn = Kp(n*pstd/p)^nui where n = number of moles in mixture
270 inline scalar Kn
271 (
272 const scalar p,
273 const scalar T,
274 const scalar n
275 ) const;
276
277
278 // Energy->temperature inversion functions
279
280 //- Temperature from enthalpy or internal energy
281 // given an initial temperature T0
282 inline scalar THE
283 (
284 const scalar H,
285 const scalar p,
286 const scalar T0
287 ) const;
288
289 //- Temperature from sensible enthalpy given an initial T0
290 inline scalar THs
291 (
292 const scalar Hs,
293 const scalar p,
294 const scalar T0
295 ) const;
296
297 //- Temperature from absolute enthalpy
298 // given an initial temperature T0
299 inline scalar THa
300 (
301 const scalar H,
302 const scalar p,
303 const scalar T0
304 ) const;
305
306 //- Temperature from sensible internal energy
307 // given an initial temperature T0
308 inline scalar TEs
309 (
310 const scalar E,
311 const scalar p,
312 const scalar T0
313 ) const;
314
315 //- Temperature from absolute internal energy
316 // given an initial temperature T0
317 inline scalar TEa
318 (
319 const scalar E,
320 const scalar p,
321 const scalar T0
322 ) const;
323
324
325 // Derivative term used for Jacobian
326
327 //- Derivative of B (acooding to Niemeyer et al.) w.r.t. temperature
328 inline scalar dKcdTbyKc(const scalar p, const scalar T) const;
329
330 //- Derivative of cp w.r.t. temperature
331 inline scalar dcpdT(const scalar p, const scalar T) const;
332
333
334 // I-O
335
336 //- Write to Ostream
337 void write(Ostream& os) const;
338
339
340 // Member operators
341
342 inline void operator+=(const thermo&);
343 inline void operator*=(const scalar);
344
345
346 // Friend operators
348 friend thermo operator+ <Thermo, Type>
349 (
350 const thermo&,
351 const thermo&
352 );
354 friend thermo operator* <Thermo, Type>
355 (
356 const scalar s,
357 const thermo&
358 );
360 friend thermo operator== <Thermo, Type>
361 (
362 const thermo&,
363 const thermo&
364 );
365
366
367 // Ostream Operator
369 friend Ostream& operator<< <Thermo, Type>
370 (
371 Ostream&,
372 const thermo&
373 );
374};
375
376
377// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378
379} // End namespace species
380} // End namespace Foam
381
382// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383
384#include "thermoI.H"
385
386#ifdef NoRepository
387 #include "thermo.C"
388#endif
389
390// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391
392#endif
393
394// ************************************************************************* //
static const Foam::dimensionedScalar A("", Foam::dimPressure, 611.21)
CGAL::Exact_predicates_exact_constructions_kernel K
scalar Hs(const scalar p, const scalar T) const
Definition: EtoHthermo.H:17
label n
volScalarField & he
Definition: YEEqn.H:52
const uniformDimensionedVectorField & g
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
scalar Kx(const scalar p, const scalar T) const
Equilibrium constant [] i.t.o. mole-fractions.
Definition: thermoI.H:305
scalar Kc(const scalar p, const scalar T) const
Equilibrium constant i.t.o. molar concentration.
Definition: thermoI.H:288
scalar G(const scalar p, const scalar T) const
Gibbs free energy [J/kg].
Definition: thermoI.H:159
scalar TEs(const scalar E, const scalar p, const scalar T0) const
Temperature from sensible internal energy.
Definition: thermoI.H:398
scalar THE(const scalar H, const scalar p, const scalar T0) const
Temperature from enthalpy or internal energy.
Definition: thermoI.H:346
scalar HE(const scalar p, const scalar T) const
Enthalpy/Internal energy [J/kg].
Definition: thermoI.H:151
scalar s(const scalar p, const scalar T) const
Entropy [J/(kmol K)].
Definition: thermoI.H:207
scalar a(const scalar p, const scalar T) const
Helmholtz free energy [J/kmol].
Definition: thermoI.H:255
scalar TEa(const scalar E, const scalar p, const scalar T0) const
Temperature from absolute internal energy.
Definition: thermoI.H:418
scalar hc() const
Chemical enthalpy [J/kmol].
Definition: thermoI.H:199
void operator+=(const thermo &)
Definition: thermoI.H:470
static word typeName()
Return the instantiated type name.
Definition: thermo.H:142
static word heName()
Name of Enthalpy/Internal energy.
Definition: thermoI.H:109
scalar ea(const scalar p, const scalar T) const
Absolute internal energy [J/kmol].
Definition: thermoI.H:239
scalar cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/(kmol K)].
Definition: thermoI.H:223
scalar CpByCpv(const scalar p, const scalar T) const
Ratio of heat capacity at constant pressure to that at.
Definition: thermoI.H:140
scalar Cpv(const scalar p, const scalar T) const
Heat capacity at constant pressure/volume [J/(kg K)].
Definition: thermoI.H:117
scalar ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kmol].
Definition: thermoI.H:183
thermo< Thermo, Type > thermoType
The thermodynamics of the individual species'.
Definition: thermo.H:124
scalar es(const scalar p, const scalar T) const
Sensible internal energy [J/kmol].
Definition: thermoI.H:231
scalar THa(const scalar H, const scalar p, const scalar T0) const
Temperature from absolute enthalpy.
Definition: thermoI.H:378
scalar dcpdT(const scalar p, const scalar T) const
Derivative of cp w.r.t. temperature.
Definition: thermoI.H:461
scalar Kn(const scalar p, const scalar T, const scalar n) const
Equilibrium constant [] i.t.o. number of moles.
Definition: thermoI.H:325
scalar dKcdTbyKc(const scalar p, const scalar T) const
Derivative of B (acooding to Niemeyer et al.) w.r.t. temperature.
Definition: thermoI.H:439
scalar THs(const scalar Hs, const scalar p, const scalar T0) const
Temperature from sensible enthalpy given an initial T0.
Definition: thermoI.H:358
void operator*=(const scalar)
Definition: thermoI.H:479
scalar hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kmol].
Definition: thermoI.H:191
scalar Kp(const scalar p, const scalar T) const
Equilibrium constant [] i.t.o. partial pressures.
Definition: thermoI.H:280
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const scalar gamma
Definition: EEqn.H:9
volScalarField H(IOobject("H", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), mesh, dimensionedScalar(dimLength, Zero))
OBJstream os(runTime.globalPath()/outputName)
volVectorField F(fluid.F())
Thermodynamic scalar constants.
Namespace for OpenFOAM.
complex limit(const complex &, const complex &)
Definition: complexI.H:263
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
labelList f(nPoints)
dictionary dict
const volScalarField & cp
scalar T0
Definition: createFields.H:22