hPolynomialThermo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::hPolynomialThermo
26 
27 Description
28  Enthalpy based thermodynamics package using a polynomial function
29  of temperature for the constant heat capacity at constant pressure:
30 
31  \verbatim
32  Cp = a0 + a1*T + a2*sqr(T) + a3*pow3(T) + a4*pow4(T)
33  + a5*pow(T, 5) + a6*pow(T, 6) + a7*pow(T, 7)
34  \endverbatim
35 
36  The polynomial function is templated on the order of the polynomial which
37  defaults to 8.
38 
39 Usage
40  \table
41  Property | Description
42  Hf | Heat of formation
43  Sf | Standard entropy
44  CpCoeffs<8> | Specific heat at constant pressure polynomial coeffs
45  \endtable
46 
47  Example of the specification of the thermodynamic properties:
48  \verbatim
49  thermodynamics
50  {
51  Hf 0;
52  Sf 0;
53  CpCoeffs<8> (1000 -0.05 0.003 0 0 0 0 0);
54  }
55  \endverbatim
56 
57  Note:
58  Specific heat at constant pressure polynomial coefficients evaluate to
59  an expression in [J/kg/K].
60 
61 SourceFiles
62  hPolynomialThermoI.H
63  hPolynomialThermo.C
64 
65 See also
66  Foam::Polynomial
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef hPolynomialThermo_H
71 #define hPolynomialThermo_H
72 
73 #include "scalar.H"
74 #include "Polynomial.H"
75 
76 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
77 
78 namespace Foam
79 {
80 
81 // Forward declaration of friend functions and operators
82 
83 template<class EquationOfState, int PolySize>
84 class hPolynomialThermo;
85 
86 template<class EquationOfState, int PolySize>
87 inline hPolynomialThermo<EquationOfState, PolySize> operator+
88 (
89  const hPolynomialThermo<EquationOfState, PolySize>&,
90  const hPolynomialThermo<EquationOfState, PolySize>&
91 );
92 
93 template<class EquationOfState, int PolySize>
94 inline hPolynomialThermo<EquationOfState, PolySize> operator*
95 (
96  const scalar,
97  const hPolynomialThermo<EquationOfState, PolySize>&
98 );
99 
100 template<class EquationOfState, int PolySize>
101 inline hPolynomialThermo<EquationOfState, PolySize> operator==
102 (
103  const hPolynomialThermo<EquationOfState, PolySize>&,
104  const hPolynomialThermo<EquationOfState, PolySize>&
105 );
106 
107 template<class EquationOfState, int PolySize>
108 Ostream& operator<<
109 (
110  Ostream&,
111  const hPolynomialThermo<EquationOfState, PolySize>&
112 );
113 
114 
115 /*---------------------------------------------------------------------------*\
116  Class hPolynomialThermo Declaration
117 \*---------------------------------------------------------------------------*/
118 
119 template<class EquationOfState, int PolySize=8>
120 class hPolynomialThermo
121 :
122  public EquationOfState
123 {
124  // Private Data
125 
126  //- Heat of formation
127  scalar Hf_;
128 
129  //- Standard entropy
130  scalar Sf_;
131 
132  //- Specific heat at constant pressure polynomial coeffs [J/kg/K/K^i]
133  Polynomial<PolySize> CpCoeffs_;
134 
135  //- Enthalpy polynomial coeffs [J/kg/K^i]
136  // Derived from Cp coeffs. Relative to Tstd.
137  typename Polynomial<PolySize>::intPolyType hCoeffs_;
138 
139  //- Entropy polynomial coeffs [J/kg/K/K^i]
140  // Derived from Cp coeffs. Relative to Tstd.
141  Polynomial<PolySize> sCoeffs_;
142 
143 
144  // Private Member Functions
145 
146  //- Construct from components
147  inline hPolynomialThermo
148  (
149  const EquationOfState& pt,
150  const scalar Hf,
151  const scalar Sf,
152  const Polynomial<PolySize>& CpCoeffs,
153  const typename Polynomial<PolySize>::intPolyType& hCoeffs,
154  const Polynomial<PolySize>& sCoeffs
155  );
156 
157 
158 public:
159 
160  // Constructors
161 
162  //- Construct from dictionary
164 
165  //- Construct as a named copy
166  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
167 
168 
169  // Member Functions
170 
171  //- Return the instantiated type name
172  static word typeName()
173  {
174  return "hPolynomial<" + EquationOfState::typeName() + '>';
175  }
176 
177  //- Limit the temperature to be in the range Tlow_ to Thigh_
178  inline scalar limit(const scalar) const;
179 
180 
181  // Fundamental properties
182 
183  //- Heat capacity at constant pressure [J/kg/K]
184  inline scalar Cp(const scalar p, const scalar T) const;
185 
186  //- Absolute enthalpy [J/kg]
187  inline scalar Ha(const scalar p, const scalar T) const;
188 
189  //- Sensible enthalpy [J/kg]
190  inline scalar Hs(const scalar p, const scalar T) const;
191 
192  //- Enthalpy of formation [J/kg]
193  inline scalar Hf() const;
194 
195  //- Entropy [J/kg/K]
196  inline scalar S(const scalar p, const scalar T) const;
197 
198  //- Gibbs free energy of the mixture in the standard state [J/kg]
199  inline scalar Gstd(const scalar T) const;
200 
201  #include "HtoEthermo.H"
202 
203 
204  // Derivative term used for Jacobian
205 
206  //- Temperature derivative of heat capacity at constant pressure
207  inline scalar dCpdT(const scalar p, const scalar T) const;
208 
209 
210  // I-O
211 
212  //- Write to Ostream
213  void write(Ostream& os) const;
214 
215 
216  // Member Operators
217 
218  inline void operator+=(const hPolynomialThermo&);
219  inline void operator*=(const scalar);
220 
221 
222  // Friend operators
223 
224  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
225  (
226  const hPolynomialThermo&,
227  const hPolynomialThermo&
228  );
229 
230  friend hPolynomialThermo operator* <EquationOfState, PolySize>
231  (
232  const scalar,
233  const hPolynomialThermo&
234  );
235 
236  friend hPolynomialThermo operator== <EquationOfState, PolySize>
237  (
238  const hPolynomialThermo&,
239  const hPolynomialThermo&
240  );
241 
242 
243  // Ostream Operator
244 
245  friend Ostream& operator<< <EquationOfState, PolySize>
246  (
247  Ostream&,
248  const hPolynomialThermo&
249  );
250 };
251 
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 } // End namespace Foam
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 #include "hPolynomialThermoI.H"
260 
261 #ifdef NoRepository
262  #include "hPolynomialThermo.C"
263 #endif
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #endif
268 
269 // ************************************************************************* //
dictionary dict
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
void write(Ostream &os) const
Write to Ostream.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
void operator+=(const hPolynomialThermo &)
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
Enthalpy based thermodynamics package using a polynomial function of temperature for the constant hea...
scalar Ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
A class for handling words, derived from string.
Definition: word.H:59
void operator*=(const scalar)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
scalar Hf() const
Enthalpy of formation [J/kg].
Polynomial templated on size (order):
Definition: Polynomial.H:65
static word typeName()
Return the instantiated type name.
scalar limit(const scalar) const
Limit the temperature to be in the range Tlow_ to Thigh_.
volScalarField & p
Namespace for OpenFOAM.
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].