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 | Copyright (C) 2011-2016 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 janafThermo<EquationOfState>&,
63  const janafThermo<EquationOfState>&
64 );
65 
66 template<class EquationOfState>
67 inline janafThermo<EquationOfState> operator*
68 (
69  const scalar,
70  const janafThermo<EquationOfState>&
71 );
72 
73 template<class EquationOfState>
74 inline janafThermo<EquationOfState> operator==
75 (
76  const janafThermo<EquationOfState>&,
77  const janafThermo<EquationOfState>&
78 );
79 
80 template<class EquationOfState>
81 Ostream& operator<<
82 (
83  Ostream&,
84  const janafThermo<EquationOfState>&
85 );
86 
87 
88 /*---------------------------------------------------------------------------*\
89  Class janafThermo Declaration
90 \*---------------------------------------------------------------------------*/
91 
92 template<class EquationOfState>
93 class janafThermo
94 :
95  public EquationOfState
96 {
97 
98 public:
99 
100  // Public data
102  static const int nCoeffs_ = 7;
104 
105 
106 private:
107 
108  // Private data
109 
110  // Temperature limits of applicability of functions
111  scalar Tlow_, Thigh_, Tcommon_;
112 
113  coeffArray highCpCoeffs_;
114  coeffArray lowCpCoeffs_;
115 
116 
117  // Private Member Functions
118 
119  //- Check that input data is valid
120  void checkInputData() const;
121 
122  //- Return the coefficients corresponding to the given temperature
123  inline const coeffArray& coeffs(const scalar T) const;
124 
125 
126 public:
127 
128  // Constructors
129 
130  //- Construct from components
131  inline janafThermo
132  (
133  const EquationOfState& st,
134  const scalar Tlow,
135  const scalar Thigh,
136  const scalar Tcommon,
137  const coeffArray& highCpCoeffs,
138  const coeffArray& lowCpCoeffs
139  );
140 
141  //- Construct from Istream
143 
144  //- Construct from dictionary
145  janafThermo(const dictionary& dict);
146 
147  //- Construct as a named copy
148  inline janafThermo(const word&, const janafThermo&);
149 
150 
151  // Member Functions
152 
153  //- Return the instantiated type name
154  static word typeName()
155  {
156  return "janaf<" + EquationOfState::typeName() + '>';
157  }
158 
159  //- Limit the temperature to be in the range Tlow_ to Thigh_
160  inline scalar limit(const scalar T) const;
161 
162 
163  // Access
164 
165  //- Return const access to the low temperature limit
166  inline scalar Tlow() const;
167 
168  //- Return const access to the high temperature limit
169  inline scalar Thigh() const;
170 
171  //- Return const access to the common temperature
172  inline scalar Tcommon() const;
173 
174  //- Return const access to the high temperature poly coefficients
175  inline const coeffArray& highCpCoeffs() const;
176 
177  //- Return const access to the low temperature poly coefficients
178  inline const coeffArray& lowCpCoeffs() const;
179 
180 
181  // Fundamental properties
182 
183  //- Heat capacity at constant pressure [J/(kmol K)]
184  inline scalar cp(const scalar p, const scalar T) const;
185 
186  //- Absolute Enthalpy [J/kmol]
187  inline scalar ha(const scalar p, const scalar T) const;
188 
189  //- Sensible enthalpy [J/kmol]
190  inline scalar hs(const scalar p, const scalar T) const;
191 
192  //- Chemical enthalpy [J/kmol]
193  inline scalar hc() const;
194 
195  //- Entropy [J/(kmol K)]
196  inline scalar s(const scalar p, const scalar T) const;
197 
198 
199  // I-O
200 
201  //- Write to Ostream
202  void write(Ostream& os) const;
203 
204 
205  // Member operators
206 
207  inline void operator+=(const janafThermo&);
208  inline void operator-=(const janafThermo&);
209 
210 
211  // Friend operators
212 
213  friend janafThermo operator+ <EquationOfState>
214  (
215  const janafThermo&,
216  const janafThermo&
217  );
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 // ************************************************************************* //
dictionary dict
scalar limit(const scalar T) const
Limit the temperature to be in the range Tlow_ to Thigh_.
Definition: janafThermoI.H:99
static const int nCoeffs_
Definition: janafThermo.H:101
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
scalar Thigh() const
Return const access to the high temperature limit.
Definition: janafThermoI.H:128
const coeffArray & lowCpCoeffs() const
Return const access to the low temperature poly coefficients.
Definition: janafThermoI.H:151
scalar s(const scalar p, const scalar T) const
Entropy [J/(kmol K)].
Definition: janafThermoI.H:215
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
scalar Tcommon() const
Return const access to the common temperature.
Definition: janafThermoI.H:135
scalar hs(const scalar p, const scalar T) const
Sensible enthalpy [J/kmol].
Definition: janafThermoI.H:190
const coeffArray & highCpCoeffs() const
Return const access to the high temperature poly coefficients.
Definition: janafThermoI.H:143
janafThermo(const EquationOfState &st, const scalar Tlow, const scalar Thigh, const scalar Tcommon, const coeffArray &highCpCoeffs, const coeffArray &lowCpCoeffs)
Construct from components.
void write(Ostream &os) const
Write to Ostream.
Definition: janafThermo.C:101
A class for handling words, derived from string.
Definition: word.H:59
static word typeName()
Return the instantiated type name.
Definition: janafThermo.H:153
scalar ha(const scalar p, const scalar T) const
Absolute Enthalpy [J/kmol].
Definition: janafThermoI.H:173
scalar cp(const scalar p, const scalar T) const
Heat capacity at constant pressure [J/(kmol K)].
Definition: janafThermoI.H:159
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)
void operator-=(const janafThermo &)
Definition: janafThermoI.H:279
scalar hc() const
Chemical enthalpy [J/kmol].
Definition: janafThermoI.H:200
void operator+=(const janafThermo &)
Definition: janafThermoI.H:235
JANAF tables based thermodynamics package templated into the equation of state.
Definition: janafThermo.H:49
FixedList< scalar, nCoeffs_ > coeffArray
Definition: janafThermo.H:102
volScalarField & p
scalar Tlow() const
Return const access to the low temperature limit.
Definition: janafThermoI.H:121
Namespace for OpenFOAM.