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 "VariableHardSphere.H"
27 #include "constants.H"
29 using namespace Foam::constant::mathematical;
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 template <class CloudType>
34 Foam::VariableHardSphere<CloudType>::VariableHardSphere
36 const dictionary& dict,
40 BinaryCollisionModel<CloudType>(dict, cloud, typeName),
41 Tref_(readScalar(this->coeffDict().lookup("Tref")))
45 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
47 template <class CloudType>
48 Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 template<class CloudType>
55 bool Foam::VariableHardSphere<CloudType>::active() const
61 template <class CloudType>
62 Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
64 const typename CloudType::parcelType& pP,
65 const typename CloudType::parcelType& pQ
68 const CloudType& cloud(this->owner());
70 label typeIdP = pP.typeId();
71 label typeIdQ = pQ.typeId();
76 cloud.constProps(typeIdP).d()
77 + cloud.constProps(typeIdQ).d()
83 cloud.constProps(typeIdP).omega()
84 + cloud.constProps(typeIdQ).omega()
87 scalar cR = mag(pP.U() - pQ.U());
94 scalar mP = cloud.constProps(typeIdP).mass();
96 scalar mQ = cloud.constProps(typeIdQ).mass();
98 scalar mR = mP*mQ/(mP + mQ);
100 // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
103 *pow(2.0*physicoChemical::k.value()*Tref_/(mR*cR*cR), omegaPQ - 0.5)
104 /exp(Foam::lgamma(2.5 - omegaPQ));
110 template <class CloudType>
111 void Foam::VariableHardSphere<CloudType>::collide
113 typename CloudType::parcelType& pP,
114 typename CloudType::parcelType& pQ
117 CloudType& cloud(this->owner());
119 label typeIdP = pP.typeId();
120 label typeIdQ = pQ.typeId();
124 Random& rndGen(cloud.rndGen());
126 scalar mP = cloud.constProps(typeIdP).mass();
128 scalar mQ = cloud.constProps(typeIdQ).mass();
130 vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
132 scalar cR = mag(UP - UQ);
134 scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
136 scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
138 scalar phi = twoPi*rndGen.scalar01();
140 vector postCollisionRelU =
149 UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
151 UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
155 // ************************************************************************* //