initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / dsmc / submodels / BinaryCollisionModel / VariableHardSphere / VariableHardSphere.C
blob29b389a65ae197b866edb2019069e3667be96c07
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "VariableHardSphere.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template <class CloudType>
32 Foam::VariableHardSphere<CloudType>::VariableHardSphere
34     const dictionary& dict,
35     CloudType& cloud
38     BinaryCollisionModel<CloudType>(dict, cloud, typeName),
39     Tref_(readScalar(this->coeffDict().lookup("Tref")))
43 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
45 template <class CloudType>
46 Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
50 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
53 template <class CloudType>
54 Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
56     label typeIdP,
57     label typeIdQ,
58     const vector& UP,
59     const vector& UQ
60 ) const
62     const CloudType& cloud(this->owner());
64     scalar dPQ =
65         0.5
66        *(
67             cloud.constProps(typeIdP).d()
68           + cloud.constProps(typeIdQ).d()
69         );
71     scalar omegaPQ =
72         0.5
73        *(
74             cloud.constProps(typeIdP).omega()
75           + cloud.constProps(typeIdQ).omega()
76         );
78     scalar cR = mag(UP - UQ);
80     if (cR < VSMALL)
81     {
82         return 0;
83     }
85     scalar mP = cloud.constProps(typeIdP).mass();
87     scalar mQ = cloud.constProps(typeIdQ).mass();
89     scalar mR = mP*mQ/(mP + mQ);
91     // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
92     scalar sigmaTPQ =
93         mathematicalConstant::pi*dPQ*dPQ
94        *pow(2.0*CloudType::kb*Tref_/(mR*cR*cR), omegaPQ - 0.5)
95        /exp(Foam::lgamma(2.5 - omegaPQ));
97     return sigmaTPQ*cR;
101 template <class CloudType>
102 void Foam::VariableHardSphere<CloudType>::collide
104     label typeIdP,
105     label typeIdQ,
106     vector& UP,
107     vector& UQ,
108     scalar& EiP,
109     scalar& EiQ
112     CloudType& cloud(this->owner());
114     Random& rndGen(cloud.rndGen());
116     scalar mP = cloud.constProps(typeIdP).mass();
118     scalar mQ = cloud.constProps(typeIdQ).mass();
120     vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
122     scalar cR = mag(UP - UQ);
124     scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
126     scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
128     scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01();
130     vector postCollisionRelU =
131         cR
132        *vector
133         (
134             cosTheta,
135             sinTheta*cos(phi),
136             sinTheta*sin(phi)
137         );
139     UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
141     UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
145 // ************************************************************************* //