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 | Copyright (C) 2011-2016 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 cp, h and s
30 
31  Polynomials for h and s derived from cp
32 
33 SourceFiles
34  hPolynomialThermoI.H
35  hPolynomialThermo.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef hPolynomialThermo_H
40 #define hPolynomialThermo_H
41 
42 #include "scalar.H"
43 #include "Polynomial.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of friend functions and operators
51 
52 template<class EquationOfState, int PolySize>
53 class hPolynomialThermo;
54 
55 template<class EquationOfState, int PolySize>
57 (
59  const hPolynomialThermo<EquationOfState, PolySize>&
60 );
61 
62 template<class EquationOfState, int PolySize>
63 inline hPolynomialThermo<EquationOfState, PolySize> operator-
64 (
65  const hPolynomialThermo<EquationOfState, PolySize>&,
66  const hPolynomialThermo<EquationOfState, PolySize>&
67 );
68 
69 template<class EquationOfState, int PolySize>
70 inline hPolynomialThermo<EquationOfState, PolySize> operator*
71 (
72  const scalar,
73  const hPolynomialThermo<EquationOfState, PolySize>&
74 );
75 
76 template<class EquationOfState, int PolySize>
77 inline hPolynomialThermo<EquationOfState, PolySize> operator==
78 (
79  const hPolynomialThermo<EquationOfState, PolySize>&,
80  const hPolynomialThermo<EquationOfState, PolySize>&
81 );
82 
83 template<class EquationOfState, int PolySize>
84 Ostream& operator<<
85 (
86  Ostream&,
87  const hPolynomialThermo<EquationOfState, PolySize>&
88 );
89 
90 
91 /*---------------------------------------------------------------------------*\
92  Class hPolynomialThermo Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 template<class EquationOfState, int PolySize=8>
97 :
98  public EquationOfState
99 {
100  // Private data
101 
102  //- Heat of formation
103  // Note: input in [J/kg], but internally uses [J/kmol]
104  scalar Hf_;
105 
106  //- Standard entropy
107  // Note: input in [J/kg/K], but internally uses [J/kmol/K]
108  scalar Sf_;
109 
110  //- Specific heat at constant pressure polynomial coeffs [J/(kg.K)]
111  Polynomial<PolySize> CpCoeffs_;
112 
113  //- Enthalpy polynomial coeffs - derived from cp [J/kg]
114  // NOTE: relative to Tstd
115  typename Polynomial<PolySize>::intPolyType hCoeffs_;
116 
117  //- Entropy - derived from Cp [J/(kg.K)] - relative to Tstd
118  Polynomial<PolySize> sCoeffs_;
119 
120 
121  // Private Member Functions
122 
123  //- Construct from components
124  inline hPolynomialThermo
125  (
126  const EquationOfState& pt,
127  const scalar Hf,
128  const scalar Sf,
129  const Polynomial<PolySize>& CpCoeffs,
130  const typename Polynomial<PolySize>::intPolyType& hCoeffs,
131  const Polynomial<PolySize>& sCoeffs
132  );
133 
134 
135 public:
136 
137  // Constructors
138 
139  //- Construct from Istream
141 
142  //- Construct from dictionary
144 
145  //- Construct as copy
146  inline hPolynomialThermo(const hPolynomialThermo&);
147 
148  //- Construct as a named copy
149  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
150 
151 
152  // Member Functions
153 
154  //- Return the instantiated type name
155  static word typeName()
156  {
157  return "hPolynomial<" + EquationOfState::typeName() + '>';
158  }
159 
160  //- Limit the temperature to be in the range Tlow_ to Thigh_
161  inline scalar limit(const scalar) const;
162 
163 
164  // Fundamental properties
165 
166  //- Heat capacity at constant pressure [J/(kmol K)]
167  inline scalar cp(const scalar p, const scalar T) const;
168 
169  //- Absolute Enthalpy [J/kmol]
170  inline scalar ha(const scalar p, const scalar T) const;
171 
172  //- Sensible enthalpy [J/kmol]
173  inline scalar hs(const scalar p, const scalar T) const;
174 
175  //- Chemical enthalpy [J/kmol]
176  inline scalar hc() const;
177 
178  //- Entropy [J/(kmol K)]
179  inline scalar s(const scalar p, const scalar T) const;
180 
181 
182  // I-O
183 
184  //- Write to Ostream
185  void write(Ostream& os) const;
186 
187 
188  // Member operators
189 
190  inline void operator=(const hPolynomialThermo&);
191  inline void operator+=(const hPolynomialThermo&);
192  inline void operator-=(const hPolynomialThermo&);
193  inline void operator*=(const scalar);
194 
195 
196  // Friend operators
197 
198  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
199  (
200  const hPolynomialThermo&,
201  const hPolynomialThermo&
202  );
203 
204  friend hPolynomialThermo operator- <EquationOfState, PolySize>
205  (
206  const hPolynomialThermo&,
207  const hPolynomialThermo&
208  );
209 
210  friend hPolynomialThermo operator* <EquationOfState, PolySize>
211  (
212  const scalar,
213  const hPolynomialThermo&
214  );
215 
216  friend hPolynomialThermo operator== <EquationOfState, PolySize>
217  (
218  const hPolynomialThermo&,
219  const hPolynomialThermo&
220  );
221 
222 
223  // Ostream Operator
224 
225  friend Ostream& operator<< <EquationOfState, PolySize>
226  (
227  Ostream&,
228  const hPolynomialThermo&
229  );
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #include "hPolynomialThermoI.H"
240 
241 #ifdef NoRepository
242  #include "hPolynomialThermo.C"
243 #endif
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
dictionary dict
scalar ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kmol].
scalar hc() const
Chemical enthalpy [J/kmol].
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
void operator+=(const hPolynomialThermo &)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void operator=(const hPolynomialThermo &)
scalar s(const scalar p, const scalar T) const
Entropy [J/(kmol K)].
Thermodynamics package templated on the equation of state, using polynomial functions for cp...
void write(Ostream &os) const
Write to Ostream.
A class for handling words, derived from string.
Definition: word.H:59
void operator-=(const hPolynomialThermo &)
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 cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kmol K)].
scalar limit(const scalar) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Polynomial templated on size (order):
Definition: Polynomial.H:63
static word typeName()
Return the instantiated type name.
scalar hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kmol].
volScalarField & p
Namespace for OpenFOAM.