View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001568 | OpenFOAM | Bug | public | 2015-03-12 15:32 | 2015-03-13 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 |
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 "cube-like" 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/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<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 round-off error? |
|
That's right. Normalization is not needed. My fault. |
|
Resolved by commit 19fbe17af23a10a14bd20dcfb693150e50e78474 |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-03-12 15:32 | a.weber | New Issue | |
2015-03-12 16:37 | henry | Note Added: 0004094 | |
2015-03-12 16:52 | henry | Note Added: 0004095 | |
2015-03-13 11:59 | henry | Note Added: 0004108 | |
2015-03-13 12:14 | a.weber | Note Added: 0004110 | |
2015-03-13 13:02 | henry | Note Added: 0004112 | |
2015-03-13 13:02 | henry | Status | new => resolved |
2015-03-13 13:02 | henry | Resolution | open => fixed |
2015-03-13 13:02 | henry | Assigned To | => henry |
2015-03-24 00:17 | liuhuafei | Issue cloned: 0001615 |