1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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
51 scalar Ttol = T0*tol_();
56 // Limit the temperature jump in a single corrector to TJump_
61 - Foam::min(((this->*F)(Test) - f)/(this->*dFdT)(Test), TJump_());
63 if (iter++ > maxIter_())
65 // Improvements: graceful exit with recovery. HJ, 11/Oct/2010
68 "specieThermo<thermo>::T(scalar f, scalar T0, "
69 "scalar (specieThermo<thermo>::*F)(const scalar) const, "
70 "scalar (specieThermo<thermo>::*dFdT)(const scalar) const"
72 ) << "Maximum number of iterations exceeded. T0 = "
73 << T0 << " F = " << (this->*F)(Test)
74 << " dFdT = " << (this->*dFdT)(Test)
77 // Use value where dFdT is calculated using T0. HJ, 11/Oct/2010
78 Tnew = f/(this->*dFdT)(T0);
83 } while (mag(Tnew - Test) > Ttol);
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 template<class thermo>
92 inline Foam::specieThermo<thermo>::specieThermo
95 const specieThermo& st
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 template<class thermo>
105 inline Foam::scalar Foam::specieThermo<thermo>::cv(const scalar T) const
107 return this->cp(T) - this->RR();
111 template<class thermo>
112 inline Foam::scalar Foam::specieThermo<thermo>::gamma(const scalar T) const
114 scalar CP = this->cp(T);
115 return CP/(CP - this->RR());
119 template<class thermo>
120 inline Foam::scalar Foam::specieThermo<thermo>::e(const scalar T) const
122 return this->h(T) - this->RR()*(T - this->Tstd());
126 template<class thermo>
127 inline Foam::scalar Foam::specieThermo<thermo>::es(const scalar T) const
129 return this->hs(T) - this->RR()*(T - this->Tstd());
133 template<class thermo>
134 inline Foam::scalar Foam::specieThermo<thermo>::g(const scalar T) const
136 return this->h(T) - T*this->s(T);
140 template<class thermo>
141 inline Foam::scalar Foam::specieThermo<thermo>::a(const scalar T) const
143 return this->e(T) - T*this->s(T);
147 template<class thermo>
148 inline Foam::scalar Foam::specieThermo<thermo>::Cp(const scalar T) const
150 return this->cp(T)/this->W();
154 template<class thermo>
155 inline Foam::scalar Foam::specieThermo<thermo>::Cv(const scalar T) const
157 return this->cv(T)/this->W();
161 template<class thermo>
162 inline Foam::scalar Foam::specieThermo<thermo>::H(const scalar T) const
164 return this->h(T)/this->W();
168 template<class thermo>
169 inline Foam::scalar Foam::specieThermo<thermo>::Hs(const scalar T) const
171 return this->hs(T)/this->W();
175 template<class thermo>
176 inline Foam::scalar Foam::specieThermo<thermo>::Hc() const
178 return this->hc()/this->W();
182 template<class thermo>
183 inline Foam::scalar Foam::specieThermo<thermo>::S(const scalar T) const
185 return this->s(T)/this->W();
189 template<class thermo>
190 inline Foam::scalar Foam::specieThermo<thermo>::E(const scalar T) const
192 return this->e(T)/this->W();
196 template<class thermo>
197 inline Foam::scalar Foam::specieThermo<thermo>::G(const scalar T) const
199 return this->g(T)/this->W();
203 template<class thermo>
204 inline Foam::scalar Foam::specieThermo<thermo>::A(const scalar T) const
206 return this->a(T)/this->W();
210 template<class thermo>
211 inline Foam::scalar Foam::specieThermo<thermo>::K(const scalar T) const
213 scalar arg = -this->nMoles()*this->g(T)/(this->RR()*T);
226 template<class thermo>
227 inline Foam::scalar Foam::specieThermo<thermo>::Kp(const scalar T) const
233 template<class thermo>
234 inline Foam::scalar Foam::specieThermo<thermo>::Kc(const scalar T) const
236 if (equal(this->nMoles(), SMALL))
242 return Kp(T)*pow(this->Pstd()/(this->RR()*T), this->nMoles());
247 template<class thermo>
248 inline Foam::scalar Foam::specieThermo<thermo>::Kx
254 if (equal(this->nMoles(), SMALL))
260 return Kp(T)*pow(this->Pstd()/p, this->nMoles());
265 template<class thermo>
266 inline Foam::scalar Foam::specieThermo<thermo>::Kn
273 if (equal(this->nMoles(), SMALL))
279 return Kp(T)*pow(n*this->Pstd()/p, this->nMoles());
284 template<class thermo>
285 inline Foam::scalar Foam::specieThermo<thermo>::TH
291 return T(h, T0, &specieThermo<thermo>::H, &specieThermo<thermo>::Cp);
295 template<class thermo>
296 inline Foam::scalar Foam::specieThermo<thermo>::THs
302 return T(hs, T0, &specieThermo<thermo>::Hs, &specieThermo<thermo>::Cp);
306 template<class thermo>
307 inline Foam::scalar Foam::specieThermo<thermo>::TE
313 return T(e, T0, &specieThermo<thermo>::E, &specieThermo<thermo>::Cv);
317 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
319 template<class thermo>
320 inline void Foam::specieThermo<thermo>::operator+=
322 const specieThermo<thermo>& st
325 thermo::operator+=(st);
328 template<class thermo>
329 inline void Foam::specieThermo<thermo>::operator-=
331 const specieThermo<thermo>& st
334 thermo::operator-=(st);
337 template<class thermo>
338 inline void Foam::specieThermo<thermo>::operator*=(const scalar s)
340 thermo::operator*=(s);
344 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
346 template<class thermo>
347 inline Foam::specieThermo<thermo> Foam::operator+
349 const specieThermo<thermo>& st1,
350 const specieThermo<thermo>& st2
353 return specieThermo<thermo>
355 static_cast<const thermo&>(st1) + static_cast<const thermo&>(st2)
360 template<class thermo>
361 inline Foam::specieThermo<thermo> Foam::operator-
363 const specieThermo<thermo>& st1,
364 const specieThermo<thermo>& st2
367 return specieThermo<thermo>
369 static_cast<const thermo&>(st1) - static_cast<const thermo&>(st2)
374 template<class thermo>
375 inline Foam::specieThermo<thermo> Foam::operator*
378 const specieThermo<thermo>& st
381 return specieThermo<thermo>
383 s*static_cast<const thermo&>(st)
388 template<class thermo>
389 inline Foam::specieThermo<thermo> Foam::operator==
391 const specieThermo<thermo>& st1,
392 const specieThermo<thermo>& st2
399 // ************************************************************************* //