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-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::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>&,
116  const janafThermo<EquationOfState>&
117 );
118 
119 template<class EquationOfState>
120 Ostream& operator<<
121 (
122  Ostream&,
123  const janafThermo<EquationOfState>&
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 data
140 
141  static const int nCoeffs_ = 7;
143 
144 
145 private:
146 
147  // Private Data
148 
149  // Temperature limits of applicability of functions
150  scalar Tlow_, Thigh_, Tcommon_;
151 
152  coeffArray highCpCoeffs_;
153  coeffArray lowCpCoeffs_;
154 
155 
156  // Private Member Functions
157 
158  //- Check that input data is valid
159  void checkInputData() const;
160 
161  //- Return the coefficients corresponding to the given temperature
162  inline const coeffArray& coeffs(const scalar T) const;
163 
164 
165 public:
166 
167  // Constructors
168 
169  //- Construct from components
170  inline janafThermo
171  (
172  const EquationOfState& st,
173  const scalar Tlow,
174  const scalar Thigh,
175  const scalar Tcommon,
176  const coeffArray& highCpCoeffs,
177  const coeffArray& lowCpCoeffs,
178  const bool convertCoeffs = false
179  );
180 
181  //- Construct from dictionary
182  janafThermo(const dictionary& dict);
183 
184  //- Construct as a named copy
185  inline janafThermo(const word&, const janafThermo&);
186 
187 
188  // Member Functions
189 
190  //- Return the instantiated type name
191  static word typeName()
192  {
193  return "janaf<" + EquationOfState::typeName() + '>';
194  }
195 
196  //- Limit the temperature to be in the range Tlow_ to Thigh_
197  inline scalar limit(const scalar T) const;
198 
199 
200  // Access
201 
202  //- Return const access to the low temperature limit
203  inline scalar Tlow() const;
204 
205  //- Return const access to the high temperature limit
206  inline scalar Thigh() const;
207 
208  //- Return const access to the common temperature
209  inline scalar Tcommon() const;
210 
211  //- Return const access to the high temperature poly coefficients
212  inline const coeffArray& highCpCoeffs() const;
213 
214  //- Return const access to the low temperature poly coefficients
215  inline const coeffArray& lowCpCoeffs() const;
216 
217 
218  // Fundamental properties
219 
220  //- Heat capacity at constant pressure [J/kg/K]
221  inline scalar Cp(const scalar p, const scalar T) const;
222 
223  //- Absolute enthalpy [J/kg]
224  inline scalar Ha(const scalar p, const scalar T) const;
225 
226  //- Sensible enthalpy [J/kg]
227  inline scalar Hs(const scalar p, const scalar T) const;
228 
229  //- Enthalpy of formation [J/kg]
230  inline scalar Hf() const;
231 
232  //- Entropy [J/kg/K]
233  inline scalar S(const scalar p, const scalar T) const;
234 
235  //- Gibbs free energy of the mixture in the standard state [J/kg]
236  inline scalar Gstd(const scalar T) const;
237 
238  #include "HtoEthermo.H"
239 
240 
241  // Derivative term used for Jacobian
242 
243  //- Temperature derivative of heat capacity at constant pressure
244  inline scalar dCpdT(const scalar p, const scalar T) const;
245 
246 
247  // I-O
248 
249  //- Write to Ostream
250  void write(Ostream& os) const;
251 
252 
253  // Member Operators
254 
255  inline void operator+=(const janafThermo&);
256 
257 
258  // Friend operators
259 
260  friend janafThermo operator+ <EquationOfState>
261  (
262  const janafThermo&,
263  const janafThermo&
264  );
265 
266  friend janafThermo operator* <EquationOfState>
267  (
268  const scalar,
269  const janafThermo&
270  );
271 
272  friend janafThermo operator== <EquationOfState>
273  (
274  const janafThermo&,
275  const janafThermo&
276  );
277 
278 
279  // Ostream Operator
280 
281  friend Ostream& operator<< <EquationOfState>
282  (
283  Ostream&,
284  const janafThermo&
285  );
286 };
287 
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 } // End namespace Foam
292 
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
294 
295 #include "janafThermoI.H"
296 
297 #ifdef NoRepository
298  #include "janafThermo.C"
299 #endif
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 #endif
304 
305 // ************************************************************************* //
dictionary dict
static const int nCoeffs_
Definition: janafThermo.H:158
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
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
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: janafThermoI.H:261
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: janafThermoI.H:111
A class for handling words, derived from string.
Definition: word.H:59
static word typeName()
Return the instantiated type name.
Definition: janafThermo.H:208
scalar S(const scalar p, const scalar T) const
Entropy [J/kg/K].
Definition: janafThermoI.H:226
scalar Tlow() const
Return const access to the low temperature limit.
Definition: janafThermoI.H:133
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
Definition: janafThermoI.H:185
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:83
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.
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 Hf() const
Enthalpy of formation [J/kg].
Definition: janafThermoI.H:211
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
Enthalpy based thermodynamics package using JANAF tables:
Definition: janafThermo.H:113
scalar Ha(const scalar p, const scalar T) const
Absolute enthalpy [J/kg].
Definition: janafThermoI.H:196
FixedList< scalar, nCoeffs_ > coeffArray
Definition: janafThermo.H:159
volScalarField & p
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/kg/K].
Definition: janafThermoI.H:171
Namespace for OpenFOAM.
scalar Tcommon() const
Return const access to the common temperature.
Definition: janafThermoI.H:147