1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "wideBandAbsorptionEmission.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(wideBandAbsorptionEmission, 0);
38 addToRunTimeSelectionTable
40 absorptionEmissionModel,
41 wideBandAbsorptionEmission,
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
52 const dictionary& dict,
56 absorptionEmissionModel(dict, mesh),
57 coeffsDict_((dict.subDict(typeName + "Coeffs"))),
62 fileName(coeffsDict_.lookup("lookUpTableFileName")),
63 mesh.time().constant(),
66 thermo_(mesh.lookupObject<basicThermo>("thermophysicalProperties")),
71 const dictionary& functionDicts = dict.subDict(typeName +"Coeffs");
72 forAllConstIter(dictionary, functionDicts, iter)
80 const dictionary& dict = iter().dict();
81 dict.lookup("bandLimits") >> iBands_[nBand];
82 dict.lookup("EhrrCoeff") >> iEhrrCoeffs_[nBand];
83 totalWaveLength_ += iBands_[nBand][1] - iBands_[nBand][0];
86 const dictionary& specDicts = dict.subDict("species");
87 forAllConstIter(dictionary, specDicts, iter)
89 const word& key = iter().keyword();
92 speciesNames_.insert(key, nSpec);
96 if (!speciesNames_.found(key))
100 "Foam::radiation::wideBandAbsorptionEmission(const"
101 "dictionary& dict, const fvMesh& mesh)"
102 ) << "specie: " << key << "is not in all the bands"
103 << nl << exit(FatalError);
106 coeffs_[nSpec][nBand].initialise(specDicts.subDict(key));
113 // Check that all the species on the dictionary are present in the
114 // look-up table and save the corresponding indices of the look-up table
117 forAllConstIter(HashTable<label>, speciesNames_, iter)
119 if (lookUpTable_.found(iter.key()))
121 label index = lookUpTable_.findFieldIndex(iter.key());
122 Info<< "specie: " << iter.key() << " found in look-up table "
123 << " with index: " << index << endl;
124 specieIndex_[iter()] = index;
126 else if (mesh.foundObject<volScalarField>(iter.key()))
128 volScalarField& Y = const_cast<volScalarField&>
129 (mesh.lookupObject<volScalarField>(iter.key()));
133 specieIndex_[iter()] = 0.0;
135 Info<< "species: " << iter.key() << " is being solved" << endl;
141 "radiation::wideBandAbsorptionEmission(const"
142 "dictionary& dict, const fvMesh& mesh)"
143 ) << "specie: " << iter.key()
144 << " is neither in look-up table : "
145 << lookUpTable_.tableName() << " nor is being solved"
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
155 Foam::radiation::wideBandAbsorptionEmission::~wideBandAbsorptionEmission()
159 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161 Foam::tmp<Foam::volScalarField>
162 Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandI) const
164 const volScalarField& T = thermo_.T();
165 const volScalarField& p = thermo_.p();
166 const volScalarField& ft = mesh_.lookupObject<volScalarField>("ft");
168 label nSpecies = speciesNames_.size();
170 tmp<volScalarField> ta
177 mesh().time().timeName(),
183 dimensionedScalar("a", dimless/dimLength, 0.0)
187 scalarField& a = ta().internalField();
191 const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
193 for (label n=0; n<nSpecies; n++)
197 if (specieIndex_[n] != 0)
199 // moles x pressure [atm]
200 Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
204 // mass fraction from species being solved
211 const absorptionCoeffs::coeffArray& b =
212 coeffs_[n][bandI].coeffs(T[i]);
214 if (coeffs_[n][bandI].invTemp())
222 ((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
232 Foam::tmp<Foam::volScalarField>
233 Foam::radiation::wideBandAbsorptionEmission::eCont(const label bandI) const
235 tmp<volScalarField> e
242 mesh().time().timeName(),
248 dimensionedScalar("e", dimless/dimLength, 0.0)
256 Foam::tmp<Foam::volScalarField>
257 Foam::radiation::wideBandAbsorptionEmission::ECont(const label bandI) const
259 tmp<volScalarField> E
266 mesh().time().timeName(),
272 dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
276 if (mesh().foundObject<volScalarField>("hrr"))
278 const volScalarField& hrr = mesh().lookupObject<volScalarField>("hrr");
279 E().internalField() =
282 *(iBands_[bandI][1] - iBands_[bandI][0])
289 Foam::tmp<Foam::volScalarField>
290 Foam::radiation::wideBandAbsorptionEmission::addIntensity
293 const volScalarField& ILambda
296 return ILambda*(iBands_[i][1] - iBands_[i][0])/totalWaveLength_;
300 void Foam::radiation::wideBandAbsorptionEmission::correct
303 PtrList<volScalarField>& aLambda
306 a = dimensionedScalar("zero", dimless/dimLength, 0.0);
308 for (label j=0; j<nBands_; j++)
310 Info<< "Calculating absorption in band: " << j << endl;
311 aLambda[j].internalField() = this->a(j);
312 Info<< "Calculated absorption in band: " << j << endl;
314 aLambda[j].internalField()
315 *(iBands_[j][1] - iBands_[j][0])
322 // ************************************************************************* //