FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "VariableHardSphere.H"
00027 
00028 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00029 
00030 template <class CloudType>
00031 Foam::VariableHardSphere<CloudType>::VariableHardSphere
00032 (
00033     const dictionary& dict,
00034     CloudType& cloud
00035 )
00036 :
00037     BinaryCollisionModel<CloudType>(dict, cloud, typeName),
00038     Tref_(readScalar(this->coeffDict().lookup("Tref")))
00039 {}
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00043 
00044 template <class CloudType>
00045 Foam::VariableHardSphere<CloudType>::~VariableHardSphere()
00046 {}
00047 
00048 
00049 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00050 
00051 
00052 template <class CloudType>
00053 Foam::scalar Foam::VariableHardSphere<CloudType>::sigmaTcR
00054 (
00055     label typeIdP,
00056     label typeIdQ,
00057     const vector& UP,
00058     const vector& UQ
00059 ) const
00060 {
00061     const CloudType& cloud(this->owner());
00062 
00063     scalar dPQ =
00064         0.5
00065        *(
00066             cloud.constProps(typeIdP).d()
00067           + cloud.constProps(typeIdQ).d()
00068         );
00069 
00070     scalar omegaPQ =
00071         0.5
00072        *(
00073             cloud.constProps(typeIdP).omega()
00074           + cloud.constProps(typeIdQ).omega()
00075         );
00076 
00077     scalar cR = mag(UP - UQ);
00078 
00079     if (cR < VSMALL)
00080     {
00081         return 0;
00082     }
00083 
00084     scalar mP = cloud.constProps(typeIdP).mass();
00085 
00086     scalar mQ = cloud.constProps(typeIdQ).mass();
00087 
00088     scalar mR = mP*mQ/(mP + mQ);
00089 
00090     // calculating cross section = pi*dPQ^2, where dPQ is from Bird, eq. 4.79
00091     scalar sigmaTPQ =
00092         mathematicalConstant::pi*dPQ*dPQ
00093        *pow(2.0*CloudType::kb*Tref_/(mR*cR*cR), omegaPQ - 0.5)
00094        /exp(Foam::lgamma(2.5 - omegaPQ));
00095 
00096     return sigmaTPQ*cR;
00097 }
00098 
00099 
00100 template <class CloudType>
00101 void Foam::VariableHardSphere<CloudType>::collide
00102 (
00103     label typeIdP,
00104     label typeIdQ,
00105     vector& UP,
00106     vector& UQ,
00107     scalar& EiP,
00108     scalar& EiQ
00109 )
00110 {
00111     CloudType& cloud(this->owner());
00112 
00113     Random& rndGen(cloud.rndGen());
00114 
00115     scalar mP = cloud.constProps(typeIdP).mass();
00116 
00117     scalar mQ = cloud.constProps(typeIdQ).mass();
00118 
00119     vector Ucm = (mP*UP + mQ*UQ)/(mP + mQ);
00120 
00121     scalar cR = mag(UP - UQ);
00122 
00123     scalar cosTheta = 2.0*rndGen.scalar01() - 1.0;
00124 
00125     scalar sinTheta = sqrt(1.0 - cosTheta*cosTheta);
00126 
00127     scalar phi = 2.0*mathematicalConstant::pi*rndGen.scalar01();
00128 
00129     vector postCollisionRelU =
00130         cR
00131        *vector
00132         (
00133             cosTheta,
00134             sinTheta*cos(phi),
00135             sinTheta*sin(phi)
00136         );
00137 
00138     UP = Ucm + postCollisionRelU*mQ/(mP + mQ);
00139 
00140     UQ = Ucm - postCollisionRelU*mP/(mP + mQ);
00141 }
00142 
00143 
00144 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines