FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 equationOfState.
30 
31 SourceFiles
32  janafThermoI.H
33  janafThermo.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef janafThermo_H
38 #define janafThermo_H
39 
40 #include <OpenFOAM/scalar.H>
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 // Forward declaration of friend functions and operators
48 
49 template<class equationOfState> class janafThermo;
50 
51 template<class equationOfState>
52 inline janafThermo<equationOfState> operator+
53 (
54  const janafThermo<equationOfState>&,
55  const janafThermo<equationOfState>&
56 );
57 
58 template<class equationOfState>
59 inline janafThermo<equationOfState> operator-
60 (
61  const janafThermo<equationOfState>&,
62  const janafThermo<equationOfState>&
63 );
64 
65 template<class equationOfState>
66 inline janafThermo<equationOfState> operator*
67 (
68  const scalar,
69  const janafThermo<equationOfState>&
70 );
71 
72 template<class equationOfState>
73 inline janafThermo<equationOfState> operator==
74 (
75  const janafThermo<equationOfState>&,
76  const janafThermo<equationOfState>&
77 );
78 
79 template<class equationOfState>
80 Ostream& operator<<
81 (
82  Ostream&,
83  const janafThermo<equationOfState>&
84 );
85 
86 
87 /*---------------------------------------------------------------------------*\
88  Class janafThermo Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 template<class equationOfState>
93 :
94  public equationOfState
95 {
96 
97 public:
98 
99  static const int nCoeffs_ = 7;
100  typedef scalar coeffArray[7];
101 
102 private:
103 
104  // Private data
105 
106  // Temperature limits of applicability of functions
107  scalar Tlow_, Thigh_, Tcommon_;
108 
109  coeffArray highCpCoeffs_;
110  coeffArray lowCpCoeffs_;
111 
112 
113  // Private member functions
114 
115  //- Check given temperature is within the range of the fitted coeffs
116  inline void checkT(const scalar T) const;
117 
118  //- Return the coefficients corresponding to the given temperature
119  inline const coeffArray& coeffs(const scalar T) const;
120 
121 
122 public:
123 
124  // Constructors
125 
126  //- Construct from components
127  inline janafThermo
128  (
129  const equationOfState& st,
130  const scalar Tlow,
131  const scalar Thigh,
132  const scalar Tcommon,
133  const coeffArray& highCpCoeffs,
134  const coeffArray& lowCpCoeffs
135  );
136 
137  //- Construct from Istream
139 
140  //- Construct as a named copy
141  inline janafThermo(const word&, const janafThermo&);
142 
143 
144  // Member Functions
145 
146  //- Heat capacity at constant pressure [J/(kmol K)]
147  inline scalar cp(const scalar T) const;
148 
149  //- Enthalpy [J/kmol]
150  inline scalar h(const scalar T) const;
151 
152  //- Sensible enthalpy [J/kmol]
153  inline scalar hs(const scalar T) const;
154 
155  //- Chemical enthalpy [J/kmol]
156  inline scalar hc() const;
157 
158  //- Entropy [J/(kmol K)]
159  inline scalar s(const scalar T) const;
160 
161 
162  // Member operators
163 
164  inline void operator+=(const janafThermo&);
165  inline void operator-=(const janafThermo&);
166 
167 
168  // Friend operators
169 
170  friend janafThermo operator+ <equationOfState>
171  (
172  const janafThermo&,
173  const janafThermo&
174  );
175 
176  friend janafThermo operator- <equationOfState>
177  (
178  const janafThermo&,
179  const janafThermo&
180  );
181 
182  friend janafThermo operator* <equationOfState>
183  (
184  const scalar,
185  const janafThermo&
186  );
187 
188  friend janafThermo operator== <equationOfState>
189  (
190  const janafThermo&,
191  const janafThermo&
192  );
193 
194 
195  // Ostream Operator
196 
197  friend Ostream& operator<< <equationOfState>
198  (
199  Ostream&,
200  const janafThermo&
201  );
202 };
203 
204 
205 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
206 
207 } // End namespace Foam
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #include <specie/janafThermoI.H>
212 
213 #ifdef NoRepository
214 # include <specie/janafThermo.C>
215 #endif
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #endif
220 
221 // ************************ vim: set sw=4 sts=4 et: ************************ //