1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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 "specieThermo.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template<class Thermo>
31 inline Foam::specieThermo<Thermo>::specieThermo
40 template<class Thermo>
41 inline Foam::scalar Foam::specieThermo<Thermo>::T
45 scalar (specieThermo<Thermo>::*F)(const scalar) const,
46 scalar (specieThermo<Thermo>::*dFdT)(const scalar) const,
47 scalar (specieThermo<Thermo>::*limit)(const scalar) const
52 scalar Ttol = T0*tol_;
59 (this->*limit)(Test - ((this->*F)(Test) - f)/(this->*dFdT)(Test));
61 if (iter++ > maxIter_)
65 "specieThermo<Thermo>::T(scalar f, scalar T0, "
66 "scalar (specieThermo<Thermo>::*F)(const scalar) const, "
67 "scalar (specieThermo<Thermo>::*dFdT)(const scalar) const"
69 ) << "Maximum number of iterations exceeded"
73 } while (mag(Tnew - Test) > Ttol);
79 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
81 template<class Thermo>
82 inline Foam::specieThermo<Thermo>::specieThermo
85 const specieThermo& st
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 template<class Thermo>
95 inline Foam::scalar Foam::specieThermo<Thermo>::cv(const scalar T) const
97 return this->cp(T) - this->RR;
101 template<class Thermo>
102 inline Foam::scalar Foam::specieThermo<Thermo>::gamma(const scalar T) const
104 scalar CP = this->cp(T);
105 return CP/(CP - this->RR);
109 template<class Thermo>
110 inline Foam::scalar Foam::specieThermo<Thermo>::e(const scalar T) const
112 return this->h(T) - this->RR*(T - this->Tstd);
116 template<class Thermo>
117 inline Foam::scalar Foam::specieThermo<Thermo>::es(const scalar T) const
119 return this->hs(T) - this->RR*(T - this->Tstd);
123 template<class Thermo>
124 inline Foam::scalar Foam::specieThermo<Thermo>::g(const scalar T) const
126 return this->h(T) - T*this->s(T);
130 template<class Thermo>
131 inline Foam::scalar Foam::specieThermo<Thermo>::a(const scalar T) const
133 return this->e(T) - T*this->s(T);
137 template<class Thermo>
138 inline Foam::scalar Foam::specieThermo<Thermo>::Cp(const scalar T) const
140 return this->cp(T)/this->W();
144 template<class Thermo>
145 inline Foam::scalar Foam::specieThermo<Thermo>::Cv(const scalar T) const
147 return this->cv(T)/this->W();
151 template<class Thermo>
152 inline Foam::scalar Foam::specieThermo<Thermo>::H(const scalar T) const
154 return this->h(T)/this->W();
158 template<class Thermo>
159 inline Foam::scalar Foam::specieThermo<Thermo>::Hs(const scalar T) const
161 return this->hs(T)/this->W();
165 template<class Thermo>
166 inline Foam::scalar Foam::specieThermo<Thermo>::Hc() const
168 return this->hc()/this->W();
172 template<class Thermo>
173 inline Foam::scalar Foam::specieThermo<Thermo>::S(const scalar T) const
175 return this->s(T)/this->W();
179 template<class Thermo>
180 inline Foam::scalar Foam::specieThermo<Thermo>::E(const scalar T) const
182 return this->e(T)/this->W();
186 template<class Thermo>
187 inline Foam::scalar Foam::specieThermo<Thermo>::G(const scalar T) const
189 return this->g(T)/this->W();
193 template<class Thermo>
194 inline Foam::scalar Foam::specieThermo<Thermo>::A(const scalar T) const
196 return this->a(T)/this->W();
200 template<class Thermo>
201 inline Foam::scalar Foam::specieThermo<Thermo>::K(const scalar T) const
203 scalar arg = -this->nMoles()*this->g(T)/(this->RR*T);
216 template<class Thermo>
217 inline Foam::scalar Foam::specieThermo<Thermo>::Kp(const scalar T) const
223 template<class Thermo>
224 inline Foam::scalar Foam::specieThermo<Thermo>::Kc(const scalar T) const
226 if (equal(this->nMoles(), SMALL))
232 return Kp(T)*pow(this->Pstd/(this->RR*T), this->nMoles());
237 template<class Thermo>
238 inline Foam::scalar Foam::specieThermo<Thermo>::Kx
244 if (equal(this->nMoles(), SMALL))
250 return Kp(T)*pow(this->Pstd/p, this->nMoles());
255 template<class Thermo>
256 inline Foam::scalar Foam::specieThermo<Thermo>::Kn
263 if (equal(this->nMoles(), SMALL))
269 return Kp(T)*pow(n*this->Pstd/p, this->nMoles());
274 template<class Thermo>
275 inline Foam::scalar Foam::specieThermo<Thermo>::TH
285 &specieThermo<Thermo>::H,
286 &specieThermo<Thermo>::Cp,
287 &specieThermo<Thermo>::limit
292 template<class Thermo>
293 inline Foam::scalar Foam::specieThermo<Thermo>::THs
303 &specieThermo<Thermo>::Hs,
304 &specieThermo<Thermo>::Cp,
305 &specieThermo<Thermo>::limit
310 template<class Thermo>
311 inline Foam::scalar Foam::specieThermo<Thermo>::TE
321 &specieThermo<Thermo>::E,
322 &specieThermo<Thermo>::Cv,
323 &specieThermo<Thermo>::limit
328 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
330 template<class Thermo>
331 inline void Foam::specieThermo<Thermo>::operator+=
333 const specieThermo<Thermo>& st
336 Thermo::operator+=(st);
340 template<class Thermo>
341 inline void Foam::specieThermo<Thermo>::operator-=
343 const specieThermo<Thermo>& st
346 Thermo::operator-=(st);
350 template<class Thermo>
351 inline void Foam::specieThermo<Thermo>::operator*=(const scalar s)
353 Thermo::operator*=(s);
357 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
359 template<class Thermo>
360 inline Foam::specieThermo<Thermo> Foam::operator+
362 const specieThermo<Thermo>& st1,
363 const specieThermo<Thermo>& st2
366 return specieThermo<Thermo>
368 static_cast<const Thermo&>(st1) + static_cast<const Thermo&>(st2)
373 template<class Thermo>
374 inline Foam::specieThermo<Thermo> Foam::operator-
376 const specieThermo<Thermo>& st1,
377 const specieThermo<Thermo>& st2
380 return specieThermo<Thermo>
382 static_cast<const Thermo&>(st1) - static_cast<const Thermo&>(st2)
387 template<class Thermo>
388 inline Foam::specieThermo<Thermo> Foam::operator*
391 const specieThermo<Thermo>& st
394 return specieThermo<Thermo>
396 s*static_cast<const Thermo&>(st)
401 template<class Thermo>
402 inline Foam::specieThermo<Thermo> Foam::operator==
404 const specieThermo<Thermo>& st1,
405 const specieThermo<Thermo>& st2
412 // ************************************************************************* //