janafThermo.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::janafThermo
29 
30 Group
31  grpSpecieThermo
32 
33 Description
34  JANAF tables based thermodynamics package templated
35  into the equation of state.
36 
37 SourceFiles
38  janafThermoI.H
39  janafThermo.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef janafThermo_H
44 #define janafThermo_H
45 
46 #include "scalar.H"
47 #include "FixedList.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 // Forward Declarations
55 
56 template<class EquationOfState> class janafThermo;
57 
58 template<class EquationOfState>
59 inline janafThermo<EquationOfState> operator+
60 (
63 );
64 
65 template<class EquationOfState>
66 inline janafThermo<EquationOfState> operator*
67 (
68  const scalar,
70 );
71 
72 template<class EquationOfState>
73 inline janafThermo<EquationOfState> operator==
74 (
77 );
78 
79 template<class EquationOfState>
80 Ostream& operator<<
81 (
82  Ostream&,
84 );
85 
86 
87 /*---------------------------------------------------------------------------*\
88  Class janafThermo Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class EquationOfState>
92 class janafThermo
93 :
94  public EquationOfState
95 {
96 public:
97 
98  // Public Data
99 
100  static constexpr int nCoeffs_ = 7;
102 
103 
104 private:
105 
106  // Private Data
107 
108  // Temperature limits of applicability of functions
109  scalar Tlow_, Thigh_, Tcommon_;
110 
111  coeffArray highCpCoeffs_;
112  coeffArray lowCpCoeffs_;
113 
114 
115  // Private Member Functions
116 
117  //- Check that input data is valid
118  void checkInputData() const;
119 
120  //- Return the coefficients corresponding to the given temperature
121  inline const coeffArray& coeffs(const scalar T) const;
122 
123 
124 public:
125 
126  // Constructors
127 
128  //- Construct from components
129  inline janafThermo
130  (
131  const EquationOfState& st,
132  const scalar Tlow,
133  const scalar Thigh,
134  const scalar Tcommon,
135  const coeffArray& highCpCoeffs,
136  const coeffArray& lowCpCoeffs,
137  const bool convertCoeffs = false
138  );
139 
140  //- Construct from dictionary
141  janafThermo(const dictionary& dict);
142 
143  //- Construct as a named copy
144  inline janafThermo(const word&, const janafThermo&);
145 
146 
147  // Member Functions
148 
149  //- Return the instantiated type name
150  static word typeName()
151  {
152  return "janaf<" + EquationOfState::typeName() + '>';
153  }
154 
155  //- Limit the temperature to be in the range Tlow_ to Thigh_
156  inline scalar limit(const scalar T) const;
158 
159  // Access
160 
161  //- Return const access to the low temperature limit
162  inline scalar Tlow() const;
163 
164  //- Return const access to the high temperature limit
165  inline scalar Thigh() const;
166 
167  //- Return const access to the common temperature
168  inline scalar Tcommon() const;
169 
170  //- Return const access to the high temperature poly coefficients
171  inline const coeffArray& highCpCoeffs() const;
172 
173  //- Return const access to the low temperature poly coefficients
174  inline const coeffArray& lowCpCoeffs() const;
175 
176 
177  // Fundamental properties
178 
179  //- Heat capacity at constant pressure [J/(kg K)]
180  inline scalar Cp(const scalar p, const scalar T) const;
181 
182  //- Absolute Enthalpy [J/kg]
183  inline scalar Ha(const scalar p, const scalar T) const;
184 
185  //- Sensible enthalpy [J/kg]
186  inline scalar Hs(const scalar p, const scalar T) const;
187 
188  //- Chemical enthalpy [J/kg]
189  inline scalar Hc() const;
190 
191  //- Entropy [J/(kg K)]
192  inline scalar S(const scalar p, const scalar T) const;
193 
194  //- Gibbs free energy of the mixture in the standard state [J/kg]
195  inline scalar Gstd(const scalar T) const;
196 
197  #include "HtoEthermo.H"
198 
199 
200  // Derivative term used for Jacobian
201 
202 
203  //- Temperature derivative of heat capacity at constant pressure
204  inline scalar dCpdT(const scalar p, const scalar T) const;
205 
206 
207  // I-O
208 
209  //- Write to Ostream
210  void write(Ostream& os) const;
211 
212 
213  // Member operators
214 
215  inline void operator+=(const janafThermo&);
216 
217 
218  // Friend operators
219 
220  friend janafThermo operator+ <EquationOfState>
221  (
222  const janafThermo&,
223  const janafThermo&
224  );
225 
226  friend janafThermo operator* <EquationOfState>
227  (
228  const scalar,
229  const janafThermo&
230  );
231 
232  friend janafThermo operator== <EquationOfState>
233  (
234  const janafThermo&,
235  const janafThermo&
236  );
237 
238 
239  // Ostream Operator
240 
241  friend Ostream& operator<< <EquationOfState>
242  (
243  Ostream&,
244  const janafThermo&
245  );
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 } // End namespace Foam
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #include "janafThermoI.H"
256 
257 #ifdef NoRepository
258  #include "janafThermo.C"
259 #endif
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
scalar Thigh() const
Return const access to the high temperature limit.
Definition: janafThermoI.H:134
scalar Hc() const
Chemical enthalpy [J/kg].
Definition: janafThermoI.H:205
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:149
scalar Gstd(const scalar T) const
Gibbs free energy of the mixture in the standard state [J/kg].
Definition: janafThermoI.H:236
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: janafThermoI.H:255
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: janafThermoI.H:107
A class for handling words, derived from Foam::string.
Definition: word.H:63
static word typeName()
Return the instantiated type name.
Definition: janafThermo.H:157
scalar S(const scalar p, const scalar T) const
Entropy [J/(kg K)].
Definition: janafThermoI.H:220
scalar Tlow() const
Return const access to the low temperature limit.
Definition: janafThermoI.H:127
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
Definition: janafThermoI.H:195
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:78
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:56
OBJstream os(runTime.globalPath()/outputName)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const coeffArray & lowCpCoeffs() const
Return const access to the low temperature poly coefficients.
Definition: janafThermoI.H:157
void operator+=(const janafThermo &)
Definition: janafThermoI.H:269
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:51
scalar Ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kg].
Definition: janafThermoI.H:179
static constexpr int nCoeffs_
Definition: janafThermo.H:95
FixedList< scalar, nCoeffs_ > coeffArray
Definition: janafThermo.H:96
volScalarField & p
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kg K)].
Definition: janafThermoI.H:165
Namespace for OpenFOAM.
scalar Tcommon() const
Return const access to the common temperature.
Definition: janafThermoI.H:141