1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 \*---------------------------------------------------------------------------*/
28 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
37 scalar spray::injectedMass(const scalar t) const
41 forAll (injectors_, i)
43 sum += injectors_[i].properties()->injectedMass(t);
50 scalar spray::totalMassToInject() const
54 forAll (injectors_, i)
56 sum += injectors_[i].properties()->mass();
63 scalar spray::injectedEnthalpy
69 label Nf = fuels_->components().size();
71 forAll (injectors_, i)
73 scalar T = injectors_[i].properties()->T(time);
74 scalarField X(injectors_[i].properties()->X());
76 scalar hl = fuels_->hl(pi, T, X);
77 scalar Wl = fuels_->W(X);
80 for(label j=0; j<Nf; j++)
82 label k = liquidToGasIndex_[j];
83 hg += gasProperties()[k].H(T)*gasProperties()[k].W()*X[j]/Wl;
86 sum += injectors_[i].properties()->injectedMass(time)*(hg-hl);
93 scalar spray::liquidMass() const
99 spray::const_iterator elmnt = begin();
109 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
112 reduce(sum, sumOp<scalar>());
118 scalar spray::liquidEnthalpy() const
121 label Nf = fuels().components().size();
125 spray::const_iterator elmnt = begin();
130 scalar T = elmnt().T();
131 scalar pc = p()[elmnt().cell()];
132 scalar hlat = fuels().hl(pc, T, elmnt().X());
134 scalar Wl = fuels().W(elmnt().X());
136 for(label j=0; j<Nf; j++)
138 label k = liquidToGasIndex_[j];
141 gasProperties()[k].H(T)*gasProperties()[k].W()*elmnt().X()[j]
145 scalar h = hg - hlat;
146 sum += elmnt().m()*h;
151 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
154 reduce(sum, sumOp<scalar>());
160 scalar spray::liquidTotalEnthalpy() const
163 label Nf = fuels().components().size();
167 spray::const_iterator elmnt = begin();
172 label celli = elmnt().cell();
173 scalar T = elmnt().T();
174 scalar pc = p()[celli];
175 scalar rho = fuels().rho(pc, T, elmnt().X());
176 scalar hlat = fuels().hl(pc, T, elmnt().X());
178 scalar Wl = fuels().W(elmnt().X());
180 for(label j=0; j<Nf; j++)
182 label k = liquidToGasIndex_[j];
184 gasProperties()[k].H(T)*gasProperties()[k].W()*elmnt().X()[j]
188 scalar psat = fuels().pv(pc, T, elmnt().X());
190 scalar h = hg - hlat + (pc - psat)/rho;
191 sum += elmnt().m()*h;
196 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
199 reduce(sum, sumOp<scalar>());
205 scalar spray::liquidKineticEnergy() const
210 spray::const_iterator elmnt = begin();
215 scalar ke = pow(mag(elmnt().U()), 2.0);
216 sum += elmnt().m()*ke;
221 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
224 reduce(sum, sumOp<scalar>());
231 scalar spray::injectedLiquidKineticEnergy() const
233 return injectedLiquidKE_;
237 scalar spray::liquidPenetration(const scalar prc) const
239 return liquidPenetration(0, prc);
243 scalar spray::liquidPenetration
249 vector ip = injectors_[nozzlei].properties()->position();
255 // arrays containing the parcels mass and
256 // distance from injector in ascending order
258 scalarField dist(Np);
264 // first arrange the parcels in ascending order
265 // the first parcel is closest to injector
266 // and the last one is most far away.
267 spray::const_iterator first = begin();
269 dist[n] = mag(first().position() - ip);
275 spray::const_iterator elmnt = ++first;
280 scalar de = mag(elmnt().position() - ip);
281 scalar me = elmnt().m();
289 // insert the parcel in the correct place
290 // and move the others
291 while ( ( i < n-1 ) && ( !found ) )
296 for(label j=n; j>i; j--)
315 reduce(mTot, sumOp<scalar>());
319 scalar mLimit = prc*mTot;
320 scalar mOff = (1.0 - prc)*mTot;
322 // 'prc' is large enough that the parcel most far
323 // away will be used, no need to loop...
324 if (mLimit > mTot - m[Np-1])
330 scalar mOffSum = 0.0;
333 while ((mOffSum < mOff) && (i>0))
346 spray::const_iterator elmnt = begin();
347 d = mag(elmnt().position() - ip);
351 reduce(d, maxOp<scalar>());
357 scalar spray::smd() const
359 scalar numerator = 0.0, denominator = VSMALL;
363 spray::const_iterator elmnt = begin();
368 label celli = elmnt().cell();
369 scalar Pc = p()[celli];
370 scalar T = elmnt().T();
371 scalar rho = fuels_->rho(Pc, T, elmnt().X());
373 scalar tmp = elmnt().N(rho)*pow(elmnt().d(), 2.0);
374 numerator += tmp*elmnt().d();
378 reduce(numerator, sumOp<scalar>());
379 reduce(denominator, sumOp<scalar>());
381 return numerator/denominator;
385 scalar spray::maxD() const
391 spray::const_iterator elmnt = begin();
396 maxD = max(maxD, elmnt().d());
399 reduce(maxD, maxOp<scalar>());
405 void spray::calculateAmbientPressure()
407 ambientPressure_ = p_.average().value();
411 void spray::calculateAmbientTemperature()
413 ambientTemperature_ = T_.average().value();
417 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
419 } // End namespace Foam
421 // ************************************************************************* //