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-2018 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  - Heat of formation is inputted in [J/kg], but internally uses [J/kmol]
60  - Standard entropy is inputted in [J/kg/K], but internally uses [J/kmol/K]
61  - Specific heat at constant pressure polynomial coefficients evaluate to an
62  expression in [J/(kg.K)].
63 
64 SourceFiles
65  hPolynomialThermoI.H
66  hPolynomialThermo.C
67 
68 See also
69  Foam::Polynomial
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef hPolynomialThermo_H
74 #define hPolynomialThermo_H
75 
76 #include "scalar.H"
77 #include "Polynomial.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 
84 // Forward declaration of friend functions and operators
85 
86 template<class EquationOfState, int PolySize>
87 class hPolynomialThermo;
88 
89 template<class EquationOfState, int PolySize>
90 inline hPolynomialThermo<EquationOfState, PolySize> operator+
91 (
92  const hPolynomialThermo<EquationOfState, PolySize>&,
93  const hPolynomialThermo<EquationOfState, PolySize>&
94 );
95 
96 template<class EquationOfState, int PolySize>
97 inline hPolynomialThermo<EquationOfState, PolySize> operator*
98 (
99  const scalar,
100  const hPolynomialThermo<EquationOfState, PolySize>&
101 );
102 
103 template<class EquationOfState, int PolySize>
104 inline hPolynomialThermo<EquationOfState, PolySize> operator==
105 (
106  const hPolynomialThermo<EquationOfState, PolySize>&,
107  const hPolynomialThermo<EquationOfState, PolySize>&
108 );
109 
110 template<class EquationOfState, int PolySize>
111 Ostream& operator<<
112 (
113  Ostream&,
114  const hPolynomialThermo<EquationOfState, PolySize>&
115 );
116 
117 
118 /*---------------------------------------------------------------------------*\
119  Class hPolynomialThermo Declaration
120 \*---------------------------------------------------------------------------*/
121 
122 template<class EquationOfState, int PolySize=8>
123 class hPolynomialThermo
124 :
125  public EquationOfState
126 {
127  // Private data
128 
129  //- Heat of formation
130  scalar Hf_;
131 
132  //- Standard entropy
133  scalar Sf_;
134 
135  //- Specific heat at constant pressure polynomial coeffs
136  Polynomial<PolySize> CpCoeffs_;
137 
138  //- Enthalpy polynomial coeffs - derived from cp [J/kg]
139  // NOTE: relative to Tstd
140  typename Polynomial<PolySize>::intPolyType hCoeffs_;
141 
142  //- Entropy - derived from Cp [J/(kg.K)] - relative to Tstd
143  Polynomial<PolySize> sCoeffs_;
144 
145 
146  // Private Member Functions
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 
160 public:
161 
162  // Constructors
163 
164  //- Construct from dictionary
166 
167  //- Construct as a named copy
168  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
169 
170 
171  // Member Functions
172 
173  //- Return the instantiated type name
174  static word typeName()
175  {
176  return "hPolynomial<" + EquationOfState::typeName() + '>';
177  }
178 
179  //- Limit the temperature to be in the range Tlow_ to Thigh_
180  inline scalar limit(const scalar) const;
181 
182 
183  // Fundamental properties
184 
185  //- Heat capacity at constant pressure [J/(kg K)]
186  inline scalar Cp(const scalar p, const scalar T) const;
187 
188  //- Absolute Enthalpy [J/kg]
189  inline scalar Ha(const scalar p, const scalar T) const;
190 
191  //- Sensible enthalpy [J/kg]
192  inline scalar Hs(const scalar p, const scalar T) const;
193 
194  //- Chemical enthalpy [J/kg]
195  inline scalar Hc() const;
196 
197  //- Entropy [J/(kg K)]
198  inline scalar S(const scalar p, const scalar T) const;
199 
200 
201  // Derivative term used for Jacobian
202 
203  //- Derivative of Gibbs free energy w.r.t. temperature
204  inline scalar dGdT(const scalar p, const scalar T) const;
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 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:137
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
void operator+=(const hPolynomialThermo &)
void operator=(const hPolynomialThermo &)
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:53
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
scalar Hc() const
Chemical enthalpy [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_.
scalar dGdT(const scalar p, const scalar T) const
Derivative of Gibbs free energy w.r.t. temperature.
volScalarField & p
Namespace for OpenFOAM.
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kg K)].