janafThermo.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-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::janafThermo
26 
27 Description
28  Enthalpy based thermodynamics package using JANAF tables:
29 
30  \verbatim
31  Cp = (((a4*T + a3)*T + a2)*T + a1)*T + a0
32  ha = ((((a4/5*T + a3/4)*T + a2/3)*T + a1/2)*T + a0)*T + a5
33  \endverbatim
34 
35 Usage
36  \table
37  Property | Description
38  Tlow | Lower temperature limit [K]
39  Thigh | Upper temperature limit [K]
40  Tcommon | Transition temperature from low to high polynomials [K]
41  lowCpCoeffs | Low temperature range heat capacity coefficients
42  highCpCoeffs | High temperature range heat capacity coefficients
43  \endtable
44 
45  Example specification of janafThermo for air:
46  \verbatim
47  thermodynamics
48  {
49  Tlow 100;
50  Thigh 10000;
51  Tcommon 1000;
52 
53  lowCpCoeffs
54  (
55  3.5309628
56  -0.0001236595
57  -5.0299339e-07
58  2.4352768e-09
59  -1.4087954e-12
60  -1046.9637
61  2.9674391
62  );
63 
64  highCpCoeffs
65  (
66  2.9525407
67  0.0013968838
68  -4.9262577e-07
69  7.8600091e-11
70  -4.6074978e-15
71  -923.93753
72  5.8718221
73  );
74  }
75  \endverbatim
76 
77 SourceFiles
78  janafThermoI.H
79  janafThermo.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef janafThermo_H
84 #define janafThermo_H
85 
86 #include "scalar.H"
87 #include "FixedList.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 
94 // Forward declaration of friend functions and operators
95 
96 template<class EquationOfState> class janafThermo;
97 
98 template<class EquationOfState>
99 inline janafThermo<EquationOfState> operator+
100 (
101  const janafThermo<EquationOfState>&,
102  const janafThermo<EquationOfState>&
103 );
104 
105 template<class EquationOfState>
106 inline janafThermo<EquationOfState> operator*
107 (
108  const scalar,
109  const janafThermo<EquationOfState>&
110 );
111 
112 template<class EquationOfState>
113 inline janafThermo<EquationOfState> operator==
114 (
115  const janafThermo<EquationOfState>&,
117 );
118 
119 template<class EquationOfState>
120 Ostream& operator<<
121 (
122  Ostream&,
124 );
125 
126 
127 /*---------------------------------------------------------------------------*\
128  Class janafThermo Declaration
129 \*---------------------------------------------------------------------------*/
130 
131 template<class EquationOfState>
132 class janafThermo
133 :
134  public EquationOfState
135 {
136 
137 public:
138 
139  // Public static data
140 
141  //- Number of coefficients
142  static const int nCoeffs_ = 7;
143 
144 
145  // Public typdefs
146 
147  //- Coefficient array type
149 
150 
151 private:
152 
153  // Private Data
154 
155  // Temperature limits of applicability of functions
156  scalar Tlow_, Thigh_, Tcommon_;
157 
158  //- Cp coefficients for the high temperature range (Tcommon to Thigh)
159  coeffArray highCpCoeffs_;
160 
161  //- Cp coefficients for the low temperature range (Tlow to Tcommon)
162  coeffArray lowCpCoeffs_;
163 
164 
165  // Private Member Functions
166 
167  //- Check that input data is valid
168  void checkInputData() const;
169 
170  //- Return the coefficients corresponding to the given temperature
171  inline const coeffArray& coeffs(const scalar T) const;
172 
173 
174 public:
175 
176  // Constructors
177 
178  //- Construct from components
179  inline janafThermo
180  (
181  const EquationOfState& st,
182  const scalar Tlow,
183  const scalar Thigh,
184  const scalar Tcommon,
185  const coeffArray& highCpCoeffs,
186  const coeffArray& lowCpCoeffs,
187  const bool convertCoeffs = false
188  );
189 
190  //- Construct from name and dictionary
191  janafThermo(const word& name, const dictionary& dict);
192 
193  //- Construct as a named copy
194  inline janafThermo(const word&, const janafThermo&);
195 
196 
197  // Member Functions
198 
199  //- Return the instantiated type name
200  static word typeName()
201  {
202  return "janaf<" + EquationOfState::typeName() + '>';
203  }
204 
205  //- Limit the temperature to be in the range Tlow_ to Thigh_
206  inline scalar limit(const scalar T) const;
207 
208 
209  // Access
210 
211  //- Return const access to the low temperature limit
212  inline scalar Tlow() const;
213 
214  //- Return const access to the high temperature limit
215  inline scalar Thigh() const;
216 
217  //- Return const access to the common temperature
218  inline scalar Tcommon() const;
219 
220  //- Return const access to the high temperature poly coefficients
221  inline const coeffArray& highCpCoeffs() const;
222 
223  //- Return const access to the low temperature poly coefficients
224  inline const coeffArray& lowCpCoeffs() const;
225 
226 
227  // Fundamental properties
228 
229  //- Heat capacity at constant pressure [J/kg/K]
230  inline scalar Cp(const scalar p, const scalar T) const;
231 
232  //- Absolute enthalpy [J/kg]
233  inline scalar Ha(const scalar p, const scalar T) const;
234 
235  //- Sensible enthalpy [J/kg]
236  inline scalar Hs(const scalar p, const scalar T) const;
237 
238  //- Enthalpy of formation [J/kg]
239  inline scalar Hf() const;
240 
241  //- Entropy [J/kg/K]
242  inline scalar S(const scalar p, const scalar T) const;
243 
244  //- Gibbs free energy of the mixture in the standard state [J/kg]
245  inline scalar Gstd(const scalar T) const;
246 
247  #include "HtoEthermo.H"
248 
249 
250  // Derivative term used for Jacobian
251 
252  //- Temperature derivative of heat capacity at constant pressure
253  inline scalar dCpdT(const scalar p, const scalar T) const;
254 
255 
256  // I-O
257 
258  //- Write to Ostream
259  void write(Ostream& os) const;
260 
261 
262  // Member Operators
263 
264  inline void operator+=(const janafThermo&);
265 
266 
267  // Friend operators
268 
269  friend janafThermo operator+ <EquationOfState>
270  (
271  const janafThermo&,
272  const janafThermo&
273  );
274 
275  friend janafThermo operator* <EquationOfState>
276  (
277  const scalar,
278  const janafThermo&
279  );
280 
281  friend janafThermo operator== <EquationOfState>
282  (
283  const janafThermo&,
284  const janafThermo&
285  );
286 
287 
288  // Ostream Operator
289 
290  friend Ostream& operator<< <EquationOfState>
291  (
293  const janafThermo&
294  );
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace Foam
301 
302 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 
304 #include "janafThermoI.H"
305 
306 #ifdef NoRepository
307  #include "janafThermo.C"
308 #endif
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #endif
313 
314 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Enthalpy based thermodynamics package using JANAF tables:
Definition: janafThermo.H:152
scalar Hf() const
Enthalpy of formation [J/kg].
Definition: janafThermoI.H:211
janafThermo(const EquationOfState &st, const scalar Tlow, const scalar Thigh, const scalar Tcommon, const coeffArray &highCpCoeffs, const coeffArray &lowCpCoeffs, const bool convertCoeffs=false)
Construct from components.
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: janafThermoI.H:111
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
Definition: janafThermoI.H:185
static word typeName()
Return the instantiated type name.
Definition: janafThermo.H:217
scalar Tlow() const
Return const access to the low temperature limit.
Definition: janafThermoI.H:133
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: janafThermoI.H:261
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].
Definition: janafThermoI.H:171
FixedList< scalar, nCoeffs_ > coeffArray
Coefficient array type.
Definition: janafThermo.H:165
scalar Tcommon() const
Return const access to the common temperature.
Definition: janafThermoI.H:147
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:87
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
Definition: janafThermoI.H:226
scalar Ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
Definition: janafThermoI.H:196
scalar Thigh() const
Return const access to the high temperature limit.
Definition: janafThermoI.H:140
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:155
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
Definition: janafThermoI.H:242
static const int nCoeffs_
Number of coefficients.
Definition: janafThermo.H:159
const coeffArray & lowCpCoeffs() const
Return const access to the low temperature poly coefficients.
Definition: janafThermoI.H:163
void operator+=(const janafThermo &)
Definition: janafThermoI.H:275
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