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 \*---------------------------------------------------------------------------*/
27 #include "mathematicalConstants.H"
30 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 Foam::scalar Foam::spray::injectedMass(const scalar t) const
38 sum += injectors_[i].properties()->injectedMass(t);
45 Foam::scalar Foam::spray::totalMassToInject() const
51 sum += injectors_[i].properties()->mass();
58 Foam::scalar Foam::spray::injectedEnthalpy
64 label Nf = fuels_->components().size();
68 scalar T = injectors_[i].properties()->T(time);
69 scalarField X(injectors_[i].properties()->X());
71 scalar hl = fuels_->hl(pi, T, X);
72 scalar Wl = fuels_->W(X);
75 for (label j=0; j<Nf; j++)
77 label k = liquidToGasIndex_[j];
78 hg += gasProperties()[k].H(T)*gasProperties()[k].W()*X[j]/Wl;
81 sum += injectors_[i].properties()->injectedMass(time)*(hg-hl);
88 Foam::scalar Foam::spray::liquidMass() const
92 forAllConstIter(spray, *this, iter)
99 sum *= constant::mathematical::twoPi/angleOfWedge();
102 reduce(sum, sumOp<scalar>());
108 Foam::scalar Foam::spray::liquidEnthalpy() const
111 label Nf = fuels().components().size();
113 forAllConstIter(spray, *this, iter)
115 scalar T = iter().T();
116 scalar pc = p()[iter().cell()];
117 scalar hlat = fuels().hl(pc, T, iter().X());
119 scalar Wl = fuels().W(iter().X());
121 for (label j=0; j<Nf; j++)
123 label k = liquidToGasIndex_[j];
126 gasProperties()[k].H(T)*gasProperties()[k].W()*iter().X()[j]
130 scalar h = hg - hlat;
136 sum *= constant::mathematical::twoPi/angleOfWedge();
139 reduce(sum, sumOp<scalar>());
145 Foam::scalar Foam::spray::liquidTotalEnthalpy() const
148 label Nf = fuels().components().size();
150 forAllConstIter(spray, *this, iter)
152 label cellI = iter().cell();
153 scalar T = iter().T();
154 scalar pc = p()[cellI];
155 scalar rho = fuels().rho(pc, T, iter().X());
156 scalar hlat = fuels().hl(pc, T, iter().X());
158 scalar Wl = fuels().W(iter().X());
160 for (label j=0; j<Nf; j++)
162 label k = liquidToGasIndex_[j];
164 gasProperties()[k].H(T)*gasProperties()[k].W()*iter().X()[j]
168 scalar psat = fuels().pv(pc, T, iter().X());
170 scalar h = hg - hlat + (pc - psat)/rho;
176 sum *= constant::mathematical::twoPi/angleOfWedge();
179 reduce(sum, sumOp<scalar>());
185 Foam::scalar Foam::spray::liquidKineticEnergy() const
189 forAllConstIter(spray, *this, iter)
191 const scalar ke = pow(mag(iter().U()), 2.0);
192 sum += iter().m()*ke;
197 sum *= constant::mathematical::twoPi/angleOfWedge();
200 reduce(sum, sumOp<scalar>());
207 Foam::scalar Foam::spray::injectedLiquidKineticEnergy() const
209 return injectedLiquidKE_;
213 Foam::scalar Foam::spray::liquidPenetration(const scalar prc) const
215 return liquidPenetration(0, prc);
219 Foam::scalar Foam::spray::liquidPenetration
226 label nHoles = injectors_[nozzlei].properties()->nHoles();
227 vector ip(vector::zero);
230 for (label i=0;i<nHoles;i++)
232 ip += injectors_[nozzlei].properties()->position(i);
238 ip = injectors_[nozzlei].properties()->position(0);
241 // vector ip = injectors_[nozzlei].properties()->position();
247 // arrays containing the parcels mass and
248 // distance from injector in ascending order
250 scalarField dist(Np);
255 // first arrange the parcels in ascending order
256 // the first parcel is closest to injector
257 // and the last one is most far away.
258 spray::const_iterator first = begin();
260 dist[n] = mag(first().position() - ip);
266 spray::const_iterator iter = ++first;
271 scalar de = mag(iter().position() - ip);
272 scalar me = iter().m();
280 // insert the parcel in the correct place
281 // and move the others
282 while ( ( i < n-1 ) && ( !found ) )
287 for (label j=n; j>i; j--)
306 reduce(mTot, sumOp<scalar>());
310 scalar mLimit = prc*mTot;
311 scalar mOff = (1.0 - prc)*mTot;
313 // 'prc' is large enough that the parcel most far
314 // away will be used, no need to loop...
315 if (mLimit > mTot - m[Np-1])
321 scalar mOffSum = 0.0;
324 while ((mOffSum < mOff) && (i>0))
337 spray::const_iterator iter = begin();
338 d = mag(iter().position() - ip);
342 reduce(d, maxOp<scalar>());
348 Foam::scalar Foam::spray::smd() const
350 scalar numerator = 0.0, denominator = VSMALL;
352 forAllConstIter(spray, *this, iter)
354 label cellI = iter().cell();
355 scalar Pc = p()[cellI];
356 scalar T = iter().T();
357 scalar rho = fuels_->rho(Pc, T, iter().X());
359 scalar tmp = iter().N(rho)*pow(iter().d(), 2.0);
360 numerator += tmp*iter().d();
364 reduce(numerator, sumOp<scalar>());
365 reduce(denominator, sumOp<scalar>());
367 return numerator/denominator;
371 Foam::scalar Foam::spray::maxD() const
375 forAllConstIter(spray, *this, iter)
377 maxD = max(maxD, iter().d());
380 reduce(maxD, maxOp<scalar>());
386 void Foam::spray::calculateAmbientPressure()
388 ambientPressure_ = p_.average().value();
392 void Foam::spray::calculateAmbientTemperature()
394 ambientTemperature_ = T_.average().value();
398 // ************************************************************************* //