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-2019 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  JANAF tables based thermodynamics package templated
29  into the equation of state.
30 
31 SourceFiles
32  janafThermoI.H
33  janafThermo.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef janafThermo_H
38 #define janafThermo_H
39 
40 #include "scalar.H"
41 #include "FixedList.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of friend functions and operators
49 
50 template<class EquationOfState> class janafThermo;
51 
52 template<class EquationOfState>
53 inline janafThermo<EquationOfState> operator+
54 (
56  const janafThermo<EquationOfState>&
57 );
58 
59 template<class EquationOfState>
60 inline janafThermo<EquationOfState> operator*
61 (
62  const scalar,
63  const janafThermo<EquationOfState>&
64 );
65 
66 template<class EquationOfState>
67 inline janafThermo<EquationOfState> operator==
68 (
69  const janafThermo<EquationOfState>&,
70  const janafThermo<EquationOfState>&
71 );
72 
73 template<class EquationOfState>
74 Ostream& operator<<
75 (
76  Ostream&,
77  const janafThermo<EquationOfState>&
78 );
79 
80 
81 /*---------------------------------------------------------------------------*\
82  Class janafThermo Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 template<class EquationOfState>
86 class janafThermo
87 :
88  public EquationOfState
89 {
90 
91 public:
92 
93  // Public data
94 
95  static const int nCoeffs_ = 7;
97 
98 
99 private:
100 
101  // Private Data
102 
103  // Temperature limits of applicability of functions
104  scalar Tlow_, Thigh_, Tcommon_;
105 
106  coeffArray highCpCoeffs_;
107  coeffArray lowCpCoeffs_;
108 
109 
110  // Private Member Functions
111 
112  //- Check that input data is valid
113  void checkInputData() const;
114 
115  //- Return the coefficients corresponding to the given temperature
116  inline const coeffArray& coeffs(const scalar T) const;
117 
118 
119 public:
120 
121  // Constructors
122 
123  //- Construct from components
124  inline janafThermo
125  (
126  const EquationOfState& st,
127  const scalar Tlow,
128  const scalar Thigh,
129  const scalar Tcommon,
130  const coeffArray& highCpCoeffs,
131  const coeffArray& lowCpCoeffs,
132  const bool convertCoeffs = false
133  );
134 
135  //- Construct from dictionary
136  janafThermo(const dictionary& dict);
137 
138  //- Construct as a named copy
139  inline janafThermo(const word&, const janafThermo&);
140 
141 
142  // Member Functions
143 
144  //- Return the instantiated type name
145  static word typeName()
146  {
147  return "janaf<" + EquationOfState::typeName() + '>';
148  }
149 
150  //- Limit the temperature to be in the range Tlow_ to Thigh_
151  inline scalar limit(const scalar T) const;
152 
153 
154  // Access
155 
156  //- Return const access to the low temperature limit
157  inline scalar Tlow() const;
158 
159  //- Return const access to the high temperature limit
160  inline scalar Thigh() const;
161 
162  //- Return const access to the common temperature
163  inline scalar Tcommon() const;
164 
165  //- Return const access to the high temperature poly coefficients
166  inline const coeffArray& highCpCoeffs() const;
167 
168  //- Return const access to the low temperature poly coefficients
169  inline const coeffArray& lowCpCoeffs() const;
170 
171 
172  // Fundamental properties
173 
174  //- Heat capacity at constant pressure [J/kg/K]
175  inline scalar Cp(const scalar p, const scalar T) const;
176 
177  //- Absolute Enthalpy [J/kg]
178  inline scalar Ha(const scalar p, const scalar T) const;
179 
180  //- Sensible enthalpy [J/kg]
181  inline scalar Hs(const scalar p, const scalar T) const;
182 
183  //- Chemical enthalpy [J/kg]
184  inline scalar Hc() const;
185 
186  //- Entropy [J/kg/K]
187  inline scalar S(const scalar p, const scalar T) const;
188 
189  #include "HtoEthermo.H"
190 
191 
192  // Derivative term used for Jacobian
193 
194  //- Derivative of Gibbs free energy w.r.t. temperature
195  inline scalar dGdT(const scalar p, const scalar T) const;
196 
197  //- Temperature derivative of heat capacity at constant pressure
198  inline scalar dCpdT(const scalar p, const scalar T) const;
199 
200 
201  // I-O
202 
203  //- Write to Ostream
204  void write(Ostream& os) const;
205 
206 
207  // Member Operators
208 
209  inline void operator+=(const janafThermo&);
210 
211 
212  // Friend operators
213 
214  friend janafThermo operator+ <EquationOfState>
215  (
216  const janafThermo&,
217  const janafThermo&
218  );
219 
220  friend janafThermo operator* <EquationOfState>
221  (
222  const scalar,
223  const janafThermo&
224  );
225 
226  friend janafThermo operator== <EquationOfState>
227  (
228  const janafThermo&,
229  const janafThermo&
230  );
231 
232 
233  // Ostream Operator
234 
235  friend Ostream& operator<< <EquationOfState>
236  (
237  Ostream&,
238  const janafThermo&
239  );
240 };
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #include "janafThermoI.H"
250 
251 #ifdef NoRepository
252  #include "janafThermo.C"
253 #endif
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #endif
258 
259 // ************************************************************************* //
dictionary dict
static const int nCoeffs_
Definition: janafThermo.H:94
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
scalar Thigh() const
Return const access to the high temperature limit.
Definition: janafThermoI.H:140
scalar Hc() const
Chemical enthalpy [J/kg].
Definition: janafThermoI.H:211
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:155
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: janafThermoI.H:254
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:144
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:201
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:53
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:163
void operator+=(const janafThermo &)
Definition: janafThermoI.H:269
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:49
scalar Ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kg].
Definition: janafThermoI.H:185
scalar dGdT(const scalar p, const scalar T) const
Derivative of Gibbs free energy w.r.t. temperature.
Definition: janafThermoI.H:242
FixedList< scalar, nCoeffs_ > coeffArray
Definition: janafThermo.H:95
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