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 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  //- Enthalpy polynomial coeffs - derived from cp [J/kg]
145  // NOTE: relative to Tstd
146  typename Polynomial<PolySize>::intPolyType hCoeffs_;
147 
148  //- Entropy - derived from Cp [J/(kg.K)] - relative to Tstd
149  Polynomial<PolySize> sCoeffs_;
150 
151 
152  // Private Member Functions
153 
154  //- Coeffs name. Eg, "CpCoeffs<10>"
155  inline static word coeffsName(const char* name)
156  {
157  return word(name + ("Coeffs<" + std::to_string(PolySize) + '>'));
158  }
159 
160  //- Construct from components
161  inline hPolynomialThermo
162  (
163  const EquationOfState& pt,
164  const scalar Hf,
165  const scalar Sf,
166  const Polynomial<PolySize>& CpCoeffs,
167  const typename Polynomial<PolySize>::intPolyType& hCoeffs,
168  const Polynomial<PolySize>& sCoeffs
169  );
170 
171 
172 public:
173 
174  // Generated Methods: copy construct, copy assignment
175 
176 
177  // Constructors
178 
179  //- Construct from dictionary
181 
182  //- Construct as a named copy
183  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
184 
185 
186  // Member Functions
187 
188  //- Return the instantiated type name
189  static word typeName()
190  {
191  return "hPolynomial<" + EquationOfState::typeName() + '>';
192  }
193 
194  //- Limit temperature to be within the range
195  inline scalar limit(const scalar) const;
196 
197 
198  // Fundamental properties
199 
200  //- Heat capacity at constant pressure [J/(kg K)]
201  inline scalar Cp(const scalar p, const scalar T) const;
202 
203  //- Absolute Enthalpy [J/kg]
204  inline scalar Ha(const scalar p, const scalar T) const;
205 
206  //- Sensible enthalpy [J/kg]
207  inline scalar Hs(const scalar p, const scalar T) const;
208 
209  //- Chemical enthalpy [J/kg]
210  inline scalar Hc() const;
211 
212  //- Entropy [J/(kg K)]
213  inline scalar S(const scalar p, const scalar T) const;
214 
215  //- Gibbs free energy of the mixture in the standard state [J/kg]
216  inline scalar Gstd(const scalar T) const;
217 
218 
219  #include "HtoEthermo.H"
220 
221 
222  // Derivative term used for Jacobian
223 
224 
225  //- Temperature derivative of heat capacity at constant pressure
226  inline scalar dCpdT(const scalar p, const scalar T) const;
227 
228 
229 
230  // IO
231 
232  //- Write to Ostream
233  void write(Ostream& os) const;
234 
235 
236  // Member Operators
237 
238  inline void operator+=(const hPolynomialThermo&);
239  inline void operator*=(const scalar);
240 
241 
242  // Friend Operators
243 
244  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
245  (
246  const hPolynomialThermo&,
247  const hPolynomialThermo&
248  );
249 
250  friend hPolynomialThermo operator* <EquationOfState, PolySize>
251  (
252  const scalar,
253  const hPolynomialThermo&
254  );
255 
256  friend hPolynomialThermo operator== <EquationOfState, PolySize>
257  (
258  const hPolynomialThermo&,
259  const hPolynomialThermo&
260  );
261 
262 
263  // IOstream Operators
264 
265  friend Ostream& operator<< <EquationOfState, PolySize>
266  (
267  Ostream&,
268  const hPolynomialThermo&
269  );
270 };
271 
272 
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
274 
275 } // End namespace Foam
276 
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
278 
279 #include "hPolynomialThermoI.H"
280 
281 #ifdef NoRepository
282  #include "hPolynomialThermo.C"
283 #endif
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #endif
288 
289 // ************************************************************************* //
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:62
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:62
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::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
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:121
scalar.H
Foam::hPolynomialThermo::typeName
static word typeName()
Return the instantiated type name.
Definition: hPolynomialThermo.H:200
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::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