hConstThermo.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::hConstThermo
26 
27 Description
28  Enthalpy based thermodynamics package using a constant heat capacity
29  at constant pressure:
30 
31  \verbatim
32  h = Cp*(T - Tref) + Hsref
33  \endverbatim
34 
35 Usage
36  \table
37  Property | Description
38  Cp | Constant Heat capacity at constant pressure [J/kg/K]
39  Tref | Reference temperature [K] (defaults to Tstd)
40  Hsref | Reference sensible enthalpy [J/kg] (defaults to 0)
41  Hf | Heat of formation [J/kg]
42  \endtable
43 
44  Example specification of hConstThermo for air:
45  \verbatim
46  thermodynamics
47  {
48  Cp 1007;
49  Hf 0;
50  }
51  \endverbatim
52 
53 SourceFiles
54  hConstThermoI.H
55  hConstThermo.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef hConstThermo_H
60 #define hConstThermo_H
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 // Forward declaration of friend functions and operators
68 
69 template<class EquationOfState> class hConstThermo;
70 
71 template<class EquationOfState>
72 inline hConstThermo<EquationOfState> operator+
73 (
74  const hConstThermo<EquationOfState>&,
75  const hConstThermo<EquationOfState>&
76 );
77 
78 template<class EquationOfState>
79 inline hConstThermo<EquationOfState> operator*
80 (
81  const scalar,
82  const hConstThermo<EquationOfState>&
83 );
84 
85 template<class EquationOfState>
86 inline hConstThermo<EquationOfState> operator==
87 (
88  const hConstThermo<EquationOfState>&,
89  const hConstThermo<EquationOfState>&
90 );
91 
92 template<class EquationOfState>
93 Ostream& operator<<
94 (
95  Ostream&,
96  const hConstThermo<EquationOfState>&
97 );
98 
99 
100 /*---------------------------------------------------------------------------*\
101  Class hConstThermo Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 template<class EquationOfState>
105 class hConstThermo
106 :
107  public EquationOfState
108 {
109  // Private Data
110 
111  //- Heat capacity at constant pressure [J/kg/K]
112  scalar Cp_;
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 Hsref_;
122 
123 
124  // Private Member Functions
125 
126  //- Construct from components
127  inline hConstThermo
128  (
129  const EquationOfState& st,
130  const scalar Cp,
131  const scalar Hf,
132  const scalar Tref,
133  const scalar Hsref
134  );
135 
136 
137 public:
138 
139  // Constructors
140 
141  //- Construct from dictionary
142  hConstThermo(const dictionary& dict);
143 
144  //- Construct as named copy
145  inline hConstThermo(const word&, const hConstThermo&);
146 
147  //- Construct and return a clone
148  inline autoPtr<hConstThermo> clone() const;
149 
150  //- Selector from dictionary
151  inline static autoPtr<hConstThermo> New(const dictionary& dict);
152 
153 
154  // Member Functions
155 
156  //- Return the instantiated type name
157  static word typeName()
158  {
159  return "hConst<" + 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 pressure [J/kg/K]
169  inline scalar Cp(const scalar p, const scalar T) const;
170 
171  //- Absolute enthalpy [J/kg]
172  inline scalar Ha(const scalar p, const scalar T) const;
173 
174  //- Sensible enthalpy [J/kg]
175  inline scalar Hs(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 "HtoEthermo.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 hConstThermo&);
204 
205 
206  // Friend operators
207 
208  friend hConstThermo operator+ <EquationOfState>
209  (
210  const hConstThermo&,
211  const hConstThermo&
212  );
213 
214  friend hConstThermo operator* <EquationOfState>
215  (
216  const scalar,
217  const hConstThermo&
218  );
219 
220  friend hConstThermo operator== <EquationOfState>
221  (
222  const hConstThermo&,
223  const hConstThermo&
224  );
225 
226 
227  // IOstream Operators
228 
229  friend Ostream& operator<< <EquationOfState>
230  (
231  Ostream&,
232  const hConstThermo&
233  );
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #include "hConstThermoI.H"
244 
245 #ifdef NoRepository
246  #include "hConstThermo.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
dictionary dict
Enthalpy based thermodynamics package using a constant heat capacity at constant pressure: ...
Definition: hConstThermo.H:83
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: hConstThermoI.H:89
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
autoPtr< hConstThermo > clone() const
Construct and return a clone.
Definition: hConstThermoI.H:65
static autoPtr< hConstThermo > New(const dictionary &dict)
Selector from dictionary.
Definition: hConstThermoI.H:76
scalar Hf() const
Enthalpy of formation [J/kg].
scalar Ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
static word typeName()
Return the instantiated type name.
Definition: hConstThermo.H:171
void operator+=(const hConstThermo &)
A class for handling words, derived from string.
Definition: word.H:59
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].
Definition: hConstThermoI.H:99
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)
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
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
void write(Ostream &os) const
Write to Ostream.
Definition: hConstThermo.C:45
Namespace for OpenFOAM.