BrownianMotionForce.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "BrownianMotionForce.H"
27 #include "mathematicalConstants.H"
28 #include "fundamentalConstants.H"
29 #include "demandDrivenData.H"
30 #include "momentumTransportModel.H"
31 #include "standardNormal.H"
32 
33 using namespace Foam::constant;
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
37 template<class CloudType>
39 (
40  CloudType& owner,
41  const fvMesh& mesh,
42  const dictionary& dict
43 )
44 :
45  ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
46  lambda_(this->coeffs().template lookup<scalar>("lambda"))
47 {}
48 
49 
50 template<class CloudType>
52 (
53  const BrownianMotionForce& bmf
54 )
55 :
57  lambda_(bmf.lambda_)
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
62 
63 template<class CloudType>
65 {}
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
70 template<class CloudType>
72 (
73  const typename CloudType::parcelType& p,
74  const typename CloudType::parcelType::trackingData& td,
75  const scalar dt,
76  const scalar mass,
77  const scalar Re,
78  const scalar muc
79 ) const
80 {
81  forceSuSp value(Zero, 0.0);
82 
83  const scalar dp = p.d();
84  const scalar Tc = td.Tc();
85 
86  const scalar alpha = 2.0*lambda_/dp;
87  const scalar cc = 1.0 + alpha*(1.257 + 0.4*exp(-1.1/alpha));
88 
89  // Boltzmann constant
90  const scalar kb = physicoChemical::k.value();
91 
92  // Equation 25
93  const scalar s0 =
94  216*muc*kb*Tc/(sqr(mathematical::pi)*pow5(dp)*sqr(p.rho())*cc);
95 
96  // Equation 26
97  const scalar f = mass*sqrt(mathematical::pi*s0/dt);
98 
99  randomGenerator& rndGen = this->owner().rndGen();
100  distributions::standardNormal& stdNormal = this->owner().stdNormal();
101 
102  // To generate a cubic distribution (i.e., 3 independent directions):
103  // value.Su() = f*stdNormal.sample<vector>();
104 
105  // To generate a spherical distribution:
106  const scalar theta = rndGen.scalar01()*mathematical::twoPi;
107  const scalar u = 2*rndGen.scalar01() - 1;
108  const scalar a = sqrt(1 - sqr(u));
109  const vector dir(a*cos(theta), a*sin(theta), u);
110  value.Su() = f*mag(stdNormal.sample())*dir;
111 
112  return value;
113 }
114 
115 
116 // ************************************************************************* //
label k
Calculates particle Brownian motion force.
BrownianMotionForce(CloudType &owner, const fvMesh &mesh, const dictionary &dict)
Construct from mesh.
virtual ~BrownianMotionForce()
Destructor.
virtual forceSuSp calcCoupled(const typename CloudType::parcelType &p, const typename CloudType::parcelType::trackingData &td, const scalar dt, const scalar mass, const scalar Re, const scalar muc) const
Calculate the coupled force.
Templated base class for dsmc cloud.
Definition: DSMCCloud.H:80
ParcelType parcelType
Type of parcel the cloud was instantiated for.
Definition: DSMCCloud.H:225
Abstract base class for particle forces.
Definition: ParticleForce.H:54
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Standard normal distribution. Not selectable.
virtual scalar sample() const
Sample the distribution.
Helper container for force Su and Sp terms.
Definition: forceSuSp.H:64
const vector & Su() const
Return const access to the explicit contribution [kg m/s^2].
Definition: forceSuSpI.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Random number generator.
scalar scalar01()
Return a scalar uniformly distributed between zero and one.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Template functions to aid in the implementation of demand driven data.
Fundamental dimensioned constants.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
const scalar twoPi(2 *pi)
Collection of constants.
static const zero Zero
Definition: zero.H:97
dimensionedScalar exp(const dimensionedScalar &ds)
dimensionedScalar sin(const dimensionedScalar &ds)
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void pow5(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensionedScalar cos(const dimensionedScalar &ds)
scalarField Re(const UList< complex > &cf)
Definition: complexFields.C:97
labelList f(nPoints)
dictionary dict
randomGenerator rndGen(653213)
volScalarField & p