ePowerThermo.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) 2021-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  Foam::ePowerThermo
26 
27 Description
28  Internal energy based thermodynamics package using a power function of
29  temperature for the constant heat capacity at constant volume which is
30  particularly suitable for solids at low temperatures:
31 
32  \verbatim
33  Cv = c0*pow(T/Tref, n0)
34  \endverbatim
35 
36 Usage
37  \table
38  Property | Description
39  c0 | Reference heat capacity at constant volume [J/kg/K]
40  n0 | Exponent of the power function
41  Tref | Reference temperature [K]
42  hf | Heat of formation [J/kg]
43  \endtable
44 
45  Example specification of ePowerThermo:
46  \verbatim
47  thermodynamics
48  {
49  c0 230;
50  Tref 470;
51  n0 3;
52  hf 0;
53  }
54  \endverbatim
55 
56 SourceFiles
57  ePowerThermoI.H
58  ePowerThermo.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef ePowerThermo_H
63 #define ePowerThermo_H
64 
65 #include "scalar.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 // Forward declaration of friend functions and operators
73 
74 template<class EquationOfState> class ePowerThermo;
75 
76 template<class EquationOfState>
77 inline ePowerThermo<EquationOfState> operator+
78 (
79  const ePowerThermo<EquationOfState>&,
80  const ePowerThermo<EquationOfState>&
81 );
82 
83 template<class EquationOfState>
84 inline ePowerThermo<EquationOfState> operator*
85 (
86  const scalar,
87  const ePowerThermo<EquationOfState>&
88 );
89 
90 
91 template<class EquationOfState>
92 inline ePowerThermo<EquationOfState> operator==
93 (
96 );
97 
98 
99 template<class EquationOfState>
100 Ostream& operator<<
101 (
102  Ostream&,
104 );
105 
106 
107 /*---------------------------------------------------------------------------*\
108  Class ePowerThermo Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 template<class EquationOfState>
112 class ePowerThermo
113 :
114  public EquationOfState
115 {
116  // Private Data
117 
118  scalar c0_;
119  scalar n0_;
120  scalar Tref_;
121  scalar hf_;
122 
123 
124  // Private Member Functions
125 
126  //- Check given temperature is within the range of the fitted coeffs
127  inline void checkT(const scalar T) const;
128 
129 
130 public:
131 
132  // Constructors
133 
134  //- Construct from components
135  inline ePowerThermo
136  (
137  const EquationOfState& st,
138  const scalar c0,
139  const scalar n0,
140  const scalar Tref,
141  const scalar hf
142  );
143 
144  //- Construct from name and dictionary
145  ePowerThermo(const word& name, const dictionary& dict);
146 
147  //- Construct as a named copy
148  inline ePowerThermo
149  (
150  const word&,
151  const ePowerThermo&
152  );
153 
154  //- Construct and return a clone
155  inline autoPtr<ePowerThermo> clone() const;
156 
157 
158  // Member Functions
159 
160  //- Return the instantiated type name
161  static word typeName()
162  {
163  return "ePower<" + EquationOfState::typeName() + '>';
164  }
165 
166  //- Limit the temperature to be in the range Tlow_ to Thigh_
167  inline scalar limit(const scalar T) const;
168 
169 
170  // Fundamental properties
171 
172  //- Heat capacity at constant volume [J/kg/K]
173  inline scalar Cv(const scalar p, const scalar T) const;
174 
175  //- Sensible internal energy [J/kg]
176  inline scalar es(const scalar p, const scalar T) const;
177 
178  //- Absolute internal energy [J/kg]
179  inline scalar ea(const scalar p, const scalar T) const;
180 
181  //- Enthalpy of formation [J/kg]
182  inline scalar hf() const;
183 
184  //- Entropy [J/kg/K]
185  inline scalar s(const scalar p, const scalar T) const;
186 
187  //- Gibbs free energy of the mixture in the standard state [J/kg]
188  inline scalar gStd(const scalar T) const;
189 
190  #include "EtoHthermo.H"
191 
192 
193  // Derivative term used for Jacobian
194 
195  //- Temperature derivative of heat capacity at constant pressure
196  inline scalar dCpdT(const scalar p, const scalar T) const;
197 
198 
199  // Member Operators
200 
201  inline void operator+=(const ePowerThermo&);
202 
203 
204  // Friend operators
205 
206  friend ePowerThermo operator+ <EquationOfState>
207  (
208  const ePowerThermo&,
209  const ePowerThermo&
210  );
211 
212  friend ePowerThermo operator* <EquationOfState>
213  (
214  const scalar,
215  const ePowerThermo&
216  );
217 
218 
219  friend ePowerThermo operator== <EquationOfState>
220  (
221  const ePowerThermo&,
222  const ePowerThermo&
223  );
224 
225 
226  // Ostream Operator
227 
228  friend Ostream& operator<< <EquationOfState>
229  (
230  Ostream&,
231  const ePowerThermo&
232  );
233 };
234 
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 } // End namespace Foam
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #ifdef NoRepository
243  #include "ePowerThermoI.H"
244  #include "ePowerThermo.C"
245 #endif
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
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:162
Internal energy based thermodynamics package using a power function of temperature for the constant h...
Definition: ePowerThermo.H:129
scalar gStd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: ePowerThermoI.H:97
ePowerThermo(const EquationOfState &st, const scalar c0, const scalar n0, const scalar Tref, const scalar hf)
Construct from components.
Definition: ePowerThermoI.H:51
void operator+=(const ePowerThermo &)
scalar s(const scalar p, const scalar T) const
Entropy [J/kg/K].
static word typeName()
Return the instantiated type name.
Definition: ePowerThermo.H:175
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
autoPtr< ePowerThermo > clone() const
Construct and return a clone.
Definition: ePowerThermoI.H:84
scalar ea(const scalar p, const scalar T) const
Absolute internal energy [J/kg].
scalar Cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/kg/K].
scalar hf() const
Enthalpy of formation [J/kg].
scalar es(const scalar p, const scalar T) const
Sensible internal energy [J/kg].
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dictionary dict
volScalarField & p