janafThermoI.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 "janafThermo.H"
00028 #include "specie.H"
00029
00030
00031
00032 template<class equationOfState>
00033 inline Foam::janafThermo<equationOfState>::janafThermo
00034 (
00035 const equationOfState& st,
00036 const scalar Tlow,
00037 const scalar Thigh,
00038 const scalar Tcommon,
00039 const typename janafThermo<equationOfState>::coeffArray& highCpCoeffs,
00040 const typename janafThermo<equationOfState>::coeffArray& lowCpCoeffs
00041 )
00042 :
00043 equationOfState(st),
00044 Tlow_(Tlow),
00045 Thigh_(Thigh),
00046 Tcommon_(Tcommon)
00047 {
00048 for (register label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
00049 {
00050 highCpCoeffs_[coefLabel] = highCpCoeffs[coefLabel];
00051 lowCpCoeffs_[coefLabel] = lowCpCoeffs[coefLabel];
00052 }
00053 }
00054
00055
00056 template<class equationOfState>
00057 inline void Foam::janafThermo<equationOfState>::checkT(const scalar T) const
00058 {
00059 if (T < Tlow_ || T > Thigh_)
00060 {
00061 FatalErrorIn
00062 (
00063 "janafThermo<equationOfState>::checkT(const scalar T) const"
00064 ) << "attempt to use janafThermo<equationOfState>"
00065 " out of temperature range "
00066 << Tlow_ << " -> " << Thigh_ << "; T = " << T
00067 << abort(FatalError);
00068 }
00069 }
00070
00071
00072 template<class equationOfState>
00073 inline const typename Foam::janafThermo<equationOfState>::coeffArray&
00074 Foam::janafThermo<equationOfState>::coeffs
00075 (
00076 const scalar T
00077 ) const
00078 {
00079 checkT(T);
00080
00081 if (T < Tcommon_)
00082 {
00083 return lowCpCoeffs_;
00084 }
00085 else
00086 {
00087 return highCpCoeffs_;
00088 }
00089 }
00090
00091
00092
00093
00094 template<class equationOfState>
00095 inline Foam::janafThermo<equationOfState>::janafThermo
00096 (
00097 const word& name,
00098 const janafThermo& jt
00099 )
00100 :
00101 equationOfState(name, jt),
00102 Tlow_(jt.Tlow_),
00103 Thigh_(jt.Thigh_),
00104 Tcommon_(jt.Tcommon_)
00105 {
00106 for (register label coefLabel=0; coefLabel<nCoeffs_; coefLabel++)
00107 {
00108 highCpCoeffs_[coefLabel] = jt.highCpCoeffs_[coefLabel];
00109 lowCpCoeffs_[coefLabel] = jt.lowCpCoeffs_[coefLabel];
00110 }
00111 }
00112
00113
00114
00115
00116 template<class equationOfState>
00117 inline Foam::scalar Foam::janafThermo<equationOfState>::cp
00118 (
00119 const scalar T
00120 ) const
00121 {
00122 const coeffArray& a = coeffs(T);
00123 return this->RR*((((a[4]*T + a[3])*T + a[2])*T + a[1])*T + a[0]);
00124 }
00125
00126
00127 template<class equationOfState>
00128 inline Foam::scalar Foam::janafThermo<equationOfState>::h
00129 (
00130 const scalar T
00131 ) const
00132 {
00133 const coeffArray& a = coeffs(T);
00134 return this->RR*
00135 (
00136 ((((a[4]/5.0*T + a[3]/4.0)*T + a[2]/3.0)*T + a[1]/2.0)*T + a[0])*T
00137 + a[5]
00138 );
00139 }
00140
00141
00142 template<class equationOfState>
00143 inline Foam::scalar Foam::janafThermo<equationOfState>::hs
00144 (
00145 const scalar T
00146 ) const
00147 {
00148 return h(T) - hc();
00149 }
00150
00151
00152 template<class equationOfState>
00153 inline Foam::scalar Foam::janafThermo<equationOfState>::hc() const
00154 {
00155 const coeffArray& a = lowCpCoeffs_;
00156 const scalar& Tstd = specie::Tstd;
00157 return this->RR*
00158 (
00159 (
00160 (((a[4]/5.0*Tstd + a[3]/4.0)*Tstd + a[2]/3.0)*Tstd + a[1]/2.0)*Tstd
00161 + a[0]
00162 )*Tstd + a[5]
00163 );
00164 }
00165
00166
00167 template<class equationOfState>
00168 inline Foam::scalar Foam::janafThermo<equationOfState>::s
00169 (
00170 const scalar T
00171 ) const
00172 {
00173 const coeffArray& a = coeffs(T);
00174 return
00175 this->RR*
00176 (
00177 (((a[4]/4.0*T + a[3]/3.0)*T + a[2]/2.0)*T + a[1])*T + a[0]*::log(T)
00178 + a[6]
00179 );
00180 }
00181
00182
00183
00184
00185 template<class equationOfState>
00186 inline void Foam::janafThermo<equationOfState>::operator+=
00187 (
00188 const janafThermo<equationOfState>& jt
00189 )
00190 {
00191 scalar molr1 = this->nMoles();
00192
00193 equationOfState::operator+=(jt);
00194
00195 molr1 /= this->nMoles();
00196 scalar molr2 = jt.nMoles()/this->nMoles();
00197
00198 Tlow_ = max(Tlow_, jt.Tlow_);
00199 Thigh_ = min(Thigh_, jt.Thigh_);
00200 Tcommon_ = molr1*Tcommon_ + molr2*jt.Tcommon_;
00201
00202 for
00203 (
00204 register label coefLabel=0;
00205 coefLabel<janafThermo<equationOfState>::nCoeffs_;
00206 coefLabel++
00207 )
00208 {
00209 highCpCoeffs_[coefLabel] =
00210 molr1*highCpCoeffs_[coefLabel]
00211 + molr2*jt.highCpCoeffs_[coefLabel];
00212
00213 lowCpCoeffs_[coefLabel] =
00214 molr1*lowCpCoeffs_[coefLabel]
00215 + molr2*jt.lowCpCoeffs_[coefLabel];
00216 }
00217 }
00218
00219
00220 template<class equationOfState>
00221 inline void Foam::janafThermo<equationOfState>::operator-=
00222 (
00223 const janafThermo<equationOfState>& jt
00224 )
00225 {
00226 scalar molr1 = this->nMoles();
00227
00228 equationOfState::operator-=(jt);
00229
00230 molr1 /= this->nMoles();
00231 scalar molr2 = jt.nMoles()/this->nMoles();
00232
00233 Tlow_ = max(Tlow_, jt.Tlow_);
00234 Thigh_ = min(Thigh_, jt.Thigh_);
00235 Tcommon_ = molr1*Tcommon_ - molr2*jt.Tcommon_;
00236
00237 for
00238 (
00239 register label coefLabel=0;
00240 coefLabel<janafThermo<equationOfState>::nCoeffs_;
00241 coefLabel++
00242 )
00243 {
00244 highCpCoeffs_[coefLabel] =
00245 molr1*highCpCoeffs_[coefLabel]
00246 - molr2*jt.highCpCoeffs_[coefLabel];
00247
00248 lowCpCoeffs_[coefLabel] =
00249 molr1*lowCpCoeffs_[coefLabel]
00250 - molr2*jt.lowCpCoeffs_[coefLabel];
00251 }
00252 }
00253
00254
00255
00256
00257 template<class equationOfState>
00258 inline Foam::janafThermo<equationOfState> Foam::operator+
00259 (
00260 const janafThermo<equationOfState>& jt1,
00261 const janafThermo<equationOfState>& jt2
00262 )
00263 {
00264 equationOfState eofs = jt1;
00265 eofs += jt2;
00266
00267 scalar molr1 = jt1.nMoles()/eofs.nMoles();
00268 scalar molr2 = jt2.nMoles()/eofs.nMoles();
00269
00270 typename janafThermo<equationOfState>::coeffArray highCpCoeffs;
00271 typename janafThermo<equationOfState>::coeffArray lowCpCoeffs;
00272
00273 for
00274 (
00275 register label coefLabel=0;
00276 coefLabel<janafThermo<equationOfState>::nCoeffs_;
00277 coefLabel++
00278 )
00279 {
00280 highCpCoeffs[coefLabel] =
00281 molr1*jt1.highCpCoeffs_[coefLabel]
00282 + molr2*jt2.highCpCoeffs_[coefLabel];
00283
00284 lowCpCoeffs[coefLabel] =
00285 molr1*jt1.lowCpCoeffs_[coefLabel]
00286 + molr2*jt2.lowCpCoeffs_[coefLabel];
00287 }
00288
00289 return janafThermo<equationOfState>
00290 (
00291 eofs,
00292 max(jt1.Tlow_, jt2.Tlow_),
00293 min(jt1.Thigh_, jt2.Thigh_),
00294 molr1*jt1.Tcommon_ + molr2*jt2.Tcommon_,
00295 highCpCoeffs,
00296 lowCpCoeffs
00297 );
00298 }
00299
00300
00301 template<class equationOfState>
00302 inline Foam::janafThermo<equationOfState> Foam::operator-
00303 (
00304 const janafThermo<equationOfState>& jt1,
00305 const janafThermo<equationOfState>& jt2
00306 )
00307 {
00308 equationOfState eofs = jt1;
00309 eofs -= jt2;
00310
00311 scalar molr1 = jt1.nMoles()/eofs.nMoles();
00312 scalar molr2 = jt2.nMoles()/eofs.nMoles();
00313
00314 typename janafThermo<equationOfState>::coeffArray highCpCoeffs;
00315 typename janafThermo<equationOfState>::coeffArray lowCpCoeffs;
00316
00317 for
00318 (
00319 register label coefLabel=0;
00320 coefLabel<janafThermo<equationOfState>::nCoeffs_;
00321 coefLabel++
00322 )
00323 {
00324 highCpCoeffs[coefLabel] =
00325 molr1*jt1.highCpCoeffs_[coefLabel]
00326 - molr2*jt2.highCpCoeffs_[coefLabel];
00327
00328 lowCpCoeffs[coefLabel] =
00329 molr1*jt1.lowCpCoeffs_[coefLabel]
00330 - molr2*jt2.lowCpCoeffs_[coefLabel];
00331 }
00332
00333 return janafThermo<equationOfState>
00334 (
00335 eofs,
00336 max(jt1.Tlow_, jt2.Tlow_),
00337 min(jt1.Thigh_, jt2.Thigh_),
00338 molr1*jt1.Tcommon_ - molr2*jt2.Tcommon_,
00339 highCpCoeffs,
00340 lowCpCoeffs
00341 );
00342 }
00343
00344
00345 template<class equationOfState>
00346 inline Foam::janafThermo<equationOfState> Foam::operator*
00347 (
00348 const scalar s,
00349 const janafThermo<equationOfState>& jt
00350 )
00351 {
00352 return janafThermo<equationOfState>
00353 (
00354 s*static_cast<const equationOfState&>(jt),
00355 jt.Tlow_,
00356 jt.Thigh_,
00357 jt.Tcommon_,
00358 jt.highCpCoeffs_,
00359 jt.lowCpCoeffs_
00360 );
00361 }
00362
00363
00364 template<class equationOfState>
00365 inline Foam::janafThermo<equationOfState> Foam::operator==
00366 (
00367 const janafThermo<equationOfState>& jt1,
00368 const janafThermo<equationOfState>& jt2
00369 )
00370 {
00371 return jt2 - jt1;
00372 }
00373
00374
00375
Copyright © 2000-2009 OpenCFD Ltd