FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

COxidationMurphyShaddix.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "COxidationMurphyShaddix.H"
00027 #include <OpenFOAM/mathematicalConstants.H>
00028 
00029 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00030 
00031 template<class CloudType>
00032 Foam::label Foam::COxidationMurphyShaddix<CloudType>::maxIters_ = 1000;
00033 
00034 template<class CloudType>
00035 Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::tolerance_ = 1e-06;
00036 
00037 
00038 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00039 
00040 template<class CloudType>
00041 Foam::COxidationMurphyShaddix<CloudType>::COxidationMurphyShaddix
00042 (
00043     const dictionary& dict,
00044     CloudType& owner
00045 )
00046 :
00047     SurfaceReactionModel<CloudType>
00048     (
00049         dict,
00050         owner,
00051         typeName
00052     ),
00053     D0_(dimensionedScalar(this->coeffDict().lookup("D0")).value()),
00054     rho0_(dimensionedScalar(this->coeffDict().lookup("rho0")).value()),
00055     T0_(dimensionedScalar(this->coeffDict().lookup("T0")).value()),
00056     Dn_(dimensionedScalar(this->coeffDict().lookup("Dn")).value()),
00057     A_(dimensionedScalar(this->coeffDict().lookup("A")).value()),
00058     E_(dimensionedScalar(this->coeffDict().lookup("E")).value()),
00059     n_(dimensionedScalar(this->coeffDict().lookup("n")).value()),
00060     WVol_(dimensionedScalar(this->coeffDict().lookup("WVol")).value()),
00061     CsLocalId_(-1),
00062     O2GlobalId_(owner.composition().globalCarrierId("O2")),
00063     CO2GlobalId_(owner.composition().globalCarrierId("CO2")),
00064     WC_(0.0),
00065     WO2_(0.0)
00066 {
00067     // Determine Cs ids
00068     label idSolid = owner.composition().idSolid();
00069     CsLocalId_ = owner.composition().localId(idSolid, "C");
00070 
00071     // Set local copies of thermo properties
00072     WO2_ = owner.mcCarrierThermo().speciesData()[O2GlobalId_].W();
00073     scalar WCO2 = owner.mcCarrierThermo().speciesData()[CO2GlobalId_].W();
00074     WC_ = WCO2 - WO2_;
00075 }
00076 
00077 
00078 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00079 
00080 template<class CloudType>
00081 Foam::COxidationMurphyShaddix<CloudType>::~COxidationMurphyShaddix()
00082 {}
00083 
00084 
00085 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00086 
00087 template<class CloudType>
00088 bool Foam::COxidationMurphyShaddix<CloudType>::active() const
00089 {
00090     return true;
00091 }
00092 
00093 
00094 template<class CloudType>
00095 Foam::scalar Foam::COxidationMurphyShaddix<CloudType>::calculate
00096 (
00097     const scalar dt,
00098     const label cellI,
00099     const scalar d,
00100     const scalar T,
00101     const scalar Tc,
00102     const scalar pc,
00103     const scalar rhoc,
00104     const scalar mass,
00105     const scalarField& YGas,
00106     const scalarField& YLiquid,
00107     const scalarField& YSolid,
00108     const scalarField& YMixture,
00109     const scalar N,
00110     scalarField& dMassGas,
00111     scalarField& dMassLiquid,
00112     scalarField& dMassSolid,
00113     scalarField& dMassSRCarrier
00114 ) const
00115 {
00116     // Fraction of remaining combustible material
00117     const label idSolid = CloudType::parcelType::SLD;
00118     const scalar fComb = YMixture[idSolid]*YSolid[CsLocalId_];
00119 
00120     // Surface combustion until combustible fraction is consumed
00121     if (fComb < SMALL)
00122     {
00123         return 0.0;
00124     }
00125 
00126     // Cell carrier phase O2 species density [kg/m^3]
00127     const scalar rhoO2 =
00128         rhoc*this->owner().mcCarrierThermo().Y(O2GlobalId_)[cellI];
00129 
00130     if (rhoO2 < SMALL)
00131     {
00132         return 0.0;
00133     }
00134 
00135     // Particle surface area [m^2]
00136     const scalar Ap = mathematicalConstant::pi*sqr(d);
00137 
00138     // Calculate diffision constant at continuous phase temperature
00139     // and density [m^2/s]
00140     const scalar D = D0_*(rho0_/rhoc)*pow(Tc/T0_, Dn_);
00141 
00142     // Far field partial pressure O2 [Pa]
00143     const scalar ppO2 = rhoO2/WO2_*specie::RR*Tc;
00144 
00145     // Total molar concentration of the carrier phase [kmol/m^3]
00146     const scalar C = pc/(specie::RR*Tc);
00147 
00148     if (debug)
00149     {
00150         Pout<< "mass  = " << mass << nl
00151             << "fComb = " << fComb << nl
00152             << "Ap    = " << Ap << nl
00153             << "dt    = " << dt << nl
00154             << "C     = " << C << nl
00155             << endl;
00156     }
00157 
00158     // Molar reaction rate per unit surface area [kmol/(m^2.s)]
00159     scalar qCsOld = 0;
00160     scalar qCs = 1;
00161 
00162     const scalar qCsLim = mass*fComb/(WC_*Ap*dt);
00163 
00164     if (debug)
00165     {
00166         Pout << "qCsLim = " << qCsLim << endl;
00167     }
00168 
00169     label iter = 0;
00170     while ((mag(qCs - qCsOld)/qCs > tolerance_) && (iter <= maxIters_))
00171     {
00172         qCsOld = qCs;
00173         const scalar PO2Surface = ppO2*exp(-(qCs + N)*d/(2*C*D));
00174         qCs = A_*exp(-E_/(specie::RR*T))*pow(PO2Surface, n_);
00175         qCs = (100.0*qCs + iter*qCsOld)/(100.0 + iter);
00176         qCs = min(qCs, qCsLim);
00177 
00178         if (debug)
00179         {
00180             Pout<< "iter = " << iter
00181                 << ", qCsOld = " << qCsOld
00182                 << ", qCs = " << qCs
00183                 << nl << endl;
00184         }
00185 
00186         iter++;
00187     }
00188 
00189     if (iter > maxIters_)
00190     {
00191         WarningIn
00192         (
00193             "scalar Foam::COxidationMurphyShaddix<CloudType>::calculate(...)"
00194         )   << "iter limit reached (" << maxIters_ << ")" << nl << endl;
00195     }
00196 
00197     // Calculate the number of molar units reacted
00198     scalar dOmega = qCs*Ap*dt;
00199 
00200     // Add to carrier phase mass transfer
00201     dMassSRCarrier[O2GlobalId_] += -dOmega*WO2_;
00202     dMassSRCarrier[CO2GlobalId_] += dOmega*(WC_ + WO2_);
00203 
00204     // Add to particle mass transfer
00205     dMassSolid[CsLocalId_] += dOmega*WC_;
00206 
00207     const scalar HC =
00208         this->owner().composition().solids().properties()[CsLocalId_].Hf()
00209       + this->owner().composition().solids().properties()[CsLocalId_].cp()*T;
00210     const scalar HCO2 =
00211         this->owner().mcCarrierThermo().speciesData()[CO2GlobalId_].H(T);
00212     const scalar HO2 =
00213         this->owner().mcCarrierThermo().speciesData()[O2GlobalId_].H(T);
00214 
00215     // Heat of reaction
00216     return dOmega*(WC_*HC + WO2_*HO2 - (WC_ + WO2_)*HCO2);
00217 }
00218 
00219 
00220 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines