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-2020 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  Thermodynamics package templated on the equation of state, using polynomial
29  functions for \c cp, \c h and \c s.
30 
31  Polynomials for \c h and \c s derived from \c cp.
32 
33 Usage
34 
35  \table
36  Property | Description
37  Hf | Heat of formation
38  Sf | Standard entropy
39  CpCoeffs<8> | Specific heat at constant pressure polynomial coeffs
40  \endtable
41 
42  Example of the specification of the thermodynamic properties:
43  \verbatim
44  thermodynamics
45  {
46  Hf 0;
47  Sf 0;
48  CpCoeffs<8> ( 1000 -0.05 0.003 0 0 0 0 0 );
49  }
50  \endverbatim
51 
52  The polynomial expression is evaluated as so:
53 
54  \f[
55  Cp = 1000 - 0.05 T + 0.003 T^2
56  \f]
57 
58 Note
59  - Specific heat at constant pressure polynomial coefficients evaluate to an
60  expression in [J/kg/K].
61 
62 SourceFiles
63  hPolynomialThermoI.H
64  hPolynomialThermo.C
65 
66 See also
67  Foam::Polynomial
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef hPolynomialThermo_H
72 #define hPolynomialThermo_H
73 
74 #include "scalar.H"
75 #include "Polynomial.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 
82 // Forward declaration of friend functions and operators
83 
84 template<class EquationOfState, int PolySize>
85 class hPolynomialThermo;
86 
87 template<class EquationOfState, int PolySize>
88 inline hPolynomialThermo<EquationOfState, PolySize> operator+
89 (
90  const hPolynomialThermo<EquationOfState, PolySize>&,
91  const hPolynomialThermo<EquationOfState, PolySize>&
92 );
93 
94 template<class EquationOfState, int PolySize>
95 inline hPolynomialThermo<EquationOfState, PolySize> operator*
96 (
97  const scalar,
98  const hPolynomialThermo<EquationOfState, PolySize>&
99 );
100 
101 template<class EquationOfState, int PolySize>
102 inline hPolynomialThermo<EquationOfState, PolySize> operator==
103 (
104  const hPolynomialThermo<EquationOfState, PolySize>&,
105  const hPolynomialThermo<EquationOfState, PolySize>&
106 );
107 
108 template<class EquationOfState, int PolySize>
109 Ostream& operator<<
110 (
111  Ostream&,
112  const hPolynomialThermo<EquationOfState, PolySize>&
113 );
114 
115 
116 /*---------------------------------------------------------------------------*\
117  Class hPolynomialThermo Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 template<class EquationOfState, int PolySize=8>
121 class hPolynomialThermo
122 :
123  public EquationOfState
124 {
125  // Private Data
126 
127  //- Heat of formation
128  scalar Hf_;
129 
130  //- Standard entropy
131  scalar Sf_;
132 
133  //- Specific heat at constant pressure polynomial coeffs [J/kg/K/K^i]
134  Polynomial<PolySize> CpCoeffs_;
135 
136  //- Enthalpy polynomial coeffs [J/kg/K^i]
137  // Derived from Cp coeffs. Relative to Tstd.
138  typename Polynomial<PolySize>::intPolyType hCoeffs_;
139 
140  //- Entropy polynomial coeffs [J/kg/K/K^i]
141  // Derived from Cp coeffs. Relative to Tstd.
142  Polynomial<PolySize> sCoeffs_;
143 
144 
145  // Private Member Functions
146 
147  //- Construct from components
148  inline hPolynomialThermo
149  (
150  const EquationOfState& pt,
151  const scalar Hf,
152  const scalar Sf,
153  const Polynomial<PolySize>& CpCoeffs,
154  const typename Polynomial<PolySize>::intPolyType& hCoeffs,
155  const Polynomial<PolySize>& sCoeffs
156  );
157 
158 
159 public:
160 
161  // Constructors
162 
163  //- Construct from dictionary
165 
166  //- Construct as a named copy
167  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
168 
169 
170  // Member Functions
171 
172  //- Return the instantiated type name
173  static word typeName()
174  {
175  return "hPolynomial<" + EquationOfState::typeName() + '>';
176  }
177 
178  //- Limit the temperature to be in the range Tlow_ to Thigh_
179  inline scalar limit(const scalar) const;
180 
181 
182  // Fundamental properties
183 
184  //- Heat capacity at constant pressure [J/kg/K]
185  inline scalar Cp(const scalar p, const scalar T) const;
186 
187  //- Absolute enthalpy [J/kg]
188  inline scalar Ha(const scalar p, const scalar T) const;
189 
190  //- Sensible enthalpy [J/kg]
191  inline scalar Hs(const scalar p, const scalar T) const;
192 
193  //- Enthalpy of formation [J/kg]
194  inline scalar Hf() const;
195 
196  //- Entropy [J/kg/K]
197  inline scalar S(const scalar p, const scalar T) const;
198 
199  //- Gibbs free energy of the mixture in the standard state [J/kg]
200  inline scalar Gstd(const scalar T) const;
201 
202  #include "HtoEthermo.H"
203 
204 
205  // Derivative term used for Jacobian
206 
207  //- Temperature derivative of heat capacity at constant pressure
208  inline scalar dCpdT(const scalar p, const scalar T) const;
209 
210 
211  // I-O
212 
213  //- Write to Ostream
214  void write(Ostream& os) const;
215 
216 
217  // Member Operators
218 
219  inline void operator+=(const hPolynomialThermo&);
220  inline void operator*=(const scalar);
221 
222 
223  // Friend operators
224 
225  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
226  (
227  const hPolynomialThermo&,
228  const hPolynomialThermo&
229  );
230 
231  friend hPolynomialThermo operator* <EquationOfState, PolySize>
232  (
233  const scalar,
234  const hPolynomialThermo&
235  );
236 
237  friend hPolynomialThermo operator== <EquationOfState, PolySize>
238  (
239  const hPolynomialThermo&,
240  const hPolynomialThermo&
241  );
242 
243 
244  // Ostream Operator
245 
246  friend Ostream& operator<< <EquationOfState, PolySize>
247  (
248  Ostream&,
249  const hPolynomialThermo&
250  );
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "hPolynomialThermoI.H"
261 
262 #ifdef NoRepository
263  #include "hPolynomialThermo.C"
264 #endif
265 
266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 
268 #endif
269 
270 // ************************************************************************* //
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].
Thermodynamics package templated on the equation of state, using polynomial functions for cp...
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].