FreeFOAM The Cross-Platform CFD Toolkit
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) 2008-2010 OpenCFD Ltd.
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 <OpenFOAM/scalar.H>
43 #include <OpenFOAM/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>
56 inline hPolynomialThermo<EquationOfState, PolySize> operator+
57 (
58  const hPolynomialThermo<EquationOfState, PolySize>&,
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>
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 [J/(kg.K)]
111  Polynomial<PolySize> CpPolynomial_;
112 
113  //- Enthalpy - derived from cp [J/kg] - relative to Tstd
114  typename Polynomial<PolySize>::intPolyType hPolynomial_;
115 
116  //- Entropy - derived from cp [J/(kg.K)] - relative to Tstd
117  Polynomial<PolySize> sPolynomial_;
118 
119 
120  // Private member functions
121 
122  //- Construct from components
123  inline hPolynomialThermo
124  (
125  const EquationOfState& pt,
126  const scalar Hf,
127  const scalar Sf,
128  const Polynomial<PolySize>& cpPoly,
129  const typename Polynomial<PolySize>::intPolyType& hPoly,
130  const Polynomial<PolySize>& sPoly
131  );
132 
133 
134 public:
135 
136  // Constructors
137 
138  //- Construct from dictionary
140 
141  //- Construct as copy
142  inline hPolynomialThermo(const hPolynomialThermo&);
143 
144  //- Construct as a named copy
145  inline hPolynomialThermo(const word&, const hPolynomialThermo&);
146 
147 
148  // Member Functions
149 
150  //- Heat capacity at constant pressure [J/(kmol K)]
151  inline scalar cp(const scalar T) const;
152 
153  //- Enthalpy [J/kmol]
154  inline scalar h(const scalar T) const;
155 
156  //- Sensible enthalpy [J/kmol]
157  inline scalar hs(const scalar T) const;
158 
159  //- Chemical enthalpy [J/kmol]
160  inline scalar hc() const;
161 
162  //- Entropy [J/(kmol K)]
163  inline scalar s(const scalar T) const;
164 
165 
166  // Member operators
167 
169  inline void operator+=(const hPolynomialThermo&);
170  inline void operator-=(const hPolynomialThermo&);
171  inline void operator*=(const scalar);
172 
173 
174  // Friend operators
175 
176  friend hPolynomialThermo operator+ <EquationOfState, PolySize>
177  (
178  const hPolynomialThermo&,
179  const hPolynomialThermo&
180  );
181 
182  friend hPolynomialThermo operator- <EquationOfState, PolySize>
183  (
184  const hPolynomialThermo&,
185  const hPolynomialThermo&
186  );
187 
188  friend hPolynomialThermo operator* <EquationOfState, PolySize>
189  (
190  const scalar,
191  const hPolynomialThermo&
192  );
193 
194  friend hPolynomialThermo operator== <EquationOfState, PolySize>
195  (
196  const hPolynomialThermo&,
197  const hPolynomialThermo&
198  );
199 
200 
201  // Ostream Operator
202 
203  friend Ostream& operator<< <EquationOfState, PolySize>
204  (
205  Ostream&,
206  const hPolynomialThermo&
207  );
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
217 #include "hPolynomialThermoI.H"
218 
219 #ifdef NoRepository
220 # include "hPolynomialThermo.C"
221 #endif
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #endif
226 
227 // ************************ vim: set sw=4 sts=4 et: ************************ //