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

parcel.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 "parcel.H"
00028 
00029 #include "spray.H"
00030 #include "dragModel.H"
00031 #include "evaporationModel.H"
00032 #include "heatTransferModel.H"
00033 #include "wallModel.H"
00034 #include "wallPolyPatch.H"
00035 #include "wedgePolyPatch.H"
00036 #include "processorPolyPatch.H"
00037 #include "basicMultiComponentMixture.H"
00038 
00039 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00040 
00041 namespace Foam
00042 {
00043     defineParticleTypeNameAndDebug(parcel, 0);
00044     defineTemplateTypeNameAndDebug(Cloud<parcel>, 0);
00045 }
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 Foam::parcel::parcel
00050 (
00051     const Cloud<parcel>& cloud,
00052     const vector& position,
00053     const label cellI,
00054     const vector& n,
00055     const scalar d,
00056     const scalar T,
00057     const scalar m,
00058     const scalar y,
00059     const scalar yDot,
00060     const scalar ct,
00061     const scalar ms,
00062     const scalar tTurb,
00063     const scalar liquidCore,
00064     const scalar injector,
00065     const vector& U,
00066     const vector& Uturb,
00067     const scalarField& X,
00068     const List<word>& liquidNames
00069 )
00070 :
00071     Particle<parcel>(cloud, position, cellI),
00072     liquidComponents_
00073     (
00074         liquidNames
00075     ),
00076     d_(d),
00077     T_(T),
00078     m_(m),
00079     y_(y),
00080     yDot_(yDot),
00081     ct_(ct),
00082     ms_(ms),
00083     tTurb_(tTurb),
00084     liquidCore_(liquidCore),
00085     injector_(injector),
00086     U_(U),
00087     Uturb_(Uturb),
00088     n_(n),
00089     X_(X),
00090     tMom_(GREAT)
00091 {}
00092 
00093 
00094 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00095 
00096 bool Foam::parcel::move(spray& sDB)
00097 {
00098     const polyMesh& mesh = cloud().pMesh();
00099     const polyBoundaryMesh& pbMesh = mesh.boundaryMesh();
00100 
00101     const liquidMixture& fuels = sDB.fuels();
00102 
00103     scalar deltaT = sDB.runTime().deltaT().value();
00104     label Nf = fuels.components().size();
00105     label Ns = sDB.composition().Y().size();
00106 
00107     // Calculate the interpolated gas properties at the position of the parcel
00108     vector Up = sDB.UInterpolator().interpolate(position(), cell())
00109         + Uturb();
00110     scalar rhog = sDB.rhoInterpolator().interpolate(position(), cell());
00111     scalar pg = sDB.pInterpolator().interpolate(position(), cell());
00112     scalar Tg = sDB.TInterpolator().interpolate(position(), cell());
00113 
00114     scalarField Yfg(Nf, 0.0);
00115 
00116     scalar cpMixture = 0.0;
00117     for(label i=0; i<Ns; i++)
00118     {
00119         const volScalarField& Yi = sDB.composition().Y()[i];
00120         if (sDB.isLiquidFuel()[i])
00121         {
00122             label j = sDB.gasToLiquidIndex()[i];
00123             scalar Yicelli = Yi[cell()];
00124             Yfg[j] = Yicelli;
00125         }
00126         cpMixture += Yi[cell()]*sDB.gasProperties()[i].Cp(Tg);
00127     }
00128 
00129     // correct the gaseous temperature for evaporated fuel
00130 
00131     scalar cellV = sDB.mesh().V()[cell()];
00132     scalar cellMass = rhog*cellV;
00133     Tg += sDB.shs()[cell()]/(cpMixture*cellMass);
00134     Tg = max(200.0, Tg);
00135 
00136     scalar tauMomentum = GREAT;
00137     scalar tauHeatTransfer = GREAT;
00138     scalarField tauEvaporation(Nf, GREAT);
00139     scalarField tauBoiling(Nf, GREAT);
00140 
00141     bool keepParcel = true;
00142 
00143     setRelaxationTimes
00144     (
00145         cell(),
00146         tauMomentum,
00147         tauEvaporation,
00148         tauHeatTransfer,
00149         tauBoiling,
00150         sDB,
00151         rhog,
00152         Up,
00153         Tg,
00154         pg,
00155         Yfg,
00156         m()*fuels.Y(X()),
00157         deltaT
00158     );
00159 
00160 
00161     // set the end-time for the track
00162     scalar tEnd = (1.0 - stepFraction())*deltaT;
00163 
00164     // set the maximum time step for this parcel
00165     scalar dtMax = min
00166     (
00167         tEnd,
00168         min
00169         (
00170             tauMomentum,
00171             min
00172             (
00173                 1.0e+10*mag(min(tauEvaporation)), // evaporation is not an issue
00174                 min
00175                 (
00176                     mag(tauHeatTransfer),
00177                     mag(min(tauBoiling))
00178                 )
00179             )
00180         )
00181     )/sDB.subCycles();
00182 
00183     // prevent the number of subcycles from being too many
00184     // (10 000 seems high enough)
00185     dtMax = max(dtMax, 1.0e-4*tEnd);
00186 
00187     bool switchProcessor = false;
00188     vector planeNormal = vector::zero;
00189     if (sDB.twoD())
00190     {
00191         planeNormal = n() ^ sDB.axisOfSymmetry();
00192         planeNormal /= mag(planeNormal);
00193     }
00194 
00195     // move the parcel until there is no 'timeLeft'
00196     while (keepParcel && tEnd > SMALL && !switchProcessor)
00197     {
00198         // set the lagrangian time-step
00199         scalar dt = min(dtMax, tEnd);
00200 
00201         // remember which cell the parcel is in
00202         // since this will change if a face is hit
00203         label celli = cell();
00204         scalar p = sDB.p()[celli];
00205 
00206         // track parcel to face, or end of trajectory
00207         if (keepParcel)
00208         {
00209             // Track and adjust the time step if the trajectory is not completed
00210             dt *= trackToFace(position() + dt*U_, sDB);
00211 
00212             // Decrement the end-time acording to how much time the track took
00213             tEnd -= dt;
00214 
00215             // Set the current time-step fraction.
00216             stepFraction() = 1.0 - tEnd/deltaT;
00217 
00218             if (onBoundary()) // hit face
00219             {
00220 #               include "boundaryTreatment.H"
00221             }
00222         }
00223 
00224         if (keepParcel && sDB.twoD())
00225         {
00226             scalar z = position() & sDB.axisOfSymmetry();
00227             vector r = position() - z*sDB.axisOfSymmetry();
00228             if (mag(r) > SMALL)
00229             {
00230                 correctNormal(sDB.axisOfSymmetry());
00231             }
00232         }
00233 
00234         // **** calculate the lagrangian source terms ****
00235         // First we get the 'old' properties.
00236         // and then 'update' them to get the 'new'
00237         // properties.
00238         // The difference is then added to the source terms.
00239 
00240         scalar oRho = fuels.rho(p, T(), X());
00241         scalarField oMass(Nf, 0.0);
00242         scalar oHg = 0.0;
00243         scalar oTotMass = m();
00244         scalarField oYf(fuels.Y(X()));
00245 
00246         forAll(oMass, i)
00247         {
00248             oMass[i] = m()*oYf[i];
00249             label j = sDB.liquidToGasIndex()[i];
00250             oHg += oYf[i]*sDB.gasProperties()[j].H(T());
00251         }
00252 
00253         vector oMom = m()*U();
00254         scalar oHv = fuels.hl(p, T(), X());
00255         scalar oH = oHg - oHv;
00256         scalar oPE = (p - fuels.pv(p, T(), X()))/oRho;
00257 
00258         // update the parcel properties (U, T, D)
00259         updateParcelProperties
00260         (
00261             dt,
00262             sDB,
00263             celli,
00264             face()
00265         );
00266 
00267         scalar nRho = fuels.rho(p, T(), X());
00268         scalar nHg = 0.0;
00269         scalarField nMass(Nf, 0.0);
00270         scalarField nYf(fuels.Y(X()));
00271 
00272         forAll(nMass, i)
00273         {
00274             nMass[i] = m()*nYf[i];
00275             label j = sDB.liquidToGasIndex()[i];
00276             nHg += nYf[i]*sDB.gasProperties()[j].H(T());
00277         }
00278 
00279         vector nMom = m()*U();
00280         scalar nHv = fuels.hl(p, T(), X());
00281         scalar nH = nHg - nHv;
00282         scalar nPE = (p - fuels.pv(p, T(), X()))/nRho;
00283 
00284         // Update the Spray Source Terms
00285         forAll(nMass, i)
00286         {
00287             sDB.srhos()[i][celli] += oMass[i] - nMass[i];
00288         }
00289         sDB.sms()[celli]   += oMom - nMom;
00290 
00291         sDB.shs()[celli]   +=
00292             oTotMass*(oH + oPE)
00293           - m()*(nH + nPE);
00294 
00295         // Remove evaporated mass from stripped mass
00296         ms() -= ms()*(oTotMass-m())/oTotMass;
00297 
00298         // remove parcel if it is 'small'
00299         if (m() < 1.0e-12)
00300         {
00301             keepParcel = false;
00302 
00303             // ... and add the removed 'stuff' to the gas
00304             forAll(nMass, i)
00305             {
00306                 sDB.srhos()[i][celli] += nMass[i];
00307             }
00308 
00309             sDB.sms()[celli] += nMom;
00310             sDB.shs()[celli] += m()*(nH + nPE);
00311         }
00312 
00313         if (onBoundary() && keepParcel)
00314         {
00315             if (face() > -1)
00316             {
00317                 if (isType<processorPolyPatch>(pbMesh[patch(face())]))
00318                 {
00319                     switchProcessor = true;
00320                 }
00321             }
00322         }
00323     }
00324 
00325     return keepParcel;
00326 }
00327 
00328 
00329 void Foam::parcel::updateParcelProperties
00330 (
00331     const scalar dt,
00332     spray& sDB,
00333     const label celli,
00334     const label facei
00335 )
00336 {
00337     const liquidMixture& fuels = sDB.fuels();
00338 
00339     label Nf = sDB.fuels().components().size();
00340     label Ns = sDB.composition().Y().size();
00341 
00342     // calculate mean molecular weight
00343     scalar W = 0.0;
00344     for(label i=0; i<Ns; i++)
00345     {
00346         W += sDB.composition().Y()[i][celli]/sDB.gasProperties()[i].W();
00347 
00348     }
00349     W = 1.0/W;
00350 
00351     // Calculate the interpolated gas properties at the position of the parcel
00352     vector Up = sDB.UInterpolator().interpolate(position(), celli, facei)
00353         + Uturb();
00354     scalar rhog = sDB.rhoInterpolator().interpolate(position(), celli, facei);
00355     scalar pg = sDB.pInterpolator().interpolate(position(), celli, facei);
00356     scalar Tg0 = sDB.TInterpolator().interpolate(position(), celli, facei);
00357 
00358     // correct the gaseous temperature for evaporated fuel
00359     scalar cpMix = 0.0;
00360     for(label i=0; i<Ns; i++)
00361     {
00362         cpMix += sDB.composition().Y()[i][celli]
00363                 *sDB.gasProperties()[i].Cp(T());
00364     }
00365     scalar cellV            = sDB.mesh().V()[celli];
00366     scalar rho              = sDB.rho()[celli];
00367     scalar cellMass         = rho*cellV;
00368     scalar dh               = sDB.shs()[celli];
00369     scalarField addedMass(Nf, 0.0);
00370 
00371     forAll(addedMass, i)
00372     {
00373         addedMass[i] += sDB.srhos()[i][celli]*cellV;
00374     }
00375 
00376     scalar Tg  = Tg0 + dh/(cpMix*cellMass);
00377     Tg = max(200.0, Tg);
00378 
00379     scalarField Yfg(Nf, 0.0);
00380     forAll(Yfg, i)
00381     {
00382         label j = sDB.liquidToGasIndex()[i];
00383         const volScalarField& Yj = sDB.composition().Y()[j];
00384         scalar Yfg0 = Yj[celli];
00385         Yfg[i] = (Yfg0*cellMass + addedMass[i])/(addedMass[i] + cellMass);
00386     }
00387 
00388     scalar tauMomentum     = GREAT;
00389     scalar tauHeatTransfer = GREAT;
00390     scalarField tauEvaporation(Nf, GREAT);
00391     scalarField tauBoiling(Nf, GREAT);
00392 
00393     setRelaxationTimes
00394     (
00395         celli,
00396         tauMomentum,
00397         tauEvaporation,
00398         tauHeatTransfer,
00399         tauBoiling,
00400         sDB,
00401         rhog,
00402         Up,
00403         Tg,
00404         pg,
00405         Yfg,
00406         m()*fuels.Y(X()),
00407         dt
00408     );
00409 
00410     scalar timeRatio = dt/tauMomentum;
00411 
00412     vector Ucorr = Up;
00413     vector gcorr = sDB.g();
00414 
00415     if (sDB.twoD())
00416     {
00417         // remove the tangential velocity component
00418         scalar v1 = Up & sDB.axisOfSymmetry();
00419         scalar v2 = Up & n();
00420         Ucorr     = v1*sDB.axisOfSymmetry() + v2*n();
00421 
00422         // Remove the tangential gravity component
00423         scalar g1 = gcorr & sDB.axisOfSymmetry();
00424         scalar g2 = gcorr & n();
00425         gcorr     = g1*sDB.axisOfSymmetry() + g2*n();
00426     }
00427 
00428     U() = (U() + timeRatio*Ucorr + gcorr*dt)/(1.0 + timeRatio);
00429 
00430     if (sDB.twoD())
00431     {
00432         vector normal = n() ^ sDB.axisOfSymmetry();
00433         normal /= mag(normal);
00434         scalar dU = U() & normal;
00435         U() -= dU*normal;
00436     }
00437 
00438     scalar TDroplet = T();
00439     scalar oldDensity = fuels.rho(pg, T(), X());
00440     scalar oldMass = m();
00441     scalarField Yf0(fuels.Y(X()));
00442     scalarField mi0(m()*Yf0);
00443     scalarField mi(mi0);
00444 
00445     scalar oldhg = 0.0;
00446     for (label i=0; i<Nf; i++)
00447     {
00448         label j = sDB.liquidToGasIndex()[i];
00449         oldhg += Yf0[i]*sDB.gasProperties()[j].H(T());
00450     }
00451 
00452     scalar oldhv = fuels.hl(pg, T(), X());
00453     scalar Np = N(oldDensity);
00454 
00455     scalar newDensity = oldDensity;
00456     scalar newMass    = oldMass;
00457     scalar newhg      = oldhg;
00458     scalar newhv      = oldhv;
00459 
00460     scalar Tnew = T();
00461 
00462     // NN.
00463     // first calculate the new temperature and droplet mass,
00464     // then calculate the energy source and correct the
00465     // gaseous temperature, Tg, and mass fraction, Yfg,
00466     // to calculate the new properties for the parcel
00467     // This procedure seems to be more stable
00468     label n = 0;
00469     while ((n < sDB.evaporation().nEvapIter()) && (m() > VSMALL))
00470     {
00471         n++;
00472         // new characteristic times does not need to be calculated the first time
00473         if (n > 1)
00474         {
00475             newDensity = fuels.rho(pg, Tnew, X());
00476             newMass = m();
00477             newhg = 0.0;
00478             scalarField Ynew(fuels.Y(X()));
00479             for(label i=0; i<Nf; i++)
00480             {
00481                 label j = sDB.liquidToGasIndex()[i];
00482                 newhg += Ynew[i]*sDB.gasProperties()[j].H(Tnew);
00483             }
00484 
00485             newhv = fuels.hl(pg, Tnew, X());
00486 
00487             scalar dm = oldMass - newMass;
00488             scalar dhNew = oldMass*(oldhg-oldhv) - newMass*(newhg-newhv);
00489 
00490             // Prediction of new gaseous temperature and fuel mass fraction
00491             Tg  = Tg0 + (dh+dhNew)/(cpMix*cellMass);
00492             Tg = max(200.0, Tg);
00493 
00494             forAll(Yfg, i)
00495             {
00496                 label j = sDB.liquidToGasIndex()[i];
00497                 const volScalarField& Yj = sDB.composition().Y()[j];
00498                 scalar Yfg0 = Yj[celli];
00499                 Yfg[i] = (Yfg0*cellMass + addedMass[i] + dm)
00500                         /(addedMass[i] + cellMass + dm);
00501             }
00502 
00503             setRelaxationTimes
00504             (
00505                 celli,
00506                 tauMomentum,
00507                 tauEvaporation,
00508                 tauHeatTransfer,
00509                 tauBoiling,
00510                 sDB,
00511                 rhog,
00512                 Up,
00513                 Tg,
00514                 pg,
00515                 Yfg,
00516                 m()*fuels.Y(X()),
00517                 dt
00518             );
00519 
00520         }
00521 
00522         scalar Taverage = TDroplet + (Tg - TDroplet)/3.0;
00523         // for a liquid Cl \approx Cp
00524         scalar liquidcL = sDB.fuels().cp(pg, TDroplet, X());
00525 
00526         cpMix = 0.0;
00527         for(label i=0; i<Ns; i++)
00528         {
00529             if (sDB.isLiquidFuel()[i])
00530             {
00531                 label j = sDB.gasToLiquidIndex()[i];
00532                 cpMix += Yfg[j]*sDB.gasProperties()[i].Cp(Taverage);
00533             }
00534             else
00535             {
00536                 scalar Y = sDB.composition().Y()[i][celli];
00537                 cpMix += Y*sDB.gasProperties()[i].Cp(Taverage);
00538             }
00539         }
00540 
00541         scalar evaporationSource = 0.0;
00542         scalar z = 0.0;
00543         scalar tauEvap = 0.0;
00544 
00545         for(label i=0; i<Nf; i++)
00546         {
00547             tauEvap += X()[i]*fuels.properties()[i].W()/tauEvaporation[i];
00548         }
00549         tauEvap = fuels.W(X())/tauEvap;
00550 
00551 
00552         if (sDB.evaporation().evaporation())
00553         {
00554             scalar hv = fuels.hl(pg, TDroplet, X());
00555             evaporationSource =
00556                 hv/liquidcL/tauEvap;
00557 
00558             z = cpMix*tauHeatTransfer/liquidcL/tauEvap;
00559         }
00560 
00561         if (sDB.heatTransfer().heatTransfer())
00562         {
00563             scalar fCorrect =
00564                 sDB.heatTransfer().fCorrection(z)/tauHeatTransfer;
00565 
00566             Tnew =
00567                 (TDroplet + dt*(fCorrect * Tg - evaporationSource))
00568                 /(1.0 + dt*fCorrect);
00569 
00570             // Prevent droplet temperature to go above critial value
00571             Tnew = min(Tnew, fuels.Tc(X()));
00572 
00573             // Prevent droplet temperature to go too low
00574             // Mainly a numerical stability issue
00575             Tnew = max(200.0, Tnew);
00576             scalar Td = Tnew;
00577 
00578             scalar pAtSurface = fuels.pv(pg, Td, X());
00579             scalar pCompare = 0.999*pg;
00580             scalar boiling = pAtSurface >= pCompare;
00581             if (boiling)
00582             {
00583                 // can not go above boiling temperature
00584                 scalar Terr = 1.0e-3;
00585                 label n=0;
00586                 scalar dT = 1.0;
00587                 scalar pOld = pAtSurface;
00588                 while (dT > Terr)
00589                 {
00590                     n++;
00591                     pAtSurface = fuels.pv(pg, Td, X());
00592                     if ((pAtSurface < pCompare) && (pOld < pCompare))
00593                     {
00594                         Td += dT;
00595                     }
00596                     else
00597                     {
00598                         if ((pAtSurface > pCompare) && (pOld > pCompare))
00599                         {
00600                             Td -= dT;
00601                         }
00602                         else
00603                         {
00604                             dT *= 0.5;
00605                             if ((pAtSurface > pCompare) && (pOld < pCompare))
00606                             {
00607                                 Td -= dT;
00608                             }
00609                             else
00610                             {
00611                                 Td += dT;
00612                             }
00613                         }
00614                     }
00615                     pOld = pAtSurface;
00616                     if (debug)
00617                     {
00618                         if (n>100)
00619                         {
00620                             Info << "n = " << n << ", T = " << Td << ", pv = " << pAtSurface << endl;
00621                         }
00622                     }
00623                 }
00624                 Tnew = Td;
00625             }
00626         }
00627 
00628         // Evaporate droplet!
00629         // if the droplet is NOT boiling use implicit scheme.
00630         if (sDB.evaporation().evaporation())
00631         {
00632             for(label i=0; i<Nf; i++)
00633             {
00634                 // immediately evaporate mass that has reached critical
00635                 // condition
00636                 if (mag(Tnew - fuels.Tc(X())) < SMALL)
00637                 {
00638                     mi[i] = 0.0;
00639                 }
00640                 else
00641                 {
00642                     scalar Td = min(Tnew, 0.999*fuels.properties()[i].Tc());
00643 
00644                     scalar pAtSurface = fuels.properties()[i].pv(pg, Td);
00645                     scalar boiling = pAtSurface >= 0.999*pg;
00646 
00647                     if (!boiling)
00648                     {
00649                         scalar fr = dt/tauEvaporation[i];
00650                         mi[i] = mi0[i]/(1.0 + fr);
00651                     }
00652                     else
00653                     {
00654                         scalar fr = dt/tauBoiling[i];
00655                         mi[i] = mi0[i]/(1.0 + fr);
00656                     }
00657                 }
00658             }
00659 
00660             scalar mTot = sum(mi);
00661             if (mTot > VSMALL)
00662             {
00663                 scalarField Ynew(mi/mTot);
00664                 scalarField Xnew(sDB.fuels().X(Ynew));
00665                 forAll(Xnew, i)
00666                 {
00667                     X()[i] = Xnew[i];
00668                 }
00669                 m() = mTot;
00670             }
00671             else
00672             {
00673                 m() = 0.0;
00674             }
00675         }
00676         T() = Tnew;
00677         scalar rhod = fuels.rho(pg, T(), X());
00678         d() = cbrt(6.0*m()/(Np*rhod*M_PI));
00679     }
00680 
00681     T() = Tnew;
00682     scalar rhod = fuels.rho(pg, T(), X());
00683     m() = sum(mi);
00684     d() = cbrt(6.0*m()/(Np*rhod*M_PI));
00685 }
00686 
00687 
00688 void Foam::parcel::transformProperties(const tensor& T)
00689 {
00690     U_ = transform(T, U_);
00691 }
00692 
00693 
00694 void Foam::parcel::transformProperties(const vector&)
00695 {}
00696 
00697 
00698 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd