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 \*---------------------------------------------------------------------------*/
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
250 label nHoles = injectors_[nozzlei].properties()->nHoles();
251 vector ip(vector::zero);
254 for(label i=0;i<nHoles;i++)
256 ip += injectors_[nozzlei].properties()->position(i);
262 ip = injectors_[nozzlei].properties()->position(0);
265 // vector ip = injectors_[nozzlei].properties()->position();
271 // arrays containing the parcels mass and
272 // distance from injector in ascending order
274 scalarField dist(Np);
280 // first arrange the parcels in ascending order
281 // the first parcel is closest to injector
282 // and the last one is most far away.
283 spray::const_iterator first = begin();
285 dist[n] = mag(first().position() - ip);
291 spray::const_iterator elmnt = ++first;
296 scalar de = mag(elmnt().position() - ip);
297 scalar me = elmnt().m();
305 // insert the parcel in the correct place
306 // and move the others
307 while ( ( i < n-1 ) && ( !found ) )
312 for(label j=n; j>i; j--)
331 reduce(mTot, sumOp<scalar>());
335 scalar mLimit = prc*mTot;
336 scalar mOff = (1.0 - prc)*mTot;
338 // 'prc' is large enough that the parcel most far
339 // away will be used, no need to loop...
340 if (mLimit > mTot - m[Np-1])
346 scalar mOffSum = 0.0;
349 while ((mOffSum < mOff) && (i>0))
362 spray::const_iterator elmnt = begin();
363 d = mag(elmnt().position() - ip);
367 reduce(d, maxOp<scalar>());
373 scalar spray::smd() const
375 scalar numerator = 0.0, denominator = VSMALL;
379 spray::const_iterator elmnt = begin();
384 label celli = elmnt().cell();
385 scalar Pc = p()[celli];
386 scalar T = elmnt().T();
387 scalar rho = fuels_->rho(Pc, T, elmnt().X());
389 scalar tmp = elmnt().N(rho)*pow(elmnt().d(), 2.0);
390 numerator += tmp*elmnt().d();
394 reduce(numerator, sumOp<scalar>());
395 reduce(denominator, sumOp<scalar>());
397 return numerator/denominator;
401 scalar spray::maxD() const
407 spray::const_iterator elmnt = begin();
412 maxD = max(maxD, elmnt().d());
415 reduce(maxD, maxOp<scalar>());
421 void spray::calculateAmbientPressure()
423 ambientPressure_ = p_.average().value();
427 void spray::calculateAmbientTemperature()
429 ambientTemperature_ = T_.average().value();
433 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
435 } // End namespace Foam
437 // ************************************************************************* //