FreeFOAM The Cross-Platform CFD Toolkit
hPolynomialThermoI.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) 2008-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 \*---------------------------------------------------------------------------*/
25 
26 #include "hPolynomialThermo.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class EquationOfState, int PolySize>
32 (
33  const EquationOfState& pt,
34  const scalar Hf,
35  const scalar Sf,
36  const Polynomial<PolySize>& CpPoly,
37  const typename Polynomial<PolySize>::intPolyType& hPoly,
38  const Polynomial<PolySize>& sPoly
39 )
40 :
41  EquationOfState(pt),
42  Hf_(Hf),
43  Sf_(Sf),
44  CpPolynomial_(CpPoly),
45  hPolynomial_(hPoly),
46  sPolynomial_(sPoly)
47 {}
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 template<class EquationOfState, int PolySize>
54 (
55  const hPolynomialThermo& pt
56 )
57 :
58  EquationOfState(pt),
59  Hf_(pt.Hf_),
60  Sf_(pt.Sf_),
61  CpPolynomial_(pt.CpPolynomial_),
62  hPolynomial_(pt.hPolynomial_),
63  sPolynomial_(pt.sPolynomial_)
64 {}
65 
66 
67 template<class EquationOfState, int PolySize>
69 (
70  const word& name,
71  const hPolynomialThermo& pt
72 )
73 :
74  EquationOfState(name, pt),
75  Hf_(pt.Hf_),
76  Sf_(pt.Sf_),
77  CpPolynomial_(pt.CpPolynomial_),
78  hPolynomial_(pt.hPolynomial_),
79  sPolynomial_(pt.sPolynomial_)
80 {}
81 
82 
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 
85 template<class EquationOfState, int PolySize>
87 (
88  const scalar T
89 ) const
90 {
91  return CpPolynomial_.evaluate(T);
92 }
93 
94 
95 template<class EquationOfState, int PolySize>
97 (
98  const scalar T
99 ) const
100 {
101  return hPolynomial_.evaluate(T);
102 }
103 
104 
105 template<class EquationOfState, int PolySize>
107 (
108  const scalar T
109 ) const
110 {
111  return h(T) - hc();
112 }
113 
114 
115 template<class EquationOfState, int PolySize>
117 const
118 {
119  return Hf_;
120 }
121 
122 
123 template<class EquationOfState, int PolySize>
125 (
126  const scalar T
127 ) const
128 {
129  return sPolynomial_.evaluate(T);
130 }
131 
132 
133 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
134 
135 template<class EquationOfState, int PolySize>
138 (
140 )
141 {
142  EquationOfState::operator=(pt);
143 
144  Hf_ = pt.Hf_;
145  Sf_ = pt.Sf_;
146  CpPolynomial_ = pt.CpPolynomial_;
147  hPolynomial_ = pt.hPolynomial_;
148  sPolynomial_ = pt.sPolynomial_;
149 
150  return *this;
151 }
152 
153 
154 template<class EquationOfState, int PolySize>
155 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator+=
156 (
158 )
159 {
160  scalar molr1 = this->nMoles();
161 
162  EquationOfState::operator+=(pt);
163 
164  molr1 /= this->nMoles();
165  scalar molr2 = pt.nMoles()/this->nMoles();
166 
167  Hf_ = molr1*Hf_ + molr2*pt.Hf_;
168  Sf_ = molr1*Sf_ + molr2*pt.Sf_;
169  CpPolynomial_ = molr1*CpPolynomial_ + molr2*pt.CpPolynomial_;
170  hPolynomial_ = molr1*hPolynomial_ + molr2*pt.hPolynomial_;
171  sPolynomial_ = molr1*sPolynomial_ + molr2*pt.sPolynomial_;
172 }
173 
174 
175 template<class EquationOfState, int PolySize>
176 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator-=
177 (
179 )
180 {
181  scalar molr1 = this->nMoles();
182 
183  EquationOfState::operator-=(pt);
184 
185  molr1 /= this->nMoles();
186  scalar molr2 = pt.nMoles()/this->nMoles();
187 
188  Hf_ = molr1*Hf_ - molr2*pt.Hf_;
189  Sf_ = molr1*Sf_ - molr2*pt.Sf_;
190  CpPolynomial_ = molr1*CpPolynomial_ - molr2*pt.CpPolynomial_;
191  hPolynomial_ = molr1*hPolynomial_ - molr2*pt.hPolynomial_;
192  sPolynomial_ = molr1*sPolynomial_ - molr2*pt.sPolynomial_;
193 }
194 
195 
196 template<class EquationOfState, int PolySize>
197 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator*=
198 (
199  const scalar s
200 )
201 {
202  EquationOfState::operator*=(s);
203 }
204 
205 
206 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
207 
208 template<class EquationOfState, int PolySize>
210 (
213 )
214 {
215  EquationOfState eofs = pt1;
216  eofs += pt2;
217 
218  scalar molr1 = pt1.nMoles()/eofs.nMoles();
219  scalar molr2 = pt2.nMoles()/eofs.nMoles();
220 
222  (
223  eofs,
224  molr1*pt1.Hf_ + molr2*pt2.Hf_,
225  molr1*pt1.Sf_ + molr2*pt2.Sf_,
226  molr1*pt1.CpPolynomial_ + molr2*pt2.CpPolynomial_,
227  molr1*pt1.hPolynomial_ + molr2*pt2.hPolynomial_,
228  molr1*pt1.sPolynomial_ + molr2*pt2.sPolynomial_
229  );
230 }
231 
232 
233 template<class EquationOfState, int PolySize>
235 (
238 )
239 {
240  EquationOfState eofs = pt1;
241  eofs -= pt2;
242 
243  scalar molr1 = pt1.nMoles()/eofs.nMoles();
244  scalar molr2 = pt2.nMoles()/eofs.nMoles();
245 
247  (
248  eofs,
249  molr1*pt1.Hf_ - molr2*pt2.Hf_,
250  molr1*pt1.Sf_ - molr2*pt2.Sf_,
251  molr1*pt1.CpPolynomial_ - molr2*pt2.CpPolynomial_,
252  molr1*pt1.hPolynomial_ - molr2*pt2.hPolynomial_,
253  molr1*pt1.sPolynomial_ - molr2*pt2.sPolynomial_
254  );
255 }
256 
257 
258 template<class EquationOfState, int PolySize>
260 (
261  const scalar s,
263 )
264 {
266  (
267  s*static_cast<const EquationOfState&>(pt),
268  pt.Hf_,
269  pt.Sf_,
270  pt.CpPolynomial_,
271  pt.hPolynomial_,
272  pt.sPolynomial_
273  );
274 }
275 
276 
277 template<class EquationOfState, int PolySize>
279 (
282 )
283 {
284  return pt2 - pt1;
285 }
286 
287 
288 // ************************ vim: set sw=4 sts=4 et: ************************ //