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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::janafThermo
28 
29 Group
30  grpSpecieThermo
31 
32 Description
33  JANAF tables based thermodynamics package templated
34  into the equation of state.
35 
36 SourceFiles
37  janafThermoI.H
38  janafThermo.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef janafThermo_H
43 #define janafThermo_H
44 
45 #include "scalar.H"
46 #include "FixedList.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declaration of friend functions and operators
54 
55 template<class EquationOfState> class janafThermo;
56 
57 template<class EquationOfState>
58 inline janafThermo<EquationOfState> operator+
59 (
62 );
63 
64 template<class EquationOfState>
65 inline janafThermo<EquationOfState> operator*
66 (
67  const scalar,
69 );
70 
71 template<class EquationOfState>
72 inline janafThermo<EquationOfState> operator==
73 (
76 );
77 
78 template<class EquationOfState>
79 Ostream& operator<<
80 (
81  Ostream&,
83 );
84 
85 
86 /*---------------------------------------------------------------------------*\
87  Class janafThermo Declaration
88 \*---------------------------------------------------------------------------*/
89 
90 template<class EquationOfState>
91 class janafThermo
92 :
93  public EquationOfState
94 {
95 
96 public:
97 
98  // Public data
99 
100  static const 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;
157 
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  #include "HtoEthermo.H"
195 
196 
197  // Derivative term used for Jacobian
198 
199  //- Derivative of Gibbs free energy w.r.t. temperature
200  inline scalar dGdT(const scalar p, const scalar T) const;
201 
202  //- Temperature derivative of heat capacity at constant pressure
203  inline scalar dCpdT(const scalar p, const scalar T) const;
204 
205 
206  // I-O
207 
208  //- Write to Ostream
209  void write(Ostream& os) const;
210 
211 
212  // Member operators
213 
214  inline void operator+=(const janafThermo&);
215 
216 
217  // Friend operators
218 
219  friend janafThermo operator+ <EquationOfState>
220  (
221  const janafThermo&,
222  const janafThermo&
223  );
224 
225  friend janafThermo operator* <EquationOfState>
226  (
227  const scalar,
228  const janafThermo&
229  );
230 
231  friend janafThermo operator== <EquationOfState>
232  (
233  const janafThermo&,
234  const janafThermo&
235  );
236 
237 
238  // Ostream Operator
239 
240  friend Ostream& operator<< <EquationOfState>
241  (
242  Ostream&,
243  const janafThermo&
244  );
245 };
246 
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 } // End namespace Foam
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #include "janafThermoI.H"
255 
256 #ifdef NoRepository
257  #include "janafThermo.C"
258 #endif
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
HtoEthermo.H
Foam::janafThermo::highCpCoeffs
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:157
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::janafThermo::Tlow
scalar Tlow() const
Return const access to the low temperature limit.
Definition: janafThermoI.H:135
Foam::janafThermo::nCoeffs_
static const int nCoeffs_
Definition: janafThermo.H:99
Foam::janafThermo
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:54
Foam::janafThermo::typeName
static word typeName()
Return the instantiated type name.
Definition: janafThermo.H:149
Foam::janafThermo::lowCpCoeffs
const coeffArray & lowCpCoeffs() const
Return const access to the low temperature poly coefficients.
Definition: janafThermoI.H:165
Foam::janafThermo::Cp
scalar Cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kg K)].
Definition: janafThermoI.H:173
Foam::janafThermo::coeffArray
FixedList< scalar, nCoeffs_ > coeffArray
Definition: janafThermo.H:100
Foam::janafThermo::Ha
scalar Ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kg].
Definition: janafThermoI.H:187
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::janafThermo::dGdT
scalar dGdT(const scalar p, const scalar T) const
Derivative of Gibbs free energy w.r.t. temperature.
Definition: janafThermoI.H:244
Foam::janafThermo::operator+=
void operator+=(const janafThermo &)
Definition: janafThermoI.H:270
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
scalar.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::janafThermo::limit
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: janafThermoI.H:113
Foam::janafThermo::Tcommon
scalar Tcommon() const
Return const access to the common temperature.
Definition: janafThermoI.H:149
Foam::FixedList< scalar, nCoeffs_ >
janafThermoI.H
janafThermo.C
Foam::janafThermo::janafThermo
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.
Foam::janafThermo::Hs
scalar Hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kg].
Definition: janafThermoI.H:203
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
FixedList.H
Foam::janafThermo::write
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:85
Foam::janafThermo::Thigh
scalar Thigh() const
Return const access to the high temperature limit.
Definition: janafThermoI.H:142
Foam::janafThermo::dCpdT
scalar dCpdT(const scalar p, const scalar T) const
Temperature derivative of heat capacity at constant pressure.
Definition: janafThermoI.H:256
Foam::janafThermo::Hc
scalar Hc() const
Chemical enthalpy [J/kg].
Definition: janafThermoI.H:213
Foam::janafThermo::S
scalar S(const scalar p, const scalar T) const
Entropy [J/(kg K)].
Definition: janafThermoI.H:228