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