hPowerThermo.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) 2012-2023 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  Enthalpy based thermodynamics package using a power function of temperature
26  for the constant heat capacity at constant volume which is particularly
27  suitable for solids at low temperatures:
28 
29  \verbatim
30  Cp = c0*pow(T/Tref, n0)
31  \endverbatim
32 
33 Usage
34  \table
35  Property | Description
36  c0 | Reference heat capacity at constant pressure [J/kg/K]
37  n0 | Exponent of the power function
38  Tref | Reference temperature [K]
39  Hf | Heat of formation [J/kg]
40  \endtable
41 
42  Example specification of hPowerThermo:
43  \verbatim
44  thermodynamics
45  {
46  c0 230;
47  Tref 470;
48  n0 3;
49  Hf 0;
50  }
51  \endverbatim
52 
53 SourceFiles
54  hPowerThermoI.H
55  hPowerThermo.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef hPowerThermo_H
60 #define hPowerThermo_H
61 
62 #include "scalar.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 // Forward declaration of friend functions and operators
70 
71 template<class EquationOfState> class hPowerThermo;
72 
73 template<class EquationOfState>
74 inline hPowerThermo<EquationOfState> operator+
75 (
76  const hPowerThermo<EquationOfState>&,
77  const hPowerThermo<EquationOfState>&
78 );
79 
80 template<class EquationOfState>
81 inline hPowerThermo<EquationOfState> operator*
82 (
83  const scalar,
84  const hPowerThermo<EquationOfState>&
85 );
86 
87 
88 template<class EquationOfState>
89 inline hPowerThermo<EquationOfState> operator==
90 (
93 );
94 
95 
96 template<class EquationOfState>
97 Ostream& operator<<
98 (
99  Ostream&,
101 );
102 
103 
104 /*---------------------------------------------------------------------------*\
105  Class hPowerThermo Declaration
106 \*---------------------------------------------------------------------------*/
107 
108 template<class EquationOfState>
109 class hPowerThermo
110 :
111  public EquationOfState
112 {
113  // Private Data
114 
115  scalar c0_;
116  scalar n0_;
117  scalar Tref_;
118  scalar Hf_;
119 
120 
121  // Private Member Functions
122 
123  //- Check given temperature is within the range of the fitted coeffs
124  inline void checkT(const scalar T) const;
125 
126 
127 public:
128 
129  // Constructors
130 
131  //- Construct from components
132  inline hPowerThermo
133  (
134  const EquationOfState& st,
135  const scalar c0,
136  const scalar n0,
137  const scalar Tref,
138  const scalar Hf
139  );
140 
141  //- Construct from name and dictionary
142  hPowerThermo(const word& name, const dictionary& dict);
143 
144  //- Construct as a named copy
145  inline hPowerThermo
146  (
147  const word&,
148  const hPowerThermo&
149  );
150 
151  //- Construct and return a clone
152  inline autoPtr<hPowerThermo> clone() const;
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/kg]
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  //- Enthalpy of formation [J/kg]
179  inline scalar Hf() const;
180 
181  //- Entropy [J/kg/K]
182  inline scalar S(const scalar p, const scalar T) const;
183 
184  //- Gibbs free energy of the mixture in the standard state [J/kg]
185  inline scalar Gstd(const scalar T) const;
186 
187  #include "HtoEthermo.H"
188 
189 
190  // Derivative term used for Jacobian
191 
192  //- Temperature derivative of heat capacity at constant pressure
193  inline scalar dCpdT(const scalar p, const scalar T) const;
194 
195 
196  // Member Operators
197 
198  inline void operator+=(const hPowerThermo&);
199 
200 
201  // Friend operators
202 
203  friend hPowerThermo operator+ <EquationOfState>
204  (
205  const hPowerThermo&,
206  const hPowerThermo&
207  );
208 
209  friend hPowerThermo operator* <EquationOfState>
210  (
211  const scalar,
212  const hPowerThermo&
213  );
214 
215 
216  friend hPowerThermo operator== <EquationOfState>
217  (
218  const hPowerThermo&,
219  const hPowerThermo&
220  );
221 
222 
223  // Ostream Operator
224 
225  friend Ostream& operator<< <EquationOfState>
226  (
227  Ostream&,
228  const hPowerThermo&
229  );
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #ifdef NoRepository
240  #include "hPowerThermoI.H"
241  #include "hPowerThermo.C"
242 #endif
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 #endif
247 
248 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
scalar Hf() const
Enthalpy of formation [J/kg].
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: hPowerThermoI.H:97
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
autoPtr< hPowerThermo > clone() const
Construct and return a clone.
Definition: hPowerThermoI.H:84
hPowerThermo(const EquationOfState &st, const scalar c0, const scalar n0, const scalar Tref, const scalar Hf)
Construct from components.
Definition: hPowerThermoI.H:51
static word typeName()
Return the instantiated type name.
Definition: hPowerThermo.H:172
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].
void operator+=(const hPowerThermo &)
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
scalar Ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p