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 \*---------------------------------------------------------------------------*/
26 #include "TrajectoryCollision.H"
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 template <class CloudType>
31 Foam::TrajectoryCollision<CloudType>::TrajectoryCollision
33 const dictionary& dict,
37 StochasticCollisionModel<CloudType>(dict, owner, typeName),
38 cSpace_(readScalar(this->coeffDict().lookup("cSpace"))),
39 cTime_(readScalar(this->coeffDict().lookup("cTime"))),
40 coalescence_(this->coeffDict().lookup("coalescence"))
44 template <class CloudType>
45 Foam::TrajectoryCollision<CloudType>::TrajectoryCollision
47 const TrajectoryCollision<CloudType>& cm
50 StochasticCollisionModel<CloudType>(cm),
53 coalescence_(cm.coalescence_)
57 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 template <class CloudType>
60 Foam::TrajectoryCollision<CloudType>::~TrajectoryCollision()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 template<class CloudType>
67 bool Foam::TrajectoryCollision<CloudType>::update
95 bool coalescence = false;
97 vector vRel = U1 - U2;
99 vector p = pos2 - pos1;
100 scalar dist = mag(p);
102 scalar vAlign = vRel & (p/(dist + SMALL));
106 scalar sumD = d1 + d2;
108 if (vAlign*dt > dist - 0.5*sumD)
110 scalar v1Mag = mag(U1);
111 scalar v2Mag = mag(U2);
112 vector nv1 = U1/v1Mag;
113 vector nv2 = U2/v2Mag;
115 scalar v1v2 = nv1 & nv2;
116 scalar v1p = nv1 & p;
117 scalar v2p = nv2 & p;
119 scalar det = 1.0 - v1v2*v1v2;
121 scalar alpha = 1.0e+20;
122 scalar beta = 1.0e+20;
124 if (mag(det) > 1.0e-4)
126 beta = -(v2p - v1v2*v1p)/det;
127 alpha = v1p + v1v2*beta;
133 // is collision possible within this timestep
134 if ((alpha>0) && (alpha<1.0) && (beta>0) && (beta<1.0))
136 vector p1c = pos1 + alpha*U1*dt;
137 vector p2c = pos2 + beta*U2*dt;
139 scalar closestDist = mag(p1c-p2c);
142 pow(0.5*sumD/max(0.5*sumD, closestDist), cSpace_)
143 * exp(-cTime_*mag(alpha-beta));
145 scalar xx = rndGen.sample01<scalar>();
148 if ((xx < collProb) && (m1 > VSMALL) && (m2 > VSMALL))
152 coalescence = collideSorted
182 coalescence = collideSorted
219 template<class CloudType>
220 bool Foam::TrajectoryCollision<CloudType>::collideSorted
223 cachedRandom& rndGen,
248 bool coalescence = false;
250 vector vRel = U1 - U2;
252 scalar mdMin = m2/N2;
254 scalar mTot = m1 + m2;
256 scalar gamma = d1/max(d2, 1.0e-12);
257 scalar f = gamma*gamma*gamma + 2.7*gamma - 2.4*gamma*gamma;
259 vector momMax = m1*U1;
260 vector momMin = m2*U2;
262 // use mass-averaged temperature to calculate We number
263 scalar Tm = (T1*m1 + T2*m2)/mTot;
265 // and mass averaged fractions ...
266 //scalarField Yav((m1*Y1 + m2*Y2)/mTot;
268 // interpolate the averaged surface tension
269 scalar sigma = sigma1 + (sigma2 - sigma1)*(Tm - T1)/(T2 - T1);
271 sigma = max(1.0e-6, sigma);
272 scalar Vtot = m1/rho1 + m2/rho2;
273 scalar rho = mTot/Vtot;
275 scalar dMean = sqrt(d1*d2);
276 scalar WeColl = max(1.0e-12, 0.5*rho*magSqr(vRel)*dMean/sigma);
278 scalar coalesceProb = min(1.0, 2.4*f/WeColl);
280 scalar prob = rndGen.sample01<scalar>();
283 if ( prob < coalesceProb && coalescence_)
286 // How 'many' of the droplets coalesce
287 scalar nProb = prob*N2/N1;
289 // Conservation of mass, momentum and energy
291 scalar dm = N1*nProb*mdMin;
293 scalar V2 = constant::mathematical::pi*pow3(d2)/6.0;
298 T1 = (Tm*mTot - m2*T2)/m1;
300 U1 =(momMax + (1.0 - m2/m2Org)*momMin)/m1;
302 // update the liquid mass fractions
303 Y1 = (m1Org*Y1 + dm*Y2)/m1;
305 // Grazing collision (no coalescence)
308 scalar gf = sqrt(prob) - sqrt(coalesceProb);
309 scalar denom = 1.0 - sqrt(coalesceProb);
316 // if gf negative, this means that coalescence is turned off
317 // and these parcels should have coalesced
320 // gf -> 1 => v1p -> p1().U() ...
321 // gf -> 0 => v1p -> momentum/(m1 + m2)
323 vector mr = m1*U1 + m2*U2;
324 vector v1p = (mr + m2*gf*vRel)/(m1 + m2);
325 vector v2p = (mr - m1*gf*vRel)/(m1 + m2);
330 U2 = (N1*v2p + (N2 - N1)*U2)/N2;
334 U1 = (N2*v1p + (N1 - N2)*U1)/N1;
343 // ************************************************************************* //