OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

VariableHardSphere.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "VariableHardSphere.H"
00028 
00029 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00030 
00031 template <class CloudType>
00032 Foam::VariableHardSphere<CloudType>::VariableHardSphere
00033 (
00034     const dictionary& dict,
00035     CloudType& cloud
00036 )
00037 :
00038     BinaryCollisionModel<CloudType>(dict, cloud, typeName),
00039     Tref_(readScalar(this->coeffDict().lookup("Tref")))
00040 {}
00041 
00042 
00043 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00044 
00045 template <class CloudType>
00046 Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
00047 {}
00048 
00049 
00050 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00051 
00052 
00053 template <class CloudType>
00054 Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
00055 (
00056     label typeIdP,
00057     label typeIdQ,
00058     const vector& UP,
00059     const vector& UQ
00060 ) const
00061 {
00062     const CloudType& cloud(this->owner());
00063 
00064     scalar dPQ =
00065         0.5
00066        *(
00067             cloud.constProps(typeIdP).d()
00068           + cloud.constProps(typeIdQ).d()
00069         );
00070 
00071     scalar omegaPQ =
00072         0.5
00073        *(
00074             cloud.constProps(typeIdP).omega()
00075           + cloud.constProps(typeIdQ).omega()
00076         );
00077 
00078     scalar cR = mag(UP - UQ);
00079 
00080     if (cR < VSMALL)
00081     {
00082         return 0;
00083     }
00084 
00085     scalar mP = cloud.constProps(typeIdP).mass();
00086 
00087     scalar mQ = cloud.constProps(typeIdQ).mass();
00088 
00089     scalar mR = mP*mQ/(mP + mQ);
00090 
00091     // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
00092     scalar sigmaTPQ =
00093         mathematicalConstant::pi*dPQ*dPQ
00094        *pow(2.0*CloudType::kb*Tref_/(mR*cR*cR), omegaPQ - 0.5)
00095        /exp(Foam::lgamma(2.5 - omegaPQ));
00096 
00097     return sigmaTPQ*cR;
00098 }
00099 
00100 
00101 template <class CloudType>
00102 void Foam::VariableHardSphere<CloudType>::collide
00103 (
00104     label typeIdP,
00105     label typeIdQ,
00106     vector& UP,
00107     vector& UQ,
00108     scalar& EiP,
00109     scalar& EiQ
00110 )
00111 {
00112     CloudType& cloud(this->owner());
00113 
00114     Random& rndGen(cloud.rndGen());
00115 
00116     scalar mP = cloud.constProps(typeIdP).mass();
00117 
00118     scalar mQ = cloud.constProps(typeIdQ).mass();
00119 
00120     vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
00121 
00122     scalar cR = mag(UP - UQ);
00123 
00124     scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
00125 
00126     scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
00127 
00128     scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01();
00129 
00130     vector postCollisionRelU =
00131         cR
00132        *vector
00133         (
00134             cosTheta,
00135             sinTheta*cos(phi),
00136             sinTheta*sin(phi)
00137         );
00138 
00139     UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
00140 
00141     UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
00142 }
00143 
00144 
00145 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd