|
[Sponsors] |
Non-randomness in general distribution (particle diameter) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 26, 2019, 16:12 |
Non-randomness in general distribution (particle diameter)
|
#1 |
New Member
Eduardo Cruz
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Hi everyone,
I'm running some LPT simulations with icoUncoupledKinematicParcelFoam. I want the particle diameters to follow a particular distribution, so I am using the distributionModel general. Everything works fine, and if you take the whole sample of particles, they indeed follow the desired distribution. The problem is if I run the same case twice, the result is exactly the same (i.e. every single particle has the same diameter in both runs). But from my understanding, looking at the source code, this should not happen. Specially because inside the Foam::distributionModels::general::sample() function there is a line Code:
scalar y = rndGen_.sample01<scalar>(); Regards, ECruz |
|
June 27, 2019, 05:03 |
|
#2 |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 342
Rep Power: 28 |
Computational randomness and randomness aren't the same thing.
If read on how computers generate random numbers, e.g. on Wikipedia, you will find that random number generators are refered to as pseudo random number generators, since computers are not very good at random behaviour. A random number generator (RNG) is typically provided with a seed value, from which it starts to create a sequence of numbers, which has the statistical properties of a random distribution. However, given the same seed value, different runs of the RNG will result in the same sequence of "random" numbers. If you want to achive non-equal sequences, you need to provide a different seed value each time you run the RNG. If you search OpenFOAM's code base for instances of calling the constructor of the RNG, you will find that OpenFOAM uses fixed seed values. Running Code:
git grep 'rndGen(' Code:
rndGen_(0) // in the constructor of KinematicCloud meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C: Random rndGen(356574); So, why use fixed seed values? First: debugging. You want your code to behave the same way each time you test it. Otherwise it's hard to distinguish a newly introduced bug from the inherent randomness. Second: is it really necessary for your code to deliver different random numbers each time you run it? Sure, if you're in information security that's essential. But in CFD? So, if you want to have different random numbers each time you run the code, provide something as seed value that's changing constantly, e.g. the time: Code:
Random ranGen(clock::getTime()); Code:
Random ranGen(clock::getTime()+pid()); |
|
June 27, 2019, 10:59 |
|
#3 |
New Member
Eduardo Cruz
Join Date: Oct 2018
Posts: 13
Rep Power: 8 |
Thanks a lot, GerhardHolzinger,
I know a little bit about pseudo-randomness. I just didn't know that OpenFOAM used a fixed seed. But your explanation makes it very clear why it is so. ECruz |
|
Tags |
distributionmodels, general distribution |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Particle tracking error | alchem | OpenFOAM Bugs | 5 | May 6, 2017 17:30 |
Particle distribution [ Length number density vs Particle diameter ] | winkungzxl | ANSYS | 1 | May 8, 2016 22:00 |
Monitor particle diameter and its frequency at a plane | Lola27 | STAR-CCM+ | 1 | December 19, 2013 06:33 |
injection problem | Mark New | FLUENT | 0 | August 4, 2013 02:30 |
forced to sticking of soot particle | kmgraju | CFX | 0 | November 27, 2012 10:08 |