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

wideBandAbsorptionEmission.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 "wideBandAbsorptionEmission.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     namespace radiation
00035     {
00036         defineTypeNameAndDebug(wideBandAbsorptionEmission, 0);
00037 
00038         addToRunTimeSelectionTable
00039         (
00040             absorptionEmissionModel,
00041             wideBandAbsorptionEmission,
00042             dictionary
00043         );
00044     }
00045 }
00046 
00047 
00048 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00049 
00050 Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
00051 (
00052     const dictionary& dict,
00053     const fvMesh& mesh
00054 )
00055 :
00056     absorptionEmissionModel(dict, mesh),
00057     coeffsDict_((dict.subDict(typeName + "Coeffs"))),
00058     speciesNames_(0),
00059     specieIndex_(0),
00060     lookUpTable_
00061     (
00062         fileName(coeffsDict_.lookup("lookUpTableFileName")),
00063         mesh.time().constant(),
00064         mesh
00065     ),
00066     thermo_(mesh.lookupObject<basicThermo>("thermophysicalProperties")),
00067     Yj_(nSpecies_),
00068     totalWaveLength_(0)
00069 {
00070     label nBand = 0;
00071     const dictionary& functionDicts = dict.subDict(typeName +"Coeffs");
00072     forAllConstIter(dictionary, functionDicts, iter)
00073     {
00074         // safety:
00075         if (!iter().isDict())
00076         {
00077             continue;
00078         }
00079 
00080         const dictionary& dict = iter().dict();
00081         dict.lookup("bandLimits") >> iBands_[nBand];
00082         dict.lookup("EhrrCoeff") >> iEhrrCoeffs_[nBand];
00083         totalWaveLength_ += iBands_[nBand][1] - iBands_[nBand][0];
00084 
00085         label nSpec = 0;
00086         const dictionary& specDicts = dict.subDict("species");
00087         forAllConstIter(dictionary, specDicts, iter)
00088         {
00089             const word& key = iter().keyword();
00090             if (nBand == 0)
00091             {
00092                 speciesNames_.insert(key, nSpec);
00093             }
00094             else
00095             {
00096                 if (!speciesNames_.found(key))
00097                 {
00098                     FatalErrorIn
00099                     (
00100                         "Foam::radiation::wideBandAbsorptionEmission(const"
00101                         "dictionary& dict, const fvMesh& mesh)"
00102                     )   << "specie: " << key << "is not in all the bands"
00103                         << nl << exit(FatalError);
00104                 }
00105             }
00106             coeffs_[nSpec][nBand].initialise(specDicts.subDict(key));
00107             nSpec++;
00108         }
00109         nBand++;
00110     }
00111     nBands_ = nBand;
00112 
00113     // Check that all the species on the dictionary are present in the
00114     // look-up table  and save the corresponding indices of the look-up table
00115 
00116     label j = 0;
00117     forAllConstIter(HashTable<label>, speciesNames_, iter)
00118     {
00119         if (lookUpTable_.found(iter.key()))
00120         {
00121             label index = lookUpTable_.findFieldIndex(iter.key());
00122             Info<< "specie: " << iter.key() << " found in look-up table "
00123                 << " with index: " << index << endl;
00124             specieIndex_[iter()] = index;
00125         }
00126         else if (mesh.foundObject<volScalarField>(iter.key()))
00127         {
00128             volScalarField& Y = const_cast<volScalarField&>
00129                 (mesh.lookupObject<volScalarField>(iter.key()));
00130 
00131             Yj_.set(j, &Y);
00132 
00133             specieIndex_[iter()] = 0.0;
00134             j++;
00135             Info<< "species: " << iter.key() << " is being solved" << endl;
00136         }
00137         else
00138         {
00139             FatalErrorIn
00140             (
00141                 "radiation::wideBandAbsorptionEmission(const"
00142                 "dictionary& dict, const fvMesh& mesh)"
00143             )   << "specie: " << iter.key()
00144                 << " is neither in look-up table : "
00145                 << lookUpTable_.tableName() << " nor is being solved"
00146                 << exit(FatalError);
00147         }
00148     }
00149 }
00150 
00151 
00152 
00153 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00154 
00155 Foam::radiation::wideBandAbsorptionEmission::~wideBandAbsorptionEmission()
00156 {}
00157 
00158 
00159 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00160 
00161 Foam::tmp<Foam::volScalarField>
00162 Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandI) const
00163 {
00164     const volScalarField& T = thermo_.T();
00165     const volScalarField& p = thermo_.p();
00166     const volScalarField& ft = mesh_.lookupObject<volScalarField>("ft");
00167 
00168     label nSpecies = speciesNames_.size();
00169 
00170     tmp<volScalarField> ta
00171     (
00172         new volScalarField
00173         (
00174             IOobject
00175             (
00176                 "a",
00177                 mesh().time().timeName(),
00178                 mesh(),
00179                 IOobject::NO_READ,
00180                 IOobject::NO_WRITE
00181             ),
00182             mesh(),
00183             dimensionedScalar("a", dimless/dimLength, 0.0)
00184         )
00185     );
00186 
00187     scalarField& a = ta().internalField();
00188 
00189     forAll(a, i)
00190     {
00191         const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
00192 
00193         for (label n=0; n<nSpecies; n++)
00194         {
00195             label l = 0;
00196             scalar Yipi = 0.0;
00197             if (specieIndex_[n] != 0)
00198             {
00199                 // moles x pressure [atm]
00200                 Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
00201             }
00202             else
00203             {
00204                 // mass fraction from species being solved
00205                 Yipi = Yj_[l][i];
00206                 l++;
00207             }
00208 
00209             scalar Ti = T[i];
00210 
00211             const absorptionCoeffs::coeffArray& b =
00212                 coeffs_[n][bandI].coeffs(T[i]);
00213 
00214             if (coeffs_[n][bandI].invTemp())
00215             {
00216                 Ti = 1.0/T[i];
00217             }
00218 
00219             a[i]+=
00220                 Yipi
00221                *(
00222                     ((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
00223                   + b[0]
00224                 );
00225         }
00226     }
00227 
00228     return ta;
00229 }
00230 
00231 
00232 Foam::tmp<Foam::volScalarField>
00233 Foam::radiation::wideBandAbsorptionEmission::eCont(const label bandI) const
00234 {
00235     tmp<volScalarField> e
00236     (
00237         new volScalarField
00238         (
00239             IOobject
00240             (
00241                 "e",
00242                 mesh().time().timeName(),
00243                 mesh(),
00244                 IOobject::NO_READ,
00245                 IOobject::NO_WRITE
00246             ),
00247             mesh(),
00248             dimensionedScalar("e", dimless/dimLength, 0.0)
00249         )
00250     );
00251 
00252     return e;
00253 }
00254 
00255 
00256 Foam::tmp<Foam::volScalarField>
00257 Foam::radiation::wideBandAbsorptionEmission::ECont(const label bandI) const
00258 {
00259     tmp<volScalarField> E
00260     (
00261         new volScalarField
00262         (
00263             IOobject
00264             (
00265                 "E",
00266                 mesh().time().timeName(),
00267                 mesh(),
00268                 IOobject::NO_READ,
00269                 IOobject::NO_WRITE
00270             ),
00271             mesh(),
00272             dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
00273         )
00274     );
00275 
00276     if (mesh().foundObject<volScalarField>("hrr"))
00277     {
00278         const volScalarField& hrr = mesh().lookupObject<volScalarField>("hrr");
00279         E().internalField() =
00280             iEhrrCoeffs_[bandI]
00281            *hrr.internalField()
00282            *(iBands_[bandI][1] - iBands_[bandI][0])
00283            /totalWaveLength_;
00284     }
00285 
00286     return E;
00287 }
00288 
00289 Foam::tmp<Foam::volScalarField>
00290 Foam::radiation::wideBandAbsorptionEmission::addIntensity
00291 (
00292     const label i,
00293     const volScalarField& ILambda
00294 ) const
00295 {
00296     return ILambda*(iBands_[i][1] - iBands_[i][0])/totalWaveLength_;
00297 }
00298 
00299 
00300 void Foam::radiation::wideBandAbsorptionEmission::correct
00301 (
00302     volScalarField& a,
00303     PtrList<volScalarField>& aLambda
00304 ) const
00305 {
00306     a = dimensionedScalar("zero", dimless/dimLength, 0.0);
00307 
00308     for (label j=0; j<nBands_; j++)
00309     {
00310         Info<< "Calculating absorption in band: " << j << endl;
00311         aLambda[j].internalField() = this->a(j);
00312         Info<< "Calculated absorption in band: " << j << endl;
00313         a.internalField() +=
00314             aLambda[j].internalField()
00315            *(iBands_[j][1] - iBands_[j][0])
00316            /totalWaveLength_;
00317     }
00318 
00319 }
00320 
00321 
00322 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd