specieThermoI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "specieThermo.H"
00028
00029
00030
00031 template<class thermo>
00032 inline Foam::specieThermo<thermo>::specieThermo
00033 (
00034 const thermo& sp
00035 )
00036 :
00037 thermo(sp)
00038 {}
00039
00040
00041 template<class thermo>
00042 inline Foam::scalar Foam::specieThermo<thermo>::T
00043 (
00044 scalar f,
00045 scalar T0,
00046 scalar (specieThermo<thermo>::*F)(const scalar) const,
00047 scalar (specieThermo<thermo>::*dFdT)(const scalar) const
00048 ) const
00049 {
00050 scalar Test = T0;
00051 scalar Tnew = T0;
00052 scalar Ttol = T0*tol_;
00053 int iter = 0;
00054
00055 do
00056 {
00057 Test = Tnew;
00058 Tnew = Test - ((this->*F)(Test) - f)/(this->*dFdT)(Test);
00059
00060 if (iter++ > maxIter_)
00061 {
00062 FatalErrorIn
00063 (
00064 "specieThermo<thermo>::T(scalar f, scalar T0, "
00065 "scalar (specieThermo<thermo>::*F)(const scalar) const, "
00066 "scalar (specieThermo<thermo>::*dFdT)(const scalar) const"
00067 ") const"
00068 ) << "Maximum number of iterations exceeded"
00069 << abort(FatalError);
00070 }
00071
00072 } while (mag(Tnew - Test) > Ttol);
00073
00074 return Tnew;
00075 }
00076
00077
00078
00079
00080 template<class thermo>
00081 inline Foam::specieThermo<thermo>::specieThermo
00082 (
00083 const word& name,
00084 const specieThermo& st
00085 )
00086 :
00087 thermo(name, st)
00088 {}
00089
00090
00091
00092
00093 template<class thermo>
00094 inline Foam::scalar Foam::specieThermo<thermo>::cv(const scalar T) const
00095 {
00096 return this->cp(T) - this->RR;
00097 }
00098
00099
00100 template<class thermo>
00101 inline Foam::scalar Foam::specieThermo<thermo>::gamma(const scalar T) const
00102 {
00103 scalar CP = this->cp(T);
00104 return CP/(CP - this->RR);
00105 }
00106
00107
00108 template<class thermo>
00109 inline Foam::scalar Foam::specieThermo<thermo>::e(const scalar T) const
00110 {
00111 return this->h(T) - this->RR*(T - this->Tstd);
00112 }
00113
00114
00115 template<class thermo>
00116 inline Foam::scalar Foam::specieThermo<thermo>::es(const scalar T) const
00117 {
00118 return this->hs(T) - this->RR*(T - this->Tstd);
00119 }
00120
00121
00122 template<class thermo>
00123 inline Foam::scalar Foam::specieThermo<thermo>::g(const scalar T) const
00124 {
00125 return this->h(T) - T*this->s(T);
00126 }
00127
00128
00129 template<class thermo>
00130 inline Foam::scalar Foam::specieThermo<thermo>::a(const scalar T) const
00131 {
00132 return this->e(T) - T*this->s(T);
00133 }
00134
00135
00136 template<class thermo>
00137 inline Foam::scalar Foam::specieThermo<thermo>::Cp(const scalar T) const
00138 {
00139 return this->cp(T)/this->W();
00140 }
00141
00142
00143 template<class thermo>
00144 inline Foam::scalar Foam::specieThermo<thermo>::Cv(const scalar T) const
00145 {
00146 return this->cv(T)/this->W();
00147 }
00148
00149
00150 template<class thermo>
00151 inline Foam::scalar Foam::specieThermo<thermo>::H(const scalar T) const
00152 {
00153 return this->h(T)/this->W();
00154 }
00155
00156
00157 template<class thermo>
00158 inline Foam::scalar Foam::specieThermo<thermo>::Hs(const scalar T) const
00159 {
00160 return this->hs(T)/this->W();
00161 }
00162
00163
00164 template<class thermo>
00165 inline Foam::scalar Foam::specieThermo<thermo>::Hc() const
00166 {
00167 return this->hc()/this->W();
00168 }
00169
00170
00171 template<class thermo>
00172 inline Foam::scalar Foam::specieThermo<thermo>::S(const scalar T) const
00173 {
00174 return this->s(T)/this->W();
00175 }
00176
00177
00178 template<class thermo>
00179 inline Foam::scalar Foam::specieThermo<thermo>::E(const scalar T) const
00180 {
00181 return this->e(T)/this->W();
00182 }
00183
00184
00185 template<class thermo>
00186 inline Foam::scalar Foam::specieThermo<thermo>::G(const scalar T) const
00187 {
00188 return this->g(T)/this->W();
00189 }
00190
00191
00192 template<class thermo>
00193 inline Foam::scalar Foam::specieThermo<thermo>::A(const scalar T) const
00194 {
00195 return this->a(T)/this->W();
00196 }
00197
00198
00199 template<class thermo>
00200 inline Foam::scalar Foam::specieThermo<thermo>::K(const scalar T) const
00201 {
00202 scalar arg = -this->nMoles()*this->g(T)/(this->RR*T);
00203
00204 if (arg < 600.0)
00205 {
00206 return ::exp(arg);
00207 }
00208 else
00209 {
00210 return VGREAT;
00211 }
00212 }
00213
00214
00215 template<class thermo>
00216 inline Foam::scalar Foam::specieThermo<thermo>::Kp(const scalar T) const
00217 {
00218 return K(T);
00219 }
00220
00221
00222 template<class thermo>
00223 inline Foam::scalar Foam::specieThermo<thermo>::Kc(const scalar T) const
00224 {
00225 if (equal(this->nMoles(), SMALL))
00226 {
00227 return Kp(T);
00228 }
00229 else
00230 {
00231 return Kp(T)*pow(this->Pstd/(this->RR*T), this->nMoles());
00232 }
00233 }
00234
00235
00236 template<class thermo>
00237 inline Foam::scalar Foam::specieThermo<thermo>::Kx
00238 (
00239 const scalar T,
00240 const scalar p
00241 ) const
00242 {
00243 if (equal(this->nMoles(), SMALL))
00244 {
00245 return Kp(T);
00246 }
00247 else
00248 {
00249 return Kp(T)*pow(this->Pstd/p, this->nMoles());
00250 }
00251 }
00252
00253
00254 template<class thermo>
00255 inline Foam::scalar Foam::specieThermo<thermo>::Kn
00256 (
00257 const scalar T,
00258 const scalar p,
00259 const scalar n
00260 ) const
00261 {
00262 if (equal(this->nMoles(), SMALL))
00263 {
00264 return Kp(T);
00265 }
00266 else
00267 {
00268 return Kp(T)*pow(n*this->Pstd/p, this->nMoles());
00269 }
00270 }
00271
00272
00273 template<class thermo>
00274 inline Foam::scalar Foam::specieThermo<thermo>::TH
00275 (
00276 const scalar h,
00277 const scalar T0
00278 ) const
00279 {
00280 return T(h, T0, &specieThermo<thermo>::H, &specieThermo<thermo>::Cp);
00281 }
00282
00283
00284 template<class thermo>
00285 inline Foam::scalar Foam::specieThermo<thermo>::TE
00286 (
00287 const scalar e,
00288 const scalar T0
00289 ) const
00290 {
00291 return T(e, T0, &specieThermo<thermo>::E, &specieThermo<thermo>::Cv);
00292 }
00293
00294
00295
00296
00297 template<class thermo>
00298 inline void Foam::specieThermo<thermo>::operator+=
00299 (
00300 const specieThermo<thermo>& st
00301 )
00302 {
00303 thermo::operator+=(st);
00304 }
00305
00306 template<class thermo>
00307 inline void Foam::specieThermo<thermo>::operator-=
00308 (
00309 const specieThermo<thermo>& st
00310 )
00311 {
00312 thermo::operator-=(st);
00313 }
00314
00315 template<class thermo>
00316 inline void Foam::specieThermo<thermo>::operator*=(const scalar s)
00317 {
00318 thermo::operator*=(s);
00319 }
00320
00321
00322
00323
00324 template<class thermo>
00325 inline Foam::specieThermo<thermo> Foam::operator+
00326 (
00327 const specieThermo<thermo>& st1,
00328 const specieThermo<thermo>& st2
00329 )
00330 {
00331 return specieThermo<thermo>
00332 (
00333 static_cast<const thermo&>(st1) + static_cast<const thermo&>(st2)
00334 );
00335 }
00336
00337
00338 template<class thermo>
00339 inline Foam::specieThermo<thermo> Foam::operator-
00340 (
00341 const specieThermo<thermo>& st1,
00342 const specieThermo<thermo>& st2
00343 )
00344 {
00345 return specieThermo<thermo>
00346 (
00347 static_cast<const thermo&>(st1) - static_cast<const thermo&>(st2)
00348 );
00349 }
00350
00351
00352 template<class thermo>
00353 inline Foam::specieThermo<thermo> Foam::operator*
00354 (
00355 const scalar s,
00356 const specieThermo<thermo>& st
00357 )
00358 {
00359 return specieThermo<thermo>
00360 (
00361 s*static_cast<const thermo&>(st)
00362 );
00363 }
00364
00365
00366 template<class thermo>
00367 inline Foam::specieThermo<thermo> Foam::operator==
00368 (
00369 const specieThermo<thermo>& st1,
00370 const specieThermo<thermo>& st2
00371 )
00372 {
00373 return st2 - st1;
00374 }
00375
00376
00377
Copyright © 2000-2009 OpenCFD Ltd