hPolynomialThermo.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-2021 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::hPolynomialThermo
29
30Group
31 grpSpecieThermo
32
33Description
34 Thermodynamics package templated on the equation of state, using polynomial
35 functions for \c cp, \c h and \c s.
36
37 Polynomials for \c h and \c s derived from \c cp.
38
39Usage
40
41 \table
42 Property | Description
43 Hf | Heat of formation
44 Sf | Standard entropy
45 CpCoeffs<8> | Specific heat at constant pressure polynomial coeffs
46 \endtable
47
48 Example of the specification of the thermodynamic properties:
49 \verbatim
50 thermodynamics
51 {
52 Hf 0;
53 Sf 0;
54 CpCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
55 }
56 \endverbatim
57
58 The polynomial expression is evaluated as so:
59
60 \f[
61 Cp = 1000 - 0.05 T + 0.003 T^2
62 \f]
63
64Note
65 - Heat of formation is inputted in [J/kg], but internally uses [J/kmol]
66 - Standard entropy is inputted in [J/kg/K], but internally uses [J/kmol/K]
67 - Specific heat at constant pressure polynomial coefficients evaluate to an
68 expression in [J/(kg.K)].
69
70SourceFiles
71 hPolynomialThermoI.H
72 hPolynomialThermo.C
73
74See also
75 Foam::Polynomial
76
77\*---------------------------------------------------------------------------*/
78
79#ifndef hPolynomialThermo_H
80#define hPolynomialThermo_H
81
82#include "scalar.H"
83#include "Polynomial.H"
84
85// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86
87namespace Foam
88{
89
90// Forward Declarations
91
92template<class EquationOfState, int PolySize>
93class hPolynomialThermo;
94
95template<class EquationOfState, int PolySize>
96inline hPolynomialThermo<EquationOfState, PolySize> operator+
97(
98 const hPolynomialThermo<EquationOfState, PolySize>&,
99 const hPolynomialThermo<EquationOfState, PolySize>&
100);
101
102template<class EquationOfState, int PolySize>
103inline hPolynomialThermo<EquationOfState, PolySize> operator*
104(
105 const scalar,
106 const hPolynomialThermo<EquationOfState, PolySize>&
108
109template<class EquationOfState, int PolySize>
111(
115
116template<class EquationOfState, int PolySize>
117Ostream& operator<<
118(
119 Ostream&,
122
123
124/*---------------------------------------------------------------------------*\
125 Class hPolynomialThermo Declaration
126\*---------------------------------------------------------------------------*/
127
128template<class EquationOfState, int PolySize=8>
130:
131 public EquationOfState
132{
133 // Private Data
134
135 //- Heat of formation
136 scalar Hf_;
137
138 //- Standard entropy
139 scalar Sf_;
141 //- Specific heat at constant pressure polynomial coeffs
142 Polynomial<PolySize> CpCoeffs_;
143
144 //- Reference temperature
145 scalar Tref_;
146
147 //- Reference enthalphy
148 scalar Href_;
149
150 //- Reference entropy
151 scalar Sref_;
152
153 //- Reference pressure
154 scalar Pref_;
155
156 //- Enthalpy polynomial coeffs - derived from cp [J/kg]
157 // NOTE: relative to Tstd
158 typename Polynomial<PolySize>::intPolyType hCoeffs_;
159
160 //- Entropy - derived from Cp [J/(kg.K)] - relative to Tstd
161 Polynomial<PolySize> sCoeffs_;
162
163
164 // Private Member Functions
165
166 //- Coeffs name. Eg, "CpCoeffs<10>"
167 inline static word coeffsName(const char* name)
168 {
169 return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
170 }
171
172 //- Construct from components
173 inline hPolynomialThermo
174 (
175 const EquationOfState& pt,
176 const scalar Hf,
177 const scalar Sf,
178 const Polynomial<PolySize>& CpCoeffs,
179 const typename Polynomial<PolySize>::intPolyType& hCoeffs,
180 const Polynomial<PolySize>& sCoeffs
181 );
182
183
184public:
185
186 // Generated Methods: copy construct, copy assignment
187
188
189 // Constructors
190
191 //- Construct from dictionary
193
194 //- Construct as a named copy
195 inline hPolynomialThermo(const word&, const hPolynomialThermo&);
196
197
198 // Member Functions
199
200 //- Return the instantiated type name
201 static word typeName()
202 {
203 return "hPolynomial<" + EquationOfState::typeName() + '>';
204 }
205
206 //- Limit temperature to be within the range
207 inline scalar limit(const scalar) const;
208
209
210 // Fundamental properties
211
212 //- Heat capacity at constant pressure [J/(kg K)]
213 inline scalar Cp(const scalar p, const scalar T) const;
214
215 //- Absolute Enthalpy [J/kg]
216 inline scalar Ha(const scalar p, const scalar T) const;
217
218 //- Sensible enthalpy [J/kg]
219 inline scalar Hs(const scalar p, const scalar T) const;
220
221 //- Chemical enthalpy [J/kg]
222 inline scalar Hc() const;
223
224 //- Entropy [J/(kg K)]
225 inline scalar S(const scalar p, const scalar T) const;
226
227 //- Gibbs free energy of the mixture in the standard state [J/kg]
228 inline scalar Gstd(const scalar T) const;
229
230
231 #include "HtoEthermo.H"
232
233
234 // Derivative term used for Jacobian
235
236
237 //- Temperature derivative of heat capacity at constant pressure
238 inline scalar dCpdT(const scalar p, const scalar T) const;
239
240
241
242 // IO
243
244 //- Write to Ostream
245 void write(Ostream& os) const;
246
247
248 // Member Operators
249
250 inline void operator+=(const hPolynomialThermo&);
251 inline void operator*=(const scalar);
252
253
254 // Friend Operators
255
256 friend hPolynomialThermo operator+ <EquationOfState, PolySize>
257 (
258 const hPolynomialThermo&,
259 const hPolynomialThermo&
260 );
261
262 friend hPolynomialThermo operator* <EquationOfState, PolySize>
263 (
264 const scalar,
265 const hPolynomialThermo&
266 );
268 friend hPolynomialThermo operator== <EquationOfState, PolySize>
269 (
270 const hPolynomialThermo&,
271 const hPolynomialThermo&
272 );
274
275 // IOstream Operators
276
277 friend Ostream& operator<< <EquationOfState, PolySize>
278 (
280 const hPolynomialThermo&
281 );
282};
283
284
285// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286
287} // End namespace Foam
289// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290
291#include "hPolynomialThermoI.H"
292
293#ifdef NoRepository
294 #include "hPolynomialThermo.C"
295#endif
296
297// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298
299#endif
300
301// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Polynomial templated on size (order):
Definition: Polynomial.H:78
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Thermodynamics package templated on the equation of state, using polynomial functions for cp,...
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
static word typeName()
Return the instantiated type name.
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
scalar Hc() const
Chemical enthalpy [J/kg].
scalar S(const scalar p, const scalar T) const
Entropy [J/(kg K)].
scalar Ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kg].
void operator+=(const hPolynomialThermo &)
scalar limit(const scalar) const
Limit temperature to be within the range.
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
void operator*=(const scalar)
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const volScalarField & T
const volScalarField & Cp
Definition: EEqn.H:7
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
runTime write()
dictionary dict