What does "seed" in makeCloud really do?

Asked by Hien Nguyen

Hello,
In the makeCloud functor:
makeCloud([(Vector3)minCorner=Vector3(0, 0, 0)[, (Vector3)maxCorner=Vector3(0, 0, 0)[, (float)rMean=-1[, (float)rRelFuzz=0[, (int)num=-1[, (bool)periodic=False[, (float)porosity=0.65[, (object)psdSizes=[][, (object)psdCumm=[][, (bool)distributeMass=False[, (int)seed=0[, (Matrix3)hSize=Matrix3(0, 0, 0, 0, 0, 0, 0, 0, 0)]]]]]]]]]]]])
There is SEED parameter.
In the example it says
 "seed" make the "random" generation always the same

and in the yade document [1] it says:
seed – number used to initialize the random number generator.

and usually I use the recommended value seed=1.

I don't understand so clearly about its effect? Is there any other explanation that is more specific?
Thanks in advance.

Hien

[1] https://yade-dem.org/doc/yade.pack.html?highlight=seed

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
Last query:
Last reply:
Revision history for this message
Best Bruno Chareyre (bruno-chareyre) said :
#1

Hi

A random generator without seed in a computer code will give (for instance, and assuming random integers):
1, 45, 12, 11, 5, 3,...
and if you run the same program another time it will be completely different:
10, 78, 3, 6, 7, ...
This is because the "randomness" is based on some digits of the computer clock, which is not very predictable and always changing.

If you give it a seed it will give always the same list of numbers. The advantage is mainly for debugging. Say, you write a script, start it, and it crashes after 1089 iterations.
To understand what's going on, you start the same script again and you stop at iteration 1089 to inspect the system.
Problem if you don't define a seed: this time it does not crash at the same iteration. The particles have different positions so the problem may occur at a different time. Really difficult to debug.
If you give a seed, you know that the exact same thing will occure each time you start the script.

Revision history for this message
Hien Nguyen (giahien) said :
#2

Thanks Bruno Chareyre, that solved my question.