OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

ReactingParcel.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "ReactingParcel.H"
00028 
00029 // * * * * * * * * * * *  Protected Member Functions * * * * * * * * * * * * //
00030 
00031 template<class ParcelType>
00032 template<class TrackData>
00033 void Foam::ReactingParcel<ParcelType>::setCellValues
00034 (
00035     TrackData& td,
00036     const scalar dt,
00037     const label cellI
00038 )
00039 {
00040     ThermoParcel<ParcelType>::setCellValues(td, dt, cellI);
00041 
00042     pc_ = td.pInterp().interpolate(this->position(), cellI);
00043     if (pc_ < td.constProps().pMin())
00044     {
00045         WarningIn
00046         (
00047             "void Foam::ReactingParcel<ParcelType>::setCellValues"
00048             "("
00049                 "TrackData&, "
00050                 "const scalar, "
00051                 "const label"
00052             ")"
00053         )   << "Limiting observed pressure in cell " << cellI << " to "
00054             << td.constProps().pMin() <<  nl << endl;
00055 
00056         pc_ = td.constProps().pMin();
00057     }
00058 }
00059 
00060 
00061 template<class ParcelType>
00062 template<class TrackData>
00063 void Foam::ReactingParcel<ParcelType>::cellValueSourceCorrection
00064 (
00065     TrackData& td,
00066     const scalar dt,
00067     const label cellI
00068 )
00069 {
00070     scalar massCell = this->massCell(cellI);
00071 
00072     scalar addedMass = 0.0;
00073     forAll(td.cloud().rhoTrans(), i)
00074     {
00075         addedMass += td.cloud().rhoTrans(i)[cellI];
00076     }
00077 
00078     this->rhoc_ += addedMass/td.cloud().pMesh().cellVolumes()[cellI];
00079 
00080     scalar massCellNew = massCell + addedMass;
00081     this->Uc_ += td.cloud().UTrans()[cellI]/massCellNew;
00082 
00083     scalar cpEff = 0;
00084     if (addedMass > ROOTVSMALL)
00085     {
00086         forAll(td.cloud().rhoTrans(), i)
00087         {
00088             scalar Y = td.cloud().rhoTrans(i)[cellI]/addedMass;
00089             cpEff +=
00090                 Y*td.cloud().mcCarrierThermo().speciesData()[i].Cp(this->Tc_);
00091         }
00092     }
00093     const scalar cpc = td.cpInterp().psi()[cellI];
00094     this->cpc_ = (massCell*cpc + addedMass*cpEff)/massCellNew;
00095 
00096     this->Tc_ += td.cloud().hsTrans()[cellI]/(this->cpc_*massCellNew);
00097 }
00098 
00099 
00100 template<class ParcelType>
00101 Foam::scalar Foam::ReactingParcel<ParcelType>::updateMassFraction
00102 (
00103     const scalar mass0,
00104     const scalarField& dMass,
00105     scalarField& Y
00106 ) const
00107 {
00108     scalar mass1 = mass0 - sum(dMass);
00109 
00110     // only update the mass fractions if the new particle mass is finite
00111     if (mass1 > ROOTVSMALL)
00112     {
00113         forAll(Y, i)
00114         {
00115             Y[i] = (Y[i]*mass0 - dMass[i])/mass1;
00116         }
00117     }
00118 
00119     return mass1;
00120 }
00121 
00122 
00123 template<class ParcelType>
00124 template<class TrackData>
00125 void Foam::ReactingParcel<ParcelType>::calc
00126 (
00127     TrackData& td,
00128     const scalar dt,
00129     const label cellI
00130 )
00131 {
00132     // Define local properties at beginning of time step
00133     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00134     const scalar np0 = this->nParticle_;
00135     const scalar d0 = this->d_;
00136     const vector& U0 = this->U_;
00137     const scalar rho0 = this->rho_;
00138     const scalar T0 = this->T_;
00139     const scalar cp0 = this->cp_;
00140     const scalar mass0 = this->mass();
00141 
00142     // Explicit momentum source for particle
00143     vector Su = vector::zero;
00144 
00145     // Momentum transfer from the particle to the carrier phase
00146     vector dUTrans = vector::zero;
00147 
00148     // Explicit enthalpy source for particle
00149     scalar Sh = 0.0;
00150 
00151     // Sensible enthalpy transfer from the particle to the carrier phase
00152     scalar dhsTrans = 0.0;
00153 
00154 
00155     // Phase change
00156     // ~~~~~~~~~~~~
00157 
00158     // Mass transfer due to phase change
00159     scalarField dMassPC(Y_.size(), 0.0);
00160 
00161     // Calc mass and enthalpy transfer due to phase change
00162     calcPhaseChange
00163     (
00164         td,
00165         dt,
00166         cellI,
00167         d0,
00168         T0,
00169         U0,
00170         mass0,
00171         0,
00172         1.0,
00173         Y_,
00174         dMassPC,
00175         Sh,
00176         dhsTrans
00177     );
00178 
00179     // Update particle component mass and mass fractions
00180     scalar mass1 = updateMassFraction(mass0, dMassPC, Y_);
00181 
00182 
00183     // Heat transfer
00184     // ~~~~~~~~~~~~~
00185 
00186     // Calculate new particle temperature
00187     scalar T1 =
00188         calcHeatTransfer(td, dt, cellI, d0, U0, rho0, T0, cp0, Sh, dhsTrans);
00189 
00190 
00191     // Motion
00192     // ~~~~~~
00193 
00194     // Calculate new particle velocity
00195     vector U1 = calcVelocity(td, dt, cellI, d0, U0, rho0, mass0, Su, dUTrans);
00196 
00197     dUTrans += 0.5*(mass0 - mass1)*(U0 + U1);
00198 
00199     // Accumulate carrier phase source terms
00200     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00201     if (td.cloud().coupled())
00202     {
00203         // Transfer mass lost from particle to carrier mass source
00204         forAll(dMassPC, i)
00205         {
00206             label gid = td.cloud().composition().localToGlobalCarrierId(0, i);
00207             td.cloud().rhoTrans(gid)[cellI] += np0*dMassPC[i];
00208             td.cloud().hcTrans()[cellI] +=
00209                 np0
00210                *dMassPC[i]
00211                *td.cloud().mcCarrierThermo().speciesData()[gid].H(T0);
00212         }
00213 
00214         // Update momentum transfer
00215         td.cloud().UTrans()[cellI] += np0*dUTrans;
00216 
00217         // Update sensible enthalpy transfer
00218         td.cloud().hsTrans()[cellI] += np0*dhsTrans;
00219     }
00220 
00221 
00222     // Remove the particle when mass falls below minimum threshold
00223     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00224     if (mass1 < td.constProps().minParticleMass())
00225     {
00226         td.keepParticle = false;
00227 
00228         if (td.cloud().coupled())
00229         {
00230             // Absorb parcel into carrier phase
00231             forAll(Y_, i)
00232             {
00233                 label gid =
00234                     td.cloud().composition().localToGlobalCarrierId(0, i);
00235                 td.cloud().rhoTrans(gid)[cellI] += np0*mass1*Y_[i];
00236             }
00237             td.cloud().UTrans()[cellI] += np0*mass1*U1;
00238             td.cloud().hcTrans()[cellI] +=
00239                 np0*mass1*td.cloud().composition().H(0, Y_, pc_, T1);
00240         }
00241     }
00242 
00243 
00244     // Set new particle properties
00245     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
00246 
00247     else
00248     {
00249         this->cp_ = td.cloud().composition().cp(0, Y_, pc_, T1);
00250         this->T_ = T1;
00251         this->U_ = U1;
00252 
00253         // Update particle density or diameter
00254         if (td.constProps().constantVolume())
00255         {
00256             this->rho_ = mass1/this->volume();
00257         }
00258         else
00259         {
00260             this->d_ = cbrt(mass1/this->rho_*6.0/mathematicalConstant::pi);
00261         }
00262     }
00263 }
00264 
00265 
00266 template<class ParcelType>
00267 template<class TrackData>
00268 void Foam::ReactingParcel<ParcelType>::calcPhaseChange
00269 (
00270     TrackData& td,
00271     const scalar dt,
00272     const label cellI,
00273     const scalar d,
00274     const scalar T,
00275     const vector& U,
00276     const scalar mass,
00277     const label idPhase,
00278     const scalar YPhase,
00279     const scalarField& YComponents,
00280     scalarField& dMassPC,
00281     scalar& Sh,
00282     scalar& dhsTrans
00283 )
00284 {
00285     if
00286     (
00287         !td.cloud().phaseChange().active()
00288      || T < td.constProps().Tvap()
00289      || YPhase < SMALL
00290     )
00291     {
00292         return;
00293     }
00294 
00295     // Calculate mass transfer due to phase change
00296     td.cloud().phaseChange().calculate
00297     (
00298         dt,
00299         cellI,
00300         d,
00301         min(T, td.constProps().Tbp()), // Limit to boiling temperature
00302         pc_,
00303         this->Tc_,
00304         this->muc_/(this->rhoc_ + ROOTVSMALL),
00305         U - this->Uc_,
00306         dMassPC
00307     );
00308 
00309     // Limit phase change mass by availability of each specie
00310     dMassPC = min(mass*YPhase*YComponents, dMassPC);
00311 
00312     scalar dMassTot = sum(dMassPC);
00313 
00314     // Add to cumulative phase change mass
00315     td.cloud().addToMassPhaseChange(this->nParticle_*dMassTot);
00316 
00317     // Enthalphy transfer to carrier phase
00318     label id;
00319     forAll(YComponents, i)
00320     {
00321         id = td.cloud().composition().localToGlobalCarrierId(idPhase, i);
00322         const scalar hv = td.cloud().mcCarrierThermo().speciesData()[id].H(T);
00323 
00324         id = td.cloud().composition().globalIds(idPhase)[i];
00325         const scalar hl =
00326             td.cloud().composition().liquids().properties()[id].h(pc_, T);
00327 
00328         Sh += dMassPC[i]*(hl - hv)/dt;
00329     }
00330 }
00331 
00332 
00333 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00334 
00335 template <class ParcelType>
00336 Foam::ReactingParcel<ParcelType>::ReactingParcel
00337 (
00338     const ReactingParcel<ParcelType>& p
00339 )
00340 :
00341     ThermoParcel<ParcelType>(p),
00342     mass0_(p.mass0_),
00343     Y_(p.Y_),
00344     pc_(p.pc_)
00345 {}
00346 
00347 
00348 // * * * * * * * * * * * * * * IOStream operators  * * * * * * * * * * * * * //
00349 
00350 #include "ReactingParcelIO.C"
00351 
00352 // ************************************************************************* //
00353 
Copyright © 2000-2009 OpenCFD Ltd