1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "wideBandAbsorptionEmission.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(wideBandAbsorptionEmission, 0);
37 addToRunTimeSelectionTable
39 absorptionEmissionModel,
40 wideBandAbsorptionEmission,
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission
51 const dictionary& dict,
55 absorptionEmissionModel(dict, mesh),
56 coeffsDict_((dict.subDict(typeName + "Coeffs"))),
61 fileName(coeffsDict_.lookup("lookUpTableFileName")),
62 mesh.time().constant(),
65 thermo_(mesh.lookupObject<basicThermo>("thermophysicalProperties")),
70 const dictionary& functionDicts = dict.subDict(typeName +"Coeffs");
71 forAllConstIter(dictionary, functionDicts, iter)
79 const dictionary& dict = iter().dict();
80 dict.lookup("bandLimits") >> iBands_[nBand];
81 dict.lookup("EhrrCoeff") >> iEhrrCoeffs_[nBand];
82 totalWaveLength_ += iBands_[nBand][1] - iBands_[nBand][0];
85 const dictionary& specDicts = dict.subDict("species");
86 forAllConstIter(dictionary, specDicts, iter)
88 const word& key = iter().keyword();
91 speciesNames_.insert(key, nSpec);
95 if (!speciesNames_.found(key))
99 "Foam::radiation::wideBandAbsorptionEmission(const"
100 "dictionary& dict, const fvMesh& mesh)"
101 ) << "specie: " << key << "is not in all the bands"
102 << nl << exit(FatalError);
105 coeffs_[nSpec][nBand].initialise(specDicts.subDict(key));
112 // Check that all the species on the dictionary are present in the
113 // look-up table and save the corresponding indices of the look-up table
116 forAllConstIter(HashTable<label>, speciesNames_, iter)
118 if (lookUpTable_.found(iter.key()))
120 label index = lookUpTable_.findFieldIndex(iter.key());
121 Info<< "specie: " << iter.key() << " found in look-up table "
122 << " with index: " << index << endl;
123 specieIndex_[iter()] = index;
125 else if (mesh.foundObject<volScalarField>(iter.key()))
127 volScalarField& Y = const_cast<volScalarField&>
128 (mesh.lookupObject<volScalarField>(iter.key()));
132 specieIndex_[iter()] = 0.0;
134 Info<< "species: " << iter.key() << " is being solved" << endl;
140 "radiation::wideBandAbsorptionEmission(const"
141 "dictionary& dict, const fvMesh& mesh)"
142 ) << "specie: " << iter.key()
143 << " is neither in look-up table : "
144 << lookUpTable_.tableName() << " nor is being solved"
152 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 Foam::radiation::wideBandAbsorptionEmission::~wideBandAbsorptionEmission()
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
160 Foam::tmp<Foam::volScalarField>
161 Foam::radiation::wideBandAbsorptionEmission::aCont(const label bandI) const
163 const volScalarField& T = thermo_.T();
164 const volScalarField& p = thermo_.p();
165 const volScalarField& ft = mesh_.lookupObject<volScalarField>("ft");
167 label nSpecies = speciesNames_.size();
169 tmp<volScalarField> ta
176 mesh().time().timeName(),
182 dimensionedScalar("a", dimless/dimLength, 0.0)
186 scalarField& a = ta().internalField();
190 const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
192 for (label n=0; n<nSpecies; n++)
196 if (specieIndex_[n] != 0)
198 // moles x pressure [atm]
199 Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
203 // mass fraction from species being solved
210 const absorptionCoeffs::coeffArray& b =
211 coeffs_[n][bandI].coeffs(T[i]);
213 if (coeffs_[n][bandI].invTemp())
221 ((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
231 Foam::tmp<Foam::volScalarField>
232 Foam::radiation::wideBandAbsorptionEmission::eCont(const label bandI) const
234 tmp<volScalarField> e
241 mesh().time().timeName(),
247 dimensionedScalar("e", dimless/dimLength, 0.0)
255 Foam::tmp<Foam::volScalarField>
256 Foam::radiation::wideBandAbsorptionEmission::ECont(const label bandI) const
258 tmp<volScalarField> E
265 mesh().time().timeName(),
271 dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0)
275 if (mesh().foundObject<volScalarField>("hrr"))
277 const volScalarField& hrr = mesh().lookupObject<volScalarField>("hrr");
278 E().internalField() =
281 *(iBands_[bandI][1] - iBands_[bandI][0])
288 Foam::tmp<Foam::volScalarField>
289 Foam::radiation::wideBandAbsorptionEmission::addIntensity
292 const volScalarField& ILambda
295 return ILambda*(iBands_[i][1] - iBands_[i][0])/totalWaveLength_;
299 void Foam::radiation::wideBandAbsorptionEmission::correct
302 PtrList<volScalarField>& aLambda
305 a = dimensionedScalar("zero", dimless/dimLength, 0.0);
307 for (label j=0; j<nBands_; j++)
309 Info<< "Calculating absorption in band: " << j << endl;
310 aLambda[j].internalField() = this->a(j);
311 Info<< "Calculated absorption in band: " << j << endl;
313 aLambda[j].internalField()
314 *(iBands_[j][1] - iBands_[j][0])
321 // ************************************************************************* //