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 \*---------------------------------------------------------------------------*/
26 #include "LarsenBorgnakkeVariableHardSphere.H"
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 template <class CloudType>
31 Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::energyRatio
37 CloudType& cloud(this->owner());
39 Random& rndGen(cloud.rndGen());
41 scalar ChiAMinusOne = ChiA - 1;
43 scalar ChiBMinusOne = ChiB - 1;
45 if (ChiAMinusOne < SMALL && ChiBMinusOne < SMALL)
47 return rndGen.scalar01();
58 energyRatio = rndGen.scalar01();
60 if (ChiAMinusOne < SMALL)
62 P = 1.0 - pow(energyRatio, ChiB);
64 else if (ChiBMinusOne < SMALL)
66 P = 1.0 - pow(energyRatio, ChiA);
73 (ChiAMinusOne + ChiBMinusOne)*energyRatio/ChiAMinusOne,
78 (ChiAMinusOne + ChiBMinusOne)*(1 - energyRatio)
83 } while (P < rndGen.scalar01());
89 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
91 template <class CloudType>
92 Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::LarsenBorgnakkeVariableHardSphere
94 const dictionary& dict,
98 BinaryCollisionModel<CloudType>(dict, cloud, typeName),
99 Tref_(readScalar(this->coeffDict().lookup("Tref"))),
100 relaxationCollisionNumber_
102 readScalar(this->coeffDict().lookup("relaxationCollisionNumber"))
107 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
109 template <class CloudType>
110 Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::
111 ~LarsenBorgnakkeVariableHardSphere()
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 template <class CloudType>
119 Foam::scalar Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::sigmaTcR
127 const CloudType& cloud(this->owner());
132 cloud.constProps(typeIdP).d()
133 + cloud.constProps(typeIdQ).d()
139 cloud.constProps(typeIdP).omega()
140 + cloud.constProps(typeIdQ).omega()
143 scalar cR = mag(UP - UQ);
150 scalar mP = cloud.constProps(typeIdP).mass();
152 scalar mQ = cloud.constProps(typeIdQ).mass();
154 scalar mR = mP*mQ/(mP + mQ);
156 // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
158 mathematicalConstant::pi*dPQ*dPQ
159 *pow(2.0*CloudType::kb*Tref_/(mR*cR*cR), omegaPQ - 0.5)
160 /exp(Foam::lgamma(2.5 - omegaPQ));
166 template <class CloudType>
167 void Foam::LarsenBorgnakkeVariableHardSphere<CloudType>::collide
177 CloudType& cloud(this->owner());
179 Random& rndGen(cloud.rndGen());
181 scalar inverseCollisionNumber = 1/relaxationCollisionNumber_;
183 // Larsen Borgnakke internal energy redistribution part. Using the serial
184 // application of the LB method, as per the INELRS subroutine in Bird's
187 scalar preCollisionEiP = EiP;
189 scalar preCollisionEiQ = EiQ;
191 scalar iDofP = cloud.constProps(typeIdP).internalDegreesOfFreedom();
193 scalar iDofQ = cloud.constProps(typeIdQ).internalDegreesOfFreedom();
198 cloud.constProps(typeIdP).omega()
199 + cloud.constProps(typeIdQ).omega()
202 scalar mP = cloud.constProps(typeIdP).mass();
204 scalar mQ = cloud.constProps(typeIdQ).mass();
206 scalar mR = mP*mQ/(mP + mQ);
208 vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
210 scalar cRsqr = magSqr(UP - UQ);
212 scalar availableEnergy = 0.5*mR*cRsqr;
214 scalar ChiB = 2.5 - omegaPQ;
218 if (inverseCollisionNumber > rndGen.scalar01())
220 availableEnergy += preCollisionEiP;
222 scalar ChiA = 0.5*iDofP;
224 EiP = energyRatio(ChiA, ChiB)*availableEnergy;
226 availableEnergy -= EiP;
232 if (inverseCollisionNumber > rndGen.scalar01())
234 availableEnergy += preCollisionEiQ;
236 // Change to general LB ratio calculation
237 scalar energyRatio = 1.0 - pow(rndGen.scalar01(),(1.0/ChiB));
239 EiQ = energyRatio*availableEnergy;
241 availableEnergy -= EiQ;
245 // Rescale the translational energy
246 scalar cR = sqrt(2.0*availableEnergy/mR);
248 // Variable Hard Sphere collision part
250 scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
252 scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
254 scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01();
256 vector postCollisionRelU =
265 UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
267 UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
271 // ************************************************************************* //