View Issue Details
ID  Project  Category  View Status  Date Submitted  Last Update 

0001568  OpenFOAM  [All Projects] Bug  public  20150312 15:32  20150313 13:02 
Reporter  a.weber  Assigned To  henry  
Priority  normal  Severity  feature  Reproducibility  always 
Status  resolved  Resolution  fixed  
Platform  GNU/Linux  OS  Ubuntu  OS Version  14.10 
Product Version  
Fixed in Version  
Summary  0001568: stochasticDispersionRAS: UTurb is not calculated spatially uniform  
Description  using << vector dir = 2.0*rnd.sample01<vector>()  vector::one; dir /= mag(dir) + SMALL; .... UTurb = sigma*fac*dir; >> will lead to a distribution of vectors according to a "cubelike" distribution, not to a uniform distribution on a sphere.  
Additional Information  using an appropriate random vector generator will solve this problem: #1 use normal distributed random numbers: e.g. http://stackoverflow.com/questions/9750908/howtogenerateaunitvectorpointinginarandomdirectionwithisotropicdist #2 use the generation method with a spherical coordinate system: << const scalar theta = rndGen.template sample01<scalar>()*constant::mathematical::pi; const scalar phi = rndGen.template sample01<scalar>()*2.0*constant::mathematical::pi; vector dir = vector ( sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta) ); dir /= mag(dir); >>  
Tags  No tags attached.  

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. 

Given the overhead of the GaussNormal method I think option #2 is preferable. 

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 roundoff error? 

That's right. Normalization is not needed. My fault. 

Resolved by commit 19fbe17af23a10a14bd20dcfb693150e50e78474 
Date Modified  Username  Field  Change 

20150312 15:32  a.weber  New Issue  
20150312 16:37  henry  Note Added: 0004094  
20150312 16:52  henry  Note Added: 0004095  
20150313 11:59  henry  Note Added: 0004108  
20150313 12:14  a.weber  Note Added: 0004110  
20150313 13:02  henry  Note Added: 0004112  
20150313 13:02  henry  Status  new => resolved 
20150313 13:02  henry  Resolution  open => fixed 
20150313 13:02  henry  Assigned To  => henry 
20150324 00:17  liuhuafei  Issue cloned: 0001615 