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

ReactingMultiphaseParcel.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) 2008-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 "ReactingMultiphaseParcel.H"
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 template<class ParcelType>
00032 const Foam::label Foam::ReactingMultiphaseParcel<ParcelType>::GAS(0);
00033 
00034 template<class ParcelType>
00035 const Foam::label Foam::ReactingMultiphaseParcel<ParcelType>::LIQ(1);
00036 
00037 template<class ParcelType>
00038 const Foam::label Foam::ReactingMultiphaseParcel<ParcelType>::SLD(2);
00039 
00040 
00041 // * * * * * * * * * * * *  Private Member Functions * * * * * * * * * * * * //
00042 
00043 template<class ParcelType>
00044 template<class TrackData>
00045 Foam::scalar Foam::ReactingMultiphaseParcel<ParcelType>::cpEff
00046 (
00047     TrackData& td,
00048     const scalar p,
00049     const scalar T,
00050     const label idG,
00051     const label idL,
00052     const label idS
00053 ) const
00054 {
00055     return
00056         this->Y_[GAS]*td.cloud().composition().cp(idG, YGas_, p, T)
00057       + this->Y_[LIQ]*td.cloud().composition().cp(idL, YLiquid_, p, T)
00058       + this->Y_[SLD]*td.cloud().composition().cp(idS, YSolid_, p, T);
00059 }
00060 
00061 
00062 template<class ParcelType>
00063 template<class TrackData>
00064 Foam::scalar Foam::ReactingMultiphaseParcel<ParcelType>::HEff
00065 (
00066     TrackData& td,
00067     const scalar p,
00068     const scalar T,
00069     const label idG,
00070     const label idL,
00071     const label idS
00072 ) const
00073 {
00074     return
00075         this->Y_[GAS]*td.cloud().composition().H(idG, YGas_, p, T)
00076       + this->Y_[LIQ]*td.cloud().composition().H(idL, YLiquid_, p, T)
00077       + this->Y_[SLD]*td.cloud().composition().H(idS, YSolid_, p, T);
00078 }
00079 
00080 
00081 template<class ParcelType>
00082 template<class TrackData>
00083 Foam::scalar Foam::ReactingMultiphaseParcel<ParcelType>::LEff
00084 (
00085     TrackData& td,
00086     const scalar p,
00087     const scalar T,
00088     const label idG,
00089     const label idL,
00090     const label idS
00091 ) const
00092 {
00093     return
00094         this->Y_[GAS]*td.cloud().composition().L(idG, YGas_, p, T)
00095       + this->Y_[LIQ]*td.cloud().composition().L(idL, YLiquid_, p, T)
00096       + this->Y_[SLD]*td.cloud().composition().L(idS, YSolid_, p, T);
00097 }
00098 
00099 
00100 template<class ParcelType>
00101 Foam::scalar Foam::ReactingMultiphaseParcel<ParcelType>::updateMassFractions
00102 (
00103     const scalar mass0,
00104     const scalarField& dMassGas,
00105     const scalarField& dMassLiquid,
00106     const scalarField& dMassSolid
00107 )
00108 {
00109     scalarField& YMix = this->Y_;
00110 
00111     scalar massGas =
00112         this->updateMassFraction(mass0*YMix[GAS], dMassGas, YGas_);
00113     scalar massLiquid =
00114         this->updateMassFraction(mass0*YMix[LIQ], dMassLiquid, YLiquid_);
00115     scalar massSolid =
00116         this->updateMassFraction(mass0*YMix[SLD], dMassSolid, YSolid_);
00117 
00118     scalar massNew = max(massGas + massLiquid + massSolid, ROOTVSMALL);
00119 
00120     YMix[GAS] = massGas/massNew;
00121     YMix[LIQ] = massLiquid/massNew;
00122     YMix[SLD] = 1.0 - YMix[GAS] - YMix[LIQ];
00123 
00124     return massNew;
00125 }
00126 
00127 
00128 // * * * * * * * * * * *  Protected Member Functions * * * * * * * * * * * * //
00129 
00130 template<class ParcelType>
00131 template<class TrackData>
00132 void Foam::ReactingMultiphaseParcel<ParcelType>::setCellValues
00133 (
00134     TrackData& td,
00135     const scalar dt,
00136     const label cellI
00137 )
00138 {
00139     ReactingParcel<ParcelType>::setCellValues(td, dt, cellI);
00140 }
00141 
00142 
00143 template<class ParcelType>
00144 template<class TrackData>
00145 void Foam::ReactingMultiphaseParcel<ParcelType>::cellValueSourceCorrection
00146 (
00147     TrackData& td,
00148     const scalar dt,
00149     const label cellI
00150 )
00151 {
00152     scalar massCell = this->massCell(cellI);
00153 
00154     scalar addedMass = 0.0;
00155     forAll(td.cloud().rhoTrans(), i)
00156     {
00157         addedMass += td.cloud().rhoTrans(i)[cellI];
00158     }
00159 
00160     this->rhoc_ += addedMass/td.cloud().pMesh().cellVolumes()[cellI];
00161 
00162     scalar massCellNew = massCell + addedMass;
00163     this->Uc_ += td.cloud().UTrans()[cellI]/massCellNew;
00164 
00165     scalar cpEff = 0;
00166     if (addedMass > ROOTVSMALL)
00167     {
00168         forAll(td.cloud().rhoTrans(), i)
00169         {
00170             scalar Y = td.cloud().rhoTrans(i)[cellI]/addedMass;
00171             cpEff +=
00172                 Y*td.cloud().mcCarrierThermo().speciesData()[i].Cp(this->Tc_);
00173         }
00174     }
00175     const scalar cpc = td.cpInterp().psi()[cellI];
00176     this->cpc_ = (massCell*cpc + addedMass*cpEff)/massCellNew;
00177 
00178     this->Tc_ += td.cloud().hsTrans()[cellI]/(this->cpc_*massCellNew);
00179 }
00180 
00181 
00182 template<class ParcelType>
00183 template<class TrackData>
00184 void Foam::ReactingMultiphaseParcel<ParcelType>::calc
00185 (
00186     TrackData& td,
00187     const scalar dt,
00188     const label cellI
00189 )
00190 {
00191     // Define local properties at beginning of timestep
00192     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00193     const scalar np0 = this->nParticle_;
00194     const scalar d0 = this->d_;
00195     const vector& U0 = this->U_;
00196     const scalar rho0 = this->rho_;
00197     const scalar T0 = this->T_;
00198     const scalar cp0 = this->cp_;
00199     const scalar mass0 = this->mass();
00200 
00201     const scalar pc = this->pc_;
00202 
00203     const scalarField& YMix = this->Y_;
00204     const label idG = td.cloud().composition().idGas();
00205     const label idL = td.cloud().composition().idLiquid();
00206     const label idS = td.cloud().composition().idSolid();
00207 
00208     // Explicit momentum source for particle
00209     vector Su = vector::zero;
00210 
00211     // Momentum transfer from the particle to the carrier phase
00212     vector dUTrans = vector::zero;
00213 
00214     // Explicit enthalpy source for particle
00215     scalar Sh = 0.0;
00216 
00217     // Sensible enthalpy transfer from the particle to the carrier phase
00218     scalar dhsTrans = 0.0;
00219 
00220 
00221     // Devolatilisation
00222     // ~~~~~~~~~~~~~~~~
00223 
00224     // Mass transfer due to devolatilisation
00225     scalarField dMassDV(YGas_.size(), 0.0);
00226 
00227     // Calc mass and enthalpy transfer due to devolatilisation
00228     calcDevolatilisation
00229     (
00230         td,
00231         dt,
00232         T0,
00233         mass0,
00234         this->mass0_,
00235         idG,
00236         YMix[GAS],
00237         YGas_,
00238         canCombust_,
00239         dMassDV,
00240         Sh,
00241         dhsTrans
00242     );
00243 
00244 
00245     // Surface reactions
00246     // ~~~~~~~~~~~~~~~~~
00247 
00248     // Change in carrier phase composition due to surface reactions
00249     scalarField dMassSRGas(YGas_.size(), 0.0);
00250     scalarField dMassSRLiquid(YLiquid_.size(), 0.0);
00251     scalarField dMassSRSolid(YSolid_.size(), 0.0);
00252     scalarField
00253         dMassSRCarrier
00254         (
00255             td.cloud().mcCarrierThermo().species().size(),
00256             0.0
00257         );
00258 
00259     // Clac mass and enthalpy transfer due to surface reactions
00260     calcSurfaceReactions
00261     (
00262         td,
00263         dt,
00264         cellI,
00265         d0,
00266         T0,
00267         mass0,
00268         canCombust_,
00269         dMassDV,    // assuming d(mass) due to phase change is non-volatile
00270         YMix,
00271         YGas_,
00272         YLiquid_,
00273         YSolid_,
00274         dMassSRGas,
00275         dMassSRLiquid,
00276         dMassSRSolid,
00277         dMassSRCarrier,
00278         Sh,
00279         dhsTrans
00280     );
00281 
00282 
00283     // Phase change in liquid phase
00284     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00285 
00286     // Mass transfer due to phase change
00287     scalarField dMassPC(YLiquid_.size(), 0.0);
00288 
00289     // Calc mass and enthalpy transfer due to phase change
00290     calcPhaseChange
00291     (
00292         td,
00293         dt,
00294         cellI,
00295         d0,
00296         T0,
00297         U0,
00298         mass0,
00299         idL,
00300         YMix[LIQ],
00301         YLiquid_,
00302         dMassPC,
00303         Sh,
00304         dhsTrans
00305     );
00306 
00307 
00308     // Update component mass fractions
00309     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00310 
00311     scalarField dMassGas = dMassDV + dMassSRGas;
00312     scalarField dMassLiquid = dMassPC + dMassSRLiquid;
00313     scalarField dMassSolid = dMassSRSolid;
00314 
00315     scalar mass1 =
00316         updateMassFractions(mass0, dMassGas, dMassLiquid, dMassSolid);
00317 
00318 
00319     // Heat transfer
00320     // ~~~~~~~~~~~~~
00321 
00322     // Calculate new particle temperature
00323     scalar T1 =
00324         calcHeatTransfer(td, dt, cellI, d0, U0, rho0, T0, cp0, Sh, dhsTrans);
00325 
00326 
00327     // Motion
00328     // ~~~~~~
00329 
00330     // Calculate new particle velocity
00331     vector U1 = calcVelocity(td, dt, cellI, d0, U0, rho0, mass0, Su, dUTrans);
00332 
00333     dUTrans += 0.5*(mass0 - mass1)*(U0 + U1);
00334 
00335 
00336     // Accumulate carrier phase source terms
00337     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00338 
00339     if (td.cloud().coupled())
00340     {
00341         // Transfer mass lost from particle to carrier mass source
00342         forAll(YGas_, i)
00343         {
00344             label gid = td.cloud().composition().localToGlobalCarrierId(GAS, i);
00345             td.cloud().rhoTrans(gid)[cellI] += np0*dMassGas[i];
00346             td.cloud().hcTrans()[cellI] +=
00347                 np0
00348                *dMassGas[i]
00349                *td.cloud().mcCarrierThermo().speciesData()[gid].H(T0);
00350         }
00351         forAll(YLiquid_, i)
00352         {
00353             label gid = td.cloud().composition().localToGlobalCarrierId(LIQ, i);
00354             td.cloud().rhoTrans(gid)[cellI] += np0*dMassLiquid[i];
00355             td.cloud().hcTrans()[cellI] +=
00356                 np0
00357                *dMassLiquid[i]
00358                *td.cloud().mcCarrierThermo().speciesData()[gid].H(T0);
00359         }
00360 /*
00361         // No mapping between solid components and carrier phase
00362         forAll(YSolid_, i)
00363         {
00364             label gid = td.cloud().composition().localToGlobalCarrierId(SLD, i);
00365             td.cloud().rhoTrans(gid)[cellI] += np0*dMassSolid[i];
00366             td.cloud().hcTrans()[cellI] +=
00367                 np0
00368                *dMassSolid[i]
00369                *td.cloud().mcCarrierThermo().speciesData()[gid].H(T0);
00370         }
00371 */
00372         forAll(dMassSRCarrier, i)
00373         {
00374             td.cloud().rhoTrans(i)[cellI] += np0*dMassSRCarrier[i];
00375             td.cloud().hcTrans()[cellI] +=
00376                 np0
00377                *dMassSRCarrier[i]
00378                *td.cloud().mcCarrierThermo().speciesData()[i].H(T0);
00379         }
00380 
00381         // Update momentum transfer
00382         td.cloud().UTrans()[cellI] += np0*dUTrans;
00383 
00384         // Update sensible enthalpy transfer
00385         td.cloud().hsTrans()[cellI] += np0*dhsTrans;
00386     }
00387 
00388 
00389     // Remove the particle when mass falls below minimum threshold
00390     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00391 
00392     if (mass1 < td.constProps().minParticleMass())
00393     {
00394         td.keepParticle = false;
00395 
00396         if (td.cloud().coupled())
00397         {
00398             // Absorb parcel into carrier phase
00399             forAll(YGas_, i)
00400             {
00401                 label gid =
00402                     td.cloud().composition().localToGlobalCarrierId(GAS, i);
00403                 td.cloud().rhoTrans(gid)[cellI] += np0*mass1*YMix[GAS]*YGas_[i];
00404             }
00405             forAll(YLiquid_, i)
00406             {
00407                 label gid =
00408                     td.cloud().composition().localToGlobalCarrierId(LIQ, i);
00409                 td.cloud().rhoTrans(gid)[cellI] +=
00410                     np0*mass1*YMix[LIQ]*YLiquid_[i];
00411             }
00412 /*
00413             // No mapping between solid components and carrier phase
00414             forAll(YSolid_, i)
00415             {
00416                 label gid =
00417                     td.cloud().composition().localToGlobalCarrierId(SLD, i);
00418                 td.cloud().rhoTrans(gid)[cellI] +=
00419                     np0*mass1*YMix[SLD]*YSolid_[i];
00420             }
00421 */
00422             td.cloud().UTrans()[cellI] += np0*mass1*U1;
00423             td.cloud().hsTrans()[cellI] +=
00424                 np0*mass1*HEff(td, pc, T1, idG, idL, idS);
00425         }
00426     }
00427 
00428 
00429     // Set new particle properties
00430     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
00431 
00432     else
00433     {
00434         this->cp_ = cpEff(td, pc, T1, idG, idL, idS);
00435         this->T_ = T1;
00436         this->U_ = U1;
00437 
00438         // Update particle density or diameter
00439         if (td.constProps().constantVolume())
00440         {
00441             this->rho_ = mass1/this->volume();
00442         }
00443         else
00444         {
00445             this->d_ = cbrt(mass1/this->rho_*6.0/mathematicalConstant::pi);
00446         }
00447     }
00448 }
00449 
00450 
00451 template<class ParcelType>
00452 template<class TrackData>
00453 void Foam::ReactingMultiphaseParcel<ParcelType>::calcDevolatilisation
00454 (
00455     TrackData& td,
00456     const scalar dt,
00457     const scalar T,
00458     const scalar mass,
00459     const scalar mass0,
00460     const label idVolatile,
00461     const scalar YVolatileTot,
00462     const scalarField& YVolatile,
00463     bool& canCombust,
00464     scalarField& dMassDV,
00465     scalar& Sh,
00466     scalar& dhsTrans
00467 ) const
00468 {
00469     // Check that model is active, and that the parcel temperature is
00470     // within necessary limits for devolatilisation to occur
00471     if
00472     (
00473         !td.cloud().devolatilisation().active()
00474      || T < td.constProps().Tvap()
00475     )
00476     {
00477         return;
00478     }
00479 
00480     // Total mass of volatiles evolved
00481     const scalar dMassTot = td.cloud().devolatilisation().calculate
00482     (
00483         dt,
00484         mass0,
00485         mass,
00486         T,
00487         td.cloud().composition().YMixture0()[idVolatile],
00488         YVolatileTot,
00489         canCombust
00490     );
00491 
00492     // Volatile mass transfer - equal components of each volatile specie
00493     dMassDV = YVolatile*dMassTot;
00494 
00495     td.cloud().addToMassDevolatilisation(this->nParticle_*dMassTot);
00496 
00497     Sh -= dMassTot*td.constProps().LDevol()/dt;
00498 }
00499 
00500 
00501 template<class ParcelType>
00502 template<class TrackData>
00503 void Foam::ReactingMultiphaseParcel<ParcelType>::calcSurfaceReactions
00504 (
00505     TrackData& td,
00506     const scalar dt,
00507     const label cellI,
00508     const scalar d,
00509     const scalar T,
00510     const scalar mass,
00511     const bool canCombust,
00512     const scalarField& dMassVolatile,
00513     const scalarField& YMix,
00514     const scalarField& YGas,
00515     const scalarField& YLiquid,
00516     const scalarField& YSolid,
00517     scalarField& dMassSRGas,
00518     scalarField& dMassSRLiquid,
00519     scalarField& dMassSRSolid,
00520     scalarField& dMassSRCarrier,
00521     scalar& Sh,
00522     scalar& dhsTrans
00523 ) const
00524 {
00525     // Check that model is active
00526     if (!td.cloud().surfaceReaction().active() || !canCombust)
00527     {
00528         return;
00529     }
00530 
00531     // Update surface reactions
00532     const scalar hReaction = td.cloud().surfaceReaction().calculate
00533     (
00534         dt,
00535         cellI,
00536         d,
00537         T,
00538         this->Tc_,
00539         this->pc_,
00540         this->rhoc_,
00541         mass,
00542         YGas,
00543         YLiquid,
00544         YSolid,
00545         YMix,
00546         dMassVolatile,
00547         dMassSRGas,
00548         dMassSRLiquid,
00549         dMassSRSolid,
00550         dMassSRCarrier
00551     );
00552 
00553     td.cloud().addToMassSurfaceReaction
00554     (
00555         this->nParticle_
00556        *(sum(dMassSRGas) + sum(dMassSRLiquid) + sum(dMassSRSolid))
00557     );
00558 
00559     const scalar xsi = min(T/5000.0, 1.0);
00560     const scalar hRetentionCoeffMod =
00561         (1.0 - xsi*xsi)*td.constProps().hRetentionCoeff();
00562 
00563     Sh += hRetentionCoeffMod *hReaction/dt;
00564 
00565     dhsTrans += (1.0 - hRetentionCoeffMod)*hReaction;
00566 }
00567 
00568 
00569 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00570 
00571 template <class ParcelType>
00572 Foam::ReactingMultiphaseParcel<ParcelType>::ReactingMultiphaseParcel
00573 (
00574     const ReactingMultiphaseParcel<ParcelType>& p
00575 )
00576 :
00577     ReactingParcel<ParcelType>(p),
00578     YGas_(p.YGas_),
00579     YLiquid_(p.YLiquid_),
00580     YSolid_(p.YSolid_)
00581 {}
00582 
00583 
00584 // * * * * * * * * * * * * * * IOStream operators  * * * * * * * * * * * * * //
00585 
00586 #include "ReactingMultiphaseParcelIO.C"
00587 
00588 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd