ORourkeCollision.C 8.78 KB
Newer Older
Henry's avatar
Henry committed
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
5
    \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
Henry's avatar
Henry committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

\*---------------------------------------------------------------------------*/

#include "ORourkeCollision.H"
#include "SLGThermo.H"
28
29
#include "CompactListList.H"
#include "mathematicalConstants.H"
Henry's avatar
Henry committed
30
31
32
33
34
35
36
37

using namespace Foam::constant::mathematical;

// * * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * //

template<class CloudType>
void Foam::ORourkeCollision<CloudType>::collide(const scalar dt)
{
38
39
40
41
42
43
44
45
46
47
48
49
    // Create the occupancy list for the cells
    labelList occupancy(this->owner().mesh().nCells(), 0);
    forAllIter(typename CloudType, this->owner(), iter)
    {
        occupancy[iter().cell()]++;
    }

    // Initialize the sizes of the lists of parcels in each cell
    CompactListList<parcelType*> pInCell(occupancy);

    // Reset the occupancy to use as a counter
    occupancy = 0;
50

51
    // Set the parcel pointer lists for each cell
52
    forAllIter(typename CloudType, this->owner(), iter)
Henry's avatar
Henry committed
53
    {
54
        pInCell(iter().cell(), occupancy[iter().cell()]++) = &iter();
55
56
57
58
59
    }

    for (label celli=0; celli<this->owner().mesh().nCells(); celli++)
    {
        if (pInCell[celli].size() >= 2)
Henry's avatar
Henry committed
60
        {
61
            forAll(pInCell[celli], i)
Henry's avatar
Henry committed
62
            {
63
64
65
66
                for (label j=i+1; j<pInCell[celli].size(); j++)
                {
                    parcelType& p1 = *pInCell[celli][i];
                    parcelType& p2 = *pInCell[celli][j];
Henry's avatar
Henry committed
67

68
69
                    scalar m1 = p1.nParticle()*p1.mass();
                    scalar m2 = p2.nParticle()*p2.mass();
Henry's avatar
Henry committed
70

71
                    bool massChanged = collideParcels(dt, p1, p2, m1, m2);
Henry's avatar
Henry committed
72

73
                    if (massChanged)
Henry's avatar
Henry committed
74
                    {
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
                        if (m1 > ROOTVSMALL)
                        {
                            const scalarField X(liquids_.X(p1.Y()));
                            p1.rho() = liquids_.rho(p1.pc(), p1.T(), X);
                            p1.Cp() = liquids_.Cp(p1.pc(), p1.T(), X);
                            p1.sigma() = liquids_.sigma(p1.pc(), p1.T(), X);
                            p1.mu() = liquids_.mu(p1.pc(), p1.T(), X);
                            p1.d() = cbrt(6.0*m1/(p1.nParticle()*p1.rho()*pi));
                        }

                        if (m2 > ROOTVSMALL)
                        {
                            const scalarField X(liquids_.X(p2.Y()));
                            p2.rho() = liquids_.rho(p2.pc(), p2.T(), X);
                            p2.Cp() = liquids_.Cp(p2.pc(), p2.T(), X);
                            p2.sigma() = liquids_.sigma(p2.pc(), p2.T(), X);
                            p2.mu() = liquids_.mu(p2.pc(), p2.T(), X);
                            p2.d() = cbrt(6.0*m2/(p2.nParticle()*p2.rho()*pi));
                        }
Henry's avatar
Henry committed
94
95
96
97
98
99
                    }
                }
            }
        }
    }

100
    // Remove coalesced parcels that fall below minimum mass threshold
Henry's avatar
Henry committed
101
102
103
104
105
    forAllIter(typename CloudType, this->owner(), iter)
    {
        parcelType& p = iter();
        scalar mass = p.nParticle()*p.mass();

106
        if (mass < this->owner().constProps().minParcelMass())
Henry's avatar
Henry committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
        {
            this->owner().deleteParticle(p);
        }
    }
}


template<class CloudType>
bool Foam::ORourkeCollision<CloudType>::collideParcels
(
    const scalar dt,
    parcelType& p1,
    parcelType& p2,
    scalar& m1,
    scalar& m2
)
{
124
125
    // Return if parcel masses are ~0
    if ((m1 < ROOTVSMALL) || (m2 < ROOTVSMALL))
Henry's avatar
Henry committed
126
127
128
129
    {
        return false;
    }

130
    const scalar Vc = this->owner().mesh().V()[p1.cell()];
Henry's avatar
Henry committed
131
132
133
134
135
136
137
138
139
140
141
    const scalar d1 = p1.d();
    const scalar d2 = p2.d();

    scalar magUrel = mag(p1.U() - p2.U());
    scalar sumD = d1 + d2;
    scalar nu0 = 0.25*constant::mathematical::pi*sqr(sumD)*magUrel*dt/Vc;
    scalar nMin = min(p1.nParticle(), p2.nParticle());
    scalar nu = nMin*nu0;
    scalar collProb = exp(-nu);
    scalar xx = this->owner().rndGen().template sample01<scalar>();

142
143
    // Collision occurs
    if (xx < collProb)
Henry's avatar
Henry committed
144
145
146
    {
        if (d1 > d2)
        {
147
            return collideSorted(dt, p1, p2, m1, m2);
Henry's avatar
Henry committed
148
149
150
        }
        else
        {
151
            return collideSorted(dt, p2, p1, m2, m1);
Henry's avatar
Henry committed
152
153
        }
    }
154
155
156
157
    else
    {
        return false;
    }
Henry's avatar
Henry committed
158
159
160
161
162
163
164
165
166
167
168
169
170
}


template<class CloudType>
bool Foam::ORourkeCollision<CloudType>::collideSorted
(
    const scalar dt,
    parcelType& p1,
    parcelType& p2,
    scalar& m1,
    scalar& m2
)
{
171
172
    const scalar nP1 = p1.nParticle();
    const scalar nP2 = p2.nParticle();
Henry's avatar
Henry committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

    const scalar sigma1 = p1.sigma();
    const scalar sigma2 = p2.sigma();

    const scalar d1 = p1.d();
    const scalar d2 = p2.d();

    const scalar T1 = p1.T();
    const scalar T2 = p2.T();

    const scalar rho1 = p1.rho();
    const scalar rho2 = p2.rho();

    const vector& U1 = p1.U();
    const vector& U2 = p2.U();


    vector URel = U1 - U2;
    scalar magURel = mag(URel);

    scalar mTot = m1 + m2;

    scalar gamma = d1/max(ROOTVSMALL, d2);
    scalar f = pow3(gamma) + 2.7*gamma - 2.4*sqr(gamma);

198
    // Mass-averaged temperature
Henry's avatar
Henry committed
199
200
    scalar Tave = (T1*m1 + T2*m2)/mTot;

201
202
203
204
205
206
    // Interpolate to find average surface tension
    scalar sigmaAve = sigma1;
    if (mag(T2 - T1) > SMALL)
    {
        sigmaAve += (sigma2 - sigma1)*(Tave - T1)/(T2 - T1);
    }
Henry's avatar
Henry committed
207
208
209
210
211
212
213
214
215
216
217
218

    scalar Vtot = m1/rho1 + m2/rho2;
    scalar rhoAve = mTot/Vtot;

    scalar dAve = sqrt(d1*d2);
    scalar WeColl = 0.5*rhoAve*sqr(magURel)*dAve/max(ROOTVSMALL, sigmaAve);

    scalar coalesceProb = min(1.0, 2.4*f/max(ROOTVSMALL, WeColl));

    scalar prob = this->owner().rndGen().template sample01<scalar>();

    // Coalescence
219
    if (coalescence_ && prob < coalesceProb)
Henry's avatar
Henry committed
220
    {
221
        // Number of the droplets that coalesce
Henry's avatar
Henry committed
222
223
        scalar nProb = prob*nP2/nP1;

224
        // Conservation of mass, momentum and energy
Henry's avatar
Henry committed
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
        scalar m1Org = m1;
        scalar m2Org = m2;

        scalar dm = nP1*nProb*m2/scalar(nP2);

        m1 += dm;
        m2 -= dm;

        p1.T() = (Tave*mTot - m2*T2)/m1;

        p1.U() = (m1*U1 + (1.0 - m2/m2Org)*m2*U2)/m1;

        p1.Y() = (m1Org*p1.Y() + dm*p2.Y())/m1;

        p2.nParticle() = m2/(rho2*p2.volume());
240
241

        return true;
Henry's avatar
Henry committed
242
243
244
245
246
247
248
249
250
251
252
253
    }
    // Grazing collision (no coalescence)
    else
    {
        scalar gf = sqrt(prob) - sqrt(coalesceProb);
        scalar denom = 1.0 - sqrt(coalesceProb);
        if (denom < 1.0e-5)
        {
            denom = 1.0;
        }
        gf /= denom;

254
        // If gf negative, this means that coalescence is turned off
Henry's avatar
Henry committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
        // and these parcels should have coalesced
        gf = max(0.0, gf);

        // gf -> 1 => v1p -> U1 ...
        // gf -> 0 => v1p -> momentum/mTot

        vector mr = m1*U1 + m2*U2;
        vector v1p = (mr + m2*gf*URel)/mTot;
        vector v2p = (mr - m1*gf*URel)/mTot;

        if (nP1 < nP2)
        {
            p1.U() = v1p;
            p2.U() = (nP1*v2p + (nP2 - nP1)*U2)/nP2;
        }
        else
        {
            p1.U() = (nP2*v1p + (nP1 - nP2)*U1)/nP1;
            p2.U() = v2p;
        }

276
277
        return false;
    }
Henry's avatar
Henry committed
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
}


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class CloudType>
Foam::ORourkeCollision<CloudType>::ORourkeCollision
(
    const dictionary& dict,
    CloudType& owner,
    const word& modelName
)
:
    StochasticCollisionModel<CloudType>(dict, owner, modelName),
    liquids_
    (
        owner.db().template lookupObject<SLGThermo>("SLGThermo").liquids()
    ),
    coalescence_(this->coeffDict().lookup("coalescence"))
{}


template<class CloudType>
Foam::ORourkeCollision<CloudType>::ORourkeCollision
(
    const ORourkeCollision<CloudType>& cm
)
:
    StochasticCollisionModel<CloudType>(cm),
    liquids_(cm.liquids_),
    coalescence_(cm.coalescence_)
{}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

template<class CloudType>
Foam::ORourkeCollision<CloudType>::~ORourkeCollision()
{}


// ************************************************************************* //