hPowerThermo.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) 2012-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::hPowerThermo
26 
27 Description
28  Power-function based thermodynamics package templated on EquationOfState.
29 
30  In this thermodynamics package the heat capacity is a simple power of
31  temperature:
32 
33  Cp(T) = c0*(T/Tref)^n0;
34 
35  which is particularly suitable for solids.
36 
37 SourceFiles
38  hPowerThermoI.H
39  hPowerThermo.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef hPowerThermo_H
44 #define hPowerThermo_H
45 
46 #include "scalar.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of friend functions and operators
54 
55 template<class EquationOfState> class hPowerThermo;
56 
57 template<class EquationOfState>
58 inline hPowerThermo<EquationOfState> operator+
59 (
61  const hPowerThermo<EquationOfState>&
62 );
63 
64 template<class EquationOfState>
65 inline hPowerThermo<EquationOfState> operator-
66 (
67  const hPowerThermo<EquationOfState>&,
68  const hPowerThermo<EquationOfState>&
69 );
70 
71 template<class EquationOfState>
72 inline hPowerThermo<EquationOfState> operator*
73 (
74  const scalar,
75  const hPowerThermo<EquationOfState>&
76 );
77 
78 
79 template<class EquationOfState>
80 inline hPowerThermo<EquationOfState> operator==
81 (
82  const hPowerThermo<EquationOfState>&,
83  const hPowerThermo<EquationOfState>&
84 );
85 
86 
87 template<class EquationOfState>
88 Ostream& operator<<
89 (
90  Ostream&,
91  const hPowerThermo<EquationOfState>&
92 );
93 
94 
95 /*---------------------------------------------------------------------------*\
96  Class hPowerThermo Declaration
97 \*---------------------------------------------------------------------------*/
98 
99 template<class EquationOfState>
100 class hPowerThermo
101 :
102  public EquationOfState
103 {
104  // Private data
105 
106  scalar c0_;
107  scalar n0_;
108  scalar Tref_;
109  scalar Hf_;
110 
111 
112  // Private Member Functions
113 
114  //- Check given temperature is within the range of the fitted coeffs
115  inline void checkT(const scalar T) const;
116 
117  //- Construct from components
118  inline hPowerThermo
119  (
120  const EquationOfState& st,
121  const scalar c0,
122  const scalar n0,
123  const scalar Tref,
124  const scalar Hf
125  );
126 
127 
128 public:
129 
130  // Constructors
131 
132  //- Construct from Istream
134 
135  //- Construct from dictionary
136  hPowerThermo(const dictionary&);
137 
138  //- Construct as a named copy
139  inline hPowerThermo
140  (
141  const word&,
142  const hPowerThermo&
143  );
144 
145  //- Construct and return a clone
146  inline autoPtr<hPowerThermo> clone() const;
147 
148  //- Selector from Istream
149  inline static autoPtr<hPowerThermo> New(Istream& is);
150 
151  //- Selector from dictionary
152  inline static autoPtr<hPowerThermo> New(const dictionary& dict);
153 
154 
155  // Member Functions
156 
157  //- Return the instantiated type name
158  static word typeName()
159  {
160  return "hPower<" + EquationOfState::typeName() + '>';
161  }
162 
163  //- Limit the temperature to be in the range Tlow_ to Thigh_
164  inline scalar limit(const scalar T) const;
165 
166 
167  // Fundamental properties
168 
169  //- Heat capacity at constant pressure [J/(kg K)]
170  inline scalar cp(const scalar p, const scalar T) const;
171 
172  //- Absolute enthalpy [J/kmol]
173  inline scalar ha(const scalar p, const scalar T) const;
174 
175  //- Sensible enthalpy [J/kg]
176  inline scalar hs(const scalar p, const scalar T) const;
177 
178  //- Chemical enthalpy [J/kg]
179  inline scalar hc() const;
180 
181  //- Entropy [J/(kmol K)]
182  inline scalar s(const scalar p, const scalar T) const;
183 
184 
185  // Member operators
186 
187  inline void operator+=(const hPowerThermo&);
188  inline void operator-=(const hPowerThermo&);
189 
190 
191  // Friend operators
192 
193  friend hPowerThermo operator+ <EquationOfState>
194  (
195  const hPowerThermo&,
196  const hPowerThermo&
197  );
198 
199  friend hPowerThermo operator- <EquationOfState>
200  (
201  const hPowerThermo&,
202  const hPowerThermo&
203  );
204 
205  friend hPowerThermo operator* <EquationOfState>
206  (
207  const scalar,
208  const hPowerThermo&
209  );
210 
211 
212  friend hPowerThermo operator== <EquationOfState>
213  (
214  const hPowerThermo&,
215  const hPowerThermo&
216  );
217 
218 
219  // Ostream Operator
220 
221  friend Ostream& operator<< <EquationOfState>
222  (
223  Ostream&,
224  const hPowerThermo&
225  );
226 };
227 
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 } // End namespace Foam
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 #ifdef NoRepository
236  #include "hPowerThermoI.H"
237  #include "hPowerThermo.C"
238 #endif
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
dictionary dict
autoPtr< hPowerThermo > clone() const
Construct and return a clone.
Definition: hPowerThermoI.H:84
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
static word typeName()
Return the instantiated type name.
Definition: hPowerThermo.H:157
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void operator+=(const hPowerThermo &)
scalar s(const scalar p, const scalar T) const
Entropy [J/(kmol K)].
A class for handling words, derived from string.
Definition: word.H:59
static autoPtr< hPowerThermo > New(Istream &is)
Selector from Istream.
Definition: hPowerThermoI.H:95
scalar cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kg K)].
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)
void operator-=(const hPowerThermo &)
scalar hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
scalar ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kmol].
Power-function based thermodynamics package templated on EquationOfState.
Definition: hPowerThermo.H:54
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:53
volScalarField & p
Namespace for OpenFOAM.
scalar hc() const
Chemical enthalpy [J/kg].