#### View Issue Details

ID Project Category View Status Date Submitted Last Update 0001568 OpenFOAM [All Projects] Bug public 2015-03-12 15:32 2015-03-13 13:02 a.weber henry normal feature always resolved fixed GNU/Linux Ubuntu 14.10 0001568: stochasticDispersionRAS: UTurb is not calculated spatially uniform using << vector dir = 2.0*rnd.sample01() - vector::one;             dir /= mag(dir) + SMALL; .... UTurb = sigma*fac*dir; >> will lead to a distribution of vectors according to a "cube-like" distribution, not to a uniform distribution on a sphere. using an appropriate random vector generator will solve this problem: #1 use normal distributed random numbers: e.g. http://stackoverflow.com/questions/9750908/how-to-generate-a-unit-vector-pointing-in-a-random-direction-with-isotropic-dist #2 use the generation method with a spherical coordinate system: << const scalar theta = rndGen.template sample01()*constant::mathematical::pi;     const scalar phi = rndGen.template sample01()*2.0*constant::mathematical::pi;     vector dir = vector         (         sin(theta) * cos(phi),         sin(theta) * sin(phi),         cos(theta)         );     dir /= mag(dir); >> No tags attached.

#### Activities

 2015-03-12 16:37 manager   ~0004094 The Foam::Random class already provides         //- Return a normal Gaussian randon number         // with zero mean and unity variance N(0, 1)         scalar GaussNormal(); I assume this would be suitable for stochasticDispersionRAS in conjunction with the spherical transformation. 2015-03-12 16:52 manager   ~0004095 Given the overhead of the GaussNormal method I think option #2 is preferable. 2015-03-13 11:59 manager   ~0004108 Following the transformation from theta and phi to dir the normalization dir /= mag(dir); should not be needed an the vector should already be unit. Do you want the normalization in anyway to compensate for round-off error? 2015-03-13 12:14 reporter   ~0004110 That's right. Normalization is not needed. My fault. 2015-03-13 13:02 manager   ~0004112 Resolved by commit 19fbe17af23a10a14bd20dcfb693150e50e78474