All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2023 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>
102 (
105 );
106 
107 template<class EquationOfState, int PolySize>
108 Ostream& operator<<
109 (
110  Ostream&,
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 public:
145 
146  // Constructors
147 
148  //- Construct from components
149  inline hPolynomialThermo
150  (
151  const EquationOfState& pt,
152  const scalar hf,
153  const scalar sf,
154  const Polynomial<PolySize>& CpCoeffs,
155  const typename Polynomial<PolySize>::intPolyType& hCoeffs,
156  const Polynomial<PolySize>& sCoeffs
157  );
158 
159  //- Construct from name and dictionary
160  hPolynomialThermo(const word& name, const dictionary& dict);
161 
162  //- Construct as a named copy
163  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
164 
165 
166  // Member Functions
167 
168  //- Return the instantiated type name
169  static word typeName()
170  {
171  return "hPolynomial<" + EquationOfState::typeName() + '>';
172  }
173 
174  //- Limit the temperature to be in the range Tlow_ to Thigh_
175  inline scalar limit(const scalar) const;
176 
177 
178  // Fundamental properties
179 
180  //- Heat capacity at constant pressure [J/kg/K]
181  inline scalar Cp(const scalar p, const scalar T) const;
182 
183  //- Absolute enthalpy [J/kg]
184  inline scalar ha(const scalar p, const scalar T) const;
185 
186  //- Sensible enthalpy [J/kg]
187  inline scalar hs(const scalar p, const scalar T) const;
188 
189  //- Enthalpy of formation [J/kg]
190  inline scalar hf() const;
191 
192  //- Entropy [J/kg/K]
193  inline scalar s(const scalar p, const scalar T) const;
194 
195  //- Gibbs free energy of the mixture in the standard state [J/kg]
196  inline scalar gStd(const scalar T) const;
197 
198  #include "HtoEthermo.H"
199 
200 
201  // Derivative term used for Jacobian
202 
203  //- Temperature derivative of heat capacity at constant pressure
204  inline scalar dCpdT(const scalar p, const scalar T) const;
205 
206 
207  // I-O
208 
209  //- Write to Ostream
210  void write(Ostream& os) const;
211 
212 
213  // Member Operators
214 
215  inline void operator+=(const hPolynomialThermo&);
216  inline void operator*=(const scalar);
217 
218 
219  // Friend operators
220 
221  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
222  (
223  const hPolynomialThermo&,
224  const hPolynomialThermo&
225  );
226 
227  friend hPolynomialThermo operator* <EquationOfState, PolySize>
228  (
229  const scalar,
230  const hPolynomialThermo&
231  );
232 
233  friend hPolynomialThermo operator== <EquationOfState, PolySize>
234  (
235  const hPolynomialThermo&,
236  const hPolynomialThermo&
237  );
238 
239 
240  // Ostream Operator
241 
242  friend Ostream& operator<< <EquationOfState, PolySize>
243  (
245  const hPolynomialThermo&
246  );
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #include "hPolynomialThermoI.H"
257 
258 #ifdef NoRepository
259  #include "hPolynomialThermo.C"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Polynomial templated on size (order):
Definition: Polynomial.H:84
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Enthalpy based thermodynamics package using a polynomial function of temperature for the constant hea...
scalar gStd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
hPolynomialThermo(const EquationOfState &pt, const scalar hf, const scalar sf, const Polynomial< PolySize > &CpCoeffs, const typename Polynomial< PolySize >::intPolyType &hCoeffs, const Polynomial< PolySize > &sCoeffs)
Construct from components.
scalar s(const scalar p, const scalar T) const
Entropy [J/kg/K].
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 Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].
void write(Ostream &os) const
Write to Ostream.
void operator+=(const hPolynomialThermo &)
scalar ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
scalar hf() const
Enthalpy of formation [J/kg].
scalar limit(const scalar) const
Limit the temperature to be in the range Tlow_ to Thigh_.
void operator*=(const scalar)
scalar hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
A class for handling words, derived from string.
Definition: word.H:62
volScalarField sf(fieldObject, mesh)
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p