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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::hPolynomialThermo
29 
30 Group
31  grpSpecieThermo
32 
33 Description
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 
39 Usage
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 
64 Note
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 
70 SourceFiles
71  hPolynomialThermoI.H
72  hPolynomialThermo.C
73 
74 See 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 
87 namespace Foam
88 {
89 
90 // Forward Declarations
91 
92 template<class EquationOfState, int PolySize>
93 class hPolynomialThermo;
94 
95 template<class EquationOfState, int PolySize>
96 inline hPolynomialThermo<EquationOfState, PolySize> operator+
97 (
98  const hPolynomialThermo<EquationOfState, PolySize>&,
99  const hPolynomialThermo<EquationOfState, PolySize>&
100 );
101 
102 template<class EquationOfState, int PolySize>
103 inline hPolynomialThermo<EquationOfState, PolySize> operator*
104 (
105  const scalar,
107 );
108 
109 template<class EquationOfState, int PolySize>
111 (
114 );
115 
116 template<class EquationOfState, int PolySize>
117 Ostream& operator<<
118 (
119  Ostream&,
121 );
122 
123 
124 /*---------------------------------------------------------------------------*\
125  Class hPolynomialThermo Declaration
126 \*---------------------------------------------------------------------------*/
127 
128 template<class EquationOfState, int PolySize=8>
129 class hPolynomialThermo
130 :
131  public EquationOfState
132 {
133  // Private Data
134 
135  //- Heat of formation
136  scalar Hf_;
137 
138  //- Standard entropy
139  scalar Sf_;
140 
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 
184 public:
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  );
267 
268  friend hPolynomialThermo operator== <EquationOfState, PolySize>
269  (
270  const hPolynomialThermo&,
271  const hPolynomialThermo&
272  );
273 
274 
275  // IOstream Operators
276 
277  friend Ostream& operator<< <EquationOfState, PolySize>
278  (
279  Ostream&,
280  const hPolynomialThermo&
281  );
282 };
283 
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #include "hPolynomialThermoI.H"
292 
293 #ifdef NoRepository
294  #include "hPolynomialThermo.C"
295 #endif
296 
297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
298 
299 #endif
300 
301 // ************************************************************************* //
HtoEthermo.H
hPolynomialThermoI.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::hPolynomialThermo::limit
scalar limit(const scalar) const
Limit temperature to be within the range.
Definition: hPolynomialThermoI.H:75
Foam::hPolynomialThermo::Gstd
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
Definition: hPolynomialThermoI.H:134
Foam::hPolynomialThermo::write
void write(Ostream &os) const
Write to Ostream.
Definition: hPolynomialThermo.C:67
Foam::hPolynomialThermo::Hs
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
Definition: hPolynomialThermoI.H:105
Foam::hPolynomialThermo::dCpdT
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: hPolynomialThermoI.H:144
Foam::hPolynomialThermo::S
scalar S(const scalar p, const scalar T) const
Entropy [J/(kg K)].
Definition: hPolynomialThermoI.H:123
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::hPolynomialThermo::Ha
scalar Ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kg].
Definition: hPolynomialThermoI.H:95
Polynomial.H
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:123
scalar.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam::hPolynomialThermo::typeName
static word typeName()
Return the instantiated type name.
Definition: hPolynomialThermo.H:212
Foam::hPolynomialThermo::operator*=
void operator*=(const scalar)
Definition: hPolynomialThermoI.H:183
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::hPolynomialThermo
Thermodynamics package templated on the equation of state, using polynomial functions for cp,...
Definition: hPolynomialThermo.H:104
Foam::Polynomial
Polynomial templated on size (order):
Definition: Polynomial.H:68
Foam::hPolynomialThermo::operator+=
void operator+=(const hPolynomialThermo &)
Definition: hPolynomialThermoI.H:159
Foam::hPolynomialThermo::Cp
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kg K)].
Definition: hPolynomialThermoI.H:85
hPolynomialThermo.C
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::hPolynomialThermo::Hc
scalar Hc() const
Chemical enthalpy [J/kg].
Definition: hPolynomialThermoI.H:114