1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "mathematicalConstants.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 scalar spray::injectedMass(const scalar t) const
40 forAll (injectors_, i)
42 sum += injectors_[i].properties()->injectedMass(t);
49 scalar spray::totalMassToInject() const
53 forAll (injectors_, i)
55 sum += injectors_[i].properties()->mass();
62 scalar spray::injectedEnthalpy
68 label Nf = fuels_->components().size();
70 forAll (injectors_, i)
72 scalar T = injectors_[i].properties()->T(time);
73 scalarField X(injectors_[i].properties()->X());
75 scalar hl = fuels_->hl(pi, T, X);
76 scalar Wl = fuels_->W(X);
79 for(label j=0; j<Nf; j++)
81 label k = liquidToGasIndex_[j];
82 hg += gasProperties()[k].H(T)*gasProperties()[k].W()*X[j]/Wl;
85 sum += injectors_[i].properties()->injectedMass(time)*(hg-hl);
92 scalar spray::liquidMass() const
98 spray::const_iterator elmnt = begin();
108 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
111 reduce(sum, sumOp<scalar>());
117 scalar spray::liquidEnthalpy() const
120 label Nf = fuels().components().size();
124 spray::const_iterator elmnt = begin();
129 scalar T = elmnt().T();
130 scalar pc = p()[elmnt().cell()];
131 scalar hlat = fuels().hl(pc, T, elmnt().X());
133 scalar Wl = fuels().W(elmnt().X());
135 for(label j=0; j<Nf; j++)
137 label k = liquidToGasIndex_[j];
140 gasProperties()[k].H(T)*gasProperties()[k].W()*elmnt().X()[j]
144 scalar h = hg - hlat;
145 sum += elmnt().m()*h;
150 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
153 reduce(sum, sumOp<scalar>());
159 scalar spray::liquidTotalEnthalpy() const
162 label Nf = fuels().components().size();
166 spray::const_iterator elmnt = begin();
171 label celli = elmnt().cell();
172 scalar T = elmnt().T();
173 scalar pc = p()[celli];
174 scalar rho = fuels().rho(pc, T, elmnt().X());
175 scalar hlat = fuels().hl(pc, T, elmnt().X());
177 scalar Wl = fuels().W(elmnt().X());
179 for(label j=0; j<Nf; j++)
181 label k = liquidToGasIndex_[j];
183 gasProperties()[k].H(T)*gasProperties()[k].W()*elmnt().X()[j]
187 scalar psat = fuels().pv(pc, T, elmnt().X());
189 scalar h = hg - hlat + (pc - psat)/rho;
190 sum += elmnt().m()*h;
195 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
198 reduce(sum, sumOp<scalar>());
204 scalar spray::liquidKineticEnergy() const
209 spray::const_iterator elmnt = begin();
214 scalar ke = pow(mag(elmnt().U()), 2.0);
215 sum += elmnt().m()*ke;
220 sum *= 2.0*mathematicalConstant::pi/angleOfWedge();
223 reduce(sum, sumOp<scalar>());
230 scalar spray::injectedLiquidKineticEnergy() const
232 return injectedLiquidKE_;
236 scalar spray::liquidPenetration(const scalar prc) const
238 return liquidPenetration(0, prc);
242 scalar spray::liquidPenetration
249 label nHoles = injectors_[nozzlei].properties()->nHoles();
250 vector ip(vector::zero);
253 for(label i=0;i<nHoles;i++)
255 ip += injectors_[nozzlei].properties()->position(i);
261 ip = injectors_[nozzlei].properties()->position(0);
264 // vector ip = injectors_[nozzlei].properties()->position();
270 // arrays containing the parcels mass and
271 // distance from injector in ascending order
273 scalarField dist(Np);
279 // first arrange the parcels in ascending order
280 // the first parcel is closest to injector
281 // and the last one is most far away.
282 spray::const_iterator first = begin();
284 dist[n] = mag(first().position() - ip);
290 spray::const_iterator elmnt = ++first;
295 scalar de = mag(elmnt().position() - ip);
296 scalar me = elmnt().m();
304 // insert the parcel in the correct place
305 // and move the others
306 while ( ( i < n-1 ) && ( !found ) )
311 for(label j=n; j>i; j--)
330 reduce(mTot, sumOp<scalar>());
334 scalar mLimit = prc*mTot;
335 scalar mOff = (1.0 - prc)*mTot;
337 // 'prc' is large enough that the parcel most far
338 // away will be used, no need to loop...
339 if (mLimit > mTot - m[Np-1])
345 scalar mOffSum = 0.0;
348 while ((mOffSum < mOff) && (i>0))
361 spray::const_iterator elmnt = begin();
362 d = mag(elmnt().position() - ip);
366 reduce(d, maxOp<scalar>());
372 scalar spray::smd() const
374 scalar numerator = 0.0, denominator = VSMALL;
378 spray::const_iterator elmnt = begin();
383 label celli = elmnt().cell();
384 scalar Pc = p()[celli];
385 scalar T = elmnt().T();
386 scalar rho = fuels_->rho(Pc, T, elmnt().X());
388 scalar tmp = elmnt().N(rho)*pow(elmnt().d(), 2.0);
389 numerator += tmp*elmnt().d();
393 reduce(numerator, sumOp<scalar>());
394 reduce(denominator, sumOp<scalar>());
396 return numerator/denominator;
400 scalar spray::maxD() const
406 spray::const_iterator elmnt = begin();
411 maxD = max(maxD, elmnt().d());
414 reduce(maxD, maxOp<scalar>());
420 void spray::calculateAmbientPressure()
422 ambientPressure_ = p_.average().value();
426 void spray::calculateAmbientTemperature()
428 ambientTemperature_ = T_.average().value();
432 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
434 } // End namespace Foam
436 // ************************************************************************* //