1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-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 "SCOPELaminarFlameSpeed.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 namespace laminarFlameSpeedModels
36 defineTypeNameAndDebug(SCOPE, 0);
38 addToRunTimeSelectionTable
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 Foam::laminarFlameSpeedModels::SCOPE::polynomial::polynomial
52 const dictionary& polyDict
55 FixedList<scalar, 7>(polyDict.lookup("coefficients")),
56 ll(readScalar(polyDict.lookup("lowerLimit"))),
57 ul(readScalar(polyDict.lookup("upperLimit"))),
58 llv(polyPhi(ll, *this)),
59 ulv(polyPhi(ul, *this)),
64 Foam::laminarFlameSpeedModels::SCOPE::SCOPE
66 const dictionary& dict,
67 const hhuCombustionThermo& ct
70 laminarFlameSpeed(dict, ct),
72 coeffsDict_(dict.subDict(typeName + "Coeffs").subDict(fuel_)),
73 LFL_(readScalar(coeffsDict_.lookup("lowerFlamabilityLimit"))),
74 UFL_(readScalar(coeffsDict_.lookup("upperFlamabilityLimit"))),
75 SuPolyL_(coeffsDict_.subDict("lowerSuPolynomial")),
76 SuPolyU_(coeffsDict_.subDict("upperSuPolynomial")),
77 Texp_(readScalar(coeffsDict_.lookup("Texp"))),
78 pexp_(readScalar(coeffsDict_.lookup("pexp"))),
79 MaPolyL_(coeffsDict_.subDict("lowerMaPolynomial")),
80 MaPolyU_(coeffsDict_.subDict("upperMaPolynomial"))
82 SuPolyL_.ll = max(SuPolyL_.ll, LFL_) + SMALL;
83 SuPolyU_.ul = min(SuPolyU_.ul, UFL_) - SMALL;
85 SuPolyL_.lu = 0.5*(SuPolyL_.ul + SuPolyU_.ll);
86 SuPolyU_.lu = SuPolyL_.lu - SMALL;
88 MaPolyL_.lu = 0.5*(MaPolyL_.ul + MaPolyU_.ll);
89 MaPolyU_.lu = MaPolyL_.lu - SMALL;
93 Info<< "phi Su (T = Tref, p = pref)" << endl;
95 for (int i=0; i<n; i++)
97 scalar phi = (2.0*i)/n;
98 Info<< phi << token::TAB << SuRef(phi) << endl;
104 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
106 Foam::laminarFlameSpeedModels::SCOPE::~SCOPE()
110 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
112 inline Foam::scalar Foam::laminarFlameSpeedModels::SCOPE::polyPhi
118 scalar x = phi - 1.0;
124 + x*(a[1] + x*(a[2] + x*(a[3] + x*(a[4] + x*(a[5] + x*a[6])))))
129 inline Foam::scalar Foam::laminarFlameSpeedModels::SCOPE::SuRef
134 if (phi < LFL_ || phi > UFL_)
136 // Return 0 beyond the flamibility limits
139 else if (phi < SuPolyL_.ll)
141 // Use linear interpolation between the low end of the
142 // lower polynomial and the lower flamibility limit
143 return SuPolyL_.llv*(phi - LFL_)/(SuPolyL_.ll - LFL_);
145 else if (phi > SuPolyU_.ul)
147 // Use linear interpolation between the upper end of the
148 // upper polynomial and the upper flamibility limit
149 return SuPolyU_.ulv*(UFL_ - phi)/(UFL_ - SuPolyU_.ul);
151 else if (phi < SuPolyL_.lu)
153 // Evaluate the lower polynomial
154 return polyPhi(phi, SuPolyL_);
156 else if (phi > SuPolyU_.lu)
158 // Evaluate the upper polynomial
159 return polyPhi(phi, SuPolyU_);
163 FatalErrorIn("laminarFlameSpeedModels::SCOPE::SuRef(scalar phi)")
165 << " cannot be handled by SCOPE function with the "
174 inline Foam::scalar Foam::laminarFlameSpeedModels::SCOPE::Ma
179 if (phi < MaPolyL_.ll)
181 // Beyond the lower limit assume Ma is constant
184 else if (phi > MaPolyU_.ul)
186 // Beyond the upper limit assume Ma is constant
189 else if (phi < SuPolyL_.lu)
191 // Evaluate the lower polynomial
192 return polyPhi(phi, MaPolyL_);
194 else if (phi > SuPolyU_.lu)
196 // Evaluate the upper polynomial
197 return polyPhi(phi, MaPolyU_);
201 FatalErrorIn("laminarFlameSpeedModels::SCOPE::Ma(scalar phi)")
203 << " cannot be handled by SCOPE function with the "
212 inline Foam::scalar Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
219 static const scalar Tref = 300.0;
220 static const scalar pRef = 1.013e5;
222 return SuRef(phi)*pow((Tu/Tref), Texp_)*pow((p/pRef), pexp_);
226 Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
228 const volScalarField& p,
229 const volScalarField& Tu,
233 tmp<volScalarField> tSu0
246 dimensionedScalar("Su0", dimVelocity, 0.0)
250 volScalarField& Su0 = tSu0();
254 Su0[celli] = Su0pTphi(p[celli], Tu[celli], phi);
257 forAll(Su0.boundaryField(), patchi)
259 scalarField& Su0p = Su0.boundaryField()[patchi];
260 const scalarField& pp = p.boundaryField()[patchi];
261 const scalarField& Tup = Tu.boundaryField()[patchi];
265 Su0p[facei] = Su0pTphi(pp[facei], Tup[facei], phi);
273 Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Su0pTphi
275 const volScalarField& p,
276 const volScalarField& Tu,
277 const volScalarField& phi
280 tmp<volScalarField> tSu0
293 dimensionedScalar("Su0", dimVelocity, 0.0)
297 volScalarField& Su0 = tSu0();
301 Su0[celli] = Su0pTphi(p[celli], Tu[celli], phi[celli]);
304 forAll(Su0.boundaryField(), patchi)
306 scalarField& Su0p = Su0.boundaryField()[patchi];
307 const scalarField& pp = p.boundaryField()[patchi];
308 const scalarField& Tup = Tu.boundaryField()[patchi];
309 const scalarField& phip = phi.boundaryField()[patchi];
327 Foam::tmp<Foam::volScalarField> Foam::laminarFlameSpeedModels::SCOPE::Ma
329 const volScalarField& phi
332 tmp<volScalarField> tMa
339 phi.time().timeName(),
345 dimensionedScalar("Ma", dimless, 0.0)
349 volScalarField& ma = tMa();
353 ma[celli] = Ma(phi[celli]);
356 forAll(ma.boundaryField(), patchi)
358 scalarField& map = ma.boundaryField()[patchi];
359 const scalarField& phip = phi.boundaryField()[patchi];
363 map[facei] = Ma(phip[facei]);
371 Foam::tmp<Foam::volScalarField>
372 Foam::laminarFlameSpeedModels::SCOPE::Ma() const
374 if (hhuCombustionThermo_.composition().contains("ft"))
376 const volScalarField& ft = hhuCombustionThermo_.composition().Y("ft");
382 hhuCombustionThermo_.lookup("stoichiometricAirFuelMassRatio")
383 )*ft/(scalar(1) - ft)
388 const fvMesh& mesh = hhuCombustionThermo_.p().mesh();
390 return tmp<volScalarField>
397 mesh.time().timeName(),
403 dimensionedScalar("Ma", dimless, Ma(equivalenceRatio_))
410 Foam::tmp<Foam::volScalarField>
411 Foam::laminarFlameSpeedModels::SCOPE::operator()() const
413 if (hhuCombustionThermo_.composition().contains("ft"))
415 const volScalarField& ft = hhuCombustionThermo_.composition().Y("ft");
419 hhuCombustionThermo_.p(),
420 hhuCombustionThermo_.Tu(),
423 hhuCombustionThermo_.lookup("stoichiometricAirFuelMassRatio")
424 )*ft/(scalar(1) - ft)
431 hhuCombustionThermo_.p(),
432 hhuCombustionThermo_.Tu(),
439 // ************************************************************************* //