eConstThermo.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) 2011-2021 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::eConstThermo
26 
27 Description
28  Internal energy based thermodynamics package using a constant heat capacity
29  at constant volume:
30 
31  \verbatim
32  e = Cv*(T - Tref) + Esref
33  \endverbatim
34 
35 Usage
36  \table
37  Property | Description
38  Cv | Constant Heat capacity at constant volume [J/kg/K]
39  Tref | Reference temperature [K] (defaults to Tstd)
40  Esref | Reference sensible internal energy [J/kg] (defaults to 0)
41  Hf | Heat of formation [J/kg]
42  \endtable
43 
44  Example specification of eConstThermo for air:
45  \verbatim
46  thermodynamics
47  {
48  Cv 724;
49  Hf 0;
50  }
51  \endverbatim
52 
53 SourceFiles
54  eConstThermoI.H
55  eConstThermo.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef eConstThermo_H
60 #define eConstThermo_H
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declaration of friend functions and operators
68 
69 template<class EquationOfState> class eConstThermo;
70 
71 template<class EquationOfState>
72 inline eConstThermo<EquationOfState> operator+
73 (
74  const eConstThermo<EquationOfState>&,
75  const eConstThermo<EquationOfState>&
76 );
77 
78 template<class EquationOfState>
79 inline eConstThermo<EquationOfState> operator*
80 (
81  const scalar,
82  const eConstThermo<EquationOfState>&
83 );
84 
85 template<class EquationOfState>
86 inline eConstThermo<EquationOfState> operator==
87 (
88  const eConstThermo<EquationOfState>&,
89  const eConstThermo<EquationOfState>&
90 );
91 
92 template<class EquationOfState>
93 Ostream& operator<<
94 (
95  Ostream&,
96  const eConstThermo<EquationOfState>&
97 );
98 
99 
100 /*---------------------------------------------------------------------------*\
101  Class eConstThermo Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 template<class EquationOfState>
105 class eConstThermo
106 :
107  public EquationOfState
108 {
109  // Private Data
110 
111  //- Heat capacity at constant volume [J/kg/K]
112  scalar Cv_;
113 
114  //- Heat of formation [J/kg]
115  scalar Hf_;
116 
117  //- Reference temperature around which to linearise [K]
118  scalar Tref_;
119 
120  //- Reference sensible enthalpy around which to linearise [J/kg]
121  scalar Esref_;
122 
123 
124  // Private Member Functions
125 
126  //- Construct from components
127  inline eConstThermo
128  (
129  const EquationOfState& st,
130  const scalar Cv,
131  const scalar Hf,
132  const scalar Tref,
133  const scalar Esref
134  );
135 
136 
137 public:
138 
139  // Constructors
140 
141  //- Construct from dictionary
142  eConstThermo(const dictionary& dict);
143 
144  //- Construct as named copy
145  inline eConstThermo(const word&, const eConstThermo&);
146 
147  //- Construct and return a clone
148  inline autoPtr<eConstThermo> clone() const;
149 
150  //- Selector from dictionary
151  inline static autoPtr<eConstThermo> New(const dictionary& dict);
152 
153 
154  // Member Functions
155 
156  //- Return the instantiated type name
157  static word typeName()
158  {
159  return "eConst<" + EquationOfState::typeName() + '>';
160  }
161 
162  //- Limit the temperature to be in the range Tlow_ to Thigh_
163  inline scalar limit(const scalar T) const;
164 
165 
166  // Fundamental properties
167 
168  //- Heat capacity at constant volume [J/kg/K]
169  inline scalar Cv(const scalar p, const scalar T) const;
170 
171  //- Sensible internal energy [J/kg]
172  inline scalar Es(const scalar p, const scalar T) const;
173 
174  //- Absolute internal energy [J/kg]
175  inline scalar Ea(const scalar p, const scalar T) const;
176 
177  //- Enthalpy of formation [J/kg]
178  inline scalar Hf() const;
179 
180  //- Entropy [J/kg/K]
181  inline scalar S(const scalar p, const scalar T) const;
182 
183  //- Gibbs free energy of the mixture in the standard state [J/kg]
184  inline scalar Gstd(const scalar T) const;
185 
186  #include "EtoHthermo.H"
187 
188 
189  // Derivative term used for Jacobian
190 
191  //- Temperature derivative of heat capacity at constant pressure
192  inline scalar dCpdT(const scalar p, const scalar T) const;
193 
194 
195  // I-O
196 
197  //- Write to Ostream
198  void write(Ostream& os) const;
199 
200 
201  // Member Operators
202 
203  inline void operator+=(const eConstThermo&);
204 
205 
206  // Friend operators
207 
208  friend eConstThermo operator+ <EquationOfState>
209  (
210  const eConstThermo&,
211  const eConstThermo&
212  );
213 
214  friend eConstThermo operator* <EquationOfState>
215  (
216  const scalar,
217  const eConstThermo&
218  );
219 
220  friend eConstThermo operator== <EquationOfState>
221  (
222  const eConstThermo&,
223  const eConstThermo&
224  );
225 
226 
227  // IOstream Operators
228 
229  friend Ostream& operator<< <EquationOfState>
230  (
231  Ostream&,
232  const eConstThermo&
233  );
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #include "eConstThermoI.H"
244 
245 #ifdef NoRepository
246  #include "eConstThermo.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: eConstThermoI.H:89
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
void operator+=(const eConstThermo &)
scalar Ea(const scalar p, const scalar T) const
Absolute internal energy [J/kg].
static word typeName()
Return the instantiated type name.
Definition: eConstThermo.H:171
scalar Hf() const
Enthalpy of formation [J/kg].
Internal energy based thermodynamics package using a constant heat capacity at constant volume: ...
Definition: eConstThermo.H:83
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:59
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
autoPtr< eConstThermo > clone() const
Construct and return a clone.
Definition: eConstThermoI.H:65
scalar Cv(const scalar p, const scalar T) const
Heat capacity at constant volume [J/kg/K].
Definition: eConstThermoI.H:99
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
void write(Ostream &os) const
Write to Ostream.
Definition: eConstThermo.C:45
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
volScalarField & p
static autoPtr< eConstThermo > New(const dictionary &dict)
Selector from dictionary.
Definition: eConstThermoI.H:76
Namespace for OpenFOAM.