1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "hPolynomialThermo.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<class EquationOfState, int PolySize>
31 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
33 const EquationOfState& pt,
36 const Polynomial<PolySize>& CpCoeffs,
37 const typename Polynomial<PolySize>::intPolyType& hCoeffs,
38 const Polynomial<PolySize>& sCoeffs
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 template<class EquationOfState, int PolySize>
53 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
55 const hPolynomialThermo& pt
61 CpCoeffs_(pt.CpCoeffs_),
62 hCoeffs_(pt.hCoeffs_),
67 template<class EquationOfState, int PolySize>
68 inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo
71 const hPolynomialThermo& pt
74 EquationOfState(name, pt),
77 CpCoeffs_(pt.CpCoeffs_),
78 hCoeffs_(pt.hCoeffs_),
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 template<class EquationOfState, int PolySize>
86 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::cp
91 return CpCoeffs_.value(T);
95 template<class EquationOfState, int PolySize>
96 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::h
101 return hCoeffs_.value(T);
105 template<class EquationOfState, int PolySize>
106 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::hs
115 template<class EquationOfState, int PolySize>
116 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::hc()
123 template<class EquationOfState, int PolySize>
124 inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::s
129 return sCoeffs_.value(T);
133 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
135 template<class EquationOfState, int PolySize>
136 inline Foam::hPolynomialThermo<EquationOfState, PolySize>&
137 Foam::hPolynomialThermo<EquationOfState, PolySize>::operator=
139 const hPolynomialThermo<EquationOfState, PolySize>& pt
142 EquationOfState::operator=(pt);
146 CpCoeffs_ = pt.CpCoeffs_;
147 hCoeffs_ = pt.hCoeffs_;
148 sCoeffs_ = pt.sCoeffs_;
154 template<class EquationOfState, int PolySize>
155 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator+=
157 const hPolynomialThermo<EquationOfState, PolySize>& pt
160 scalar molr1 = this->nMoles();
162 EquationOfState::operator+=(pt);
164 molr1 /= this->nMoles();
165 scalar molr2 = pt.nMoles()/this->nMoles();
167 Hf_ = molr1*Hf_ + molr2*pt.Hf_;
168 Sf_ = molr1*Sf_ + molr2*pt.Sf_;
169 CpCoeffs_ = molr1*CpCoeffs_ + molr2*pt.CpCoeffs_;
170 hCoeffs_ = molr1*hCoeffs_ + molr2*pt.hCoeffs_;
171 sCoeffs_ = molr1*sCoeffs_ + molr2*pt.sCoeffs_;
175 template<class EquationOfState, int PolySize>
176 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator-=
178 const hPolynomialThermo<EquationOfState, PolySize>& pt
181 scalar molr1 = this->nMoles();
183 EquationOfState::operator-=(pt);
185 molr1 /= this->nMoles();
186 scalar molr2 = pt.nMoles()/this->nMoles();
188 Hf_ = molr1*Hf_ - molr2*pt.Hf_;
189 Sf_ = molr1*Sf_ - molr2*pt.Sf_;
190 CpCoeffs_ = molr1*CpCoeffs_ - molr2*pt.CpCoeffs_;
191 hCoeffs_ = molr1*hCoeffs_ - molr2*pt.hCoeffs_;
192 sCoeffs_ = molr1*sCoeffs_ - molr2*pt.sCoeffs_;
196 template<class EquationOfState, int PolySize>
197 inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator*=
202 EquationOfState::operator*=(s);
206 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
208 template<class EquationOfState, int PolySize>
209 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator+
211 const hPolynomialThermo<EquationOfState, PolySize>& pt1,
212 const hPolynomialThermo<EquationOfState, PolySize>& pt2
215 EquationOfState eofs = pt1;
218 scalar molr1 = pt1.nMoles()/eofs.nMoles();
219 scalar molr2 = pt2.nMoles()/eofs.nMoles();
221 return hPolynomialThermo<EquationOfState, PolySize>
224 molr1*pt1.Hf_ + molr2*pt2.Hf_,
225 molr1*pt1.Sf_ + molr2*pt2.Sf_,
226 molr1*pt1.CpCoeffs_ + molr2*pt2.CpCoeffs_,
227 molr1*pt1.hCoeffs_ + molr2*pt2.hCoeffs_,
228 molr1*pt1.sCoeffs_ + molr2*pt2.sCoeffs_
233 template<class EquationOfState, int PolySize>
234 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator-
236 const hPolynomialThermo<EquationOfState, PolySize>& pt1,
237 const hPolynomialThermo<EquationOfState, PolySize>& pt2
240 EquationOfState eofs = pt1;
243 scalar molr1 = pt1.nMoles()/eofs.nMoles();
244 scalar molr2 = pt2.nMoles()/eofs.nMoles();
246 return hPolynomialThermo<EquationOfState, PolySize>
249 molr1*pt1.Hf_ - molr2*pt2.Hf_,
250 molr1*pt1.Sf_ - molr2*pt2.Sf_,
251 molr1*pt1.CpCoeffs_ - molr2*pt2.CpCoeffs_,
252 molr1*pt1.hCoeffs_ - molr2*pt2.hCoeffs_,
253 molr1*pt1.sCoeffs_ - molr2*pt2.sCoeffs_
258 template<class EquationOfState, int PolySize>
259 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator*
262 const hPolynomialThermo<EquationOfState, PolySize>& pt
265 return hPolynomialThermo<EquationOfState, PolySize>
267 s*static_cast<const EquationOfState&>(pt),
277 template<class EquationOfState, int PolySize>
278 inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator==
280 const hPolynomialThermo<EquationOfState, PolySize>& pt1,
281 const hPolynomialThermo<EquationOfState, PolySize>& pt2
288 // ************************************************************************* //