Skip to content
Snippets Groups Projects
Commit 77479d45 authored by Folkert Nobels's avatar Folkert Nobels
Browse files

Change difference between different kind of random numbers to make it robust

parent 8b553991
Branches
Tags
1 merge request!742Fix the random number generator
......@@ -30,22 +30,22 @@
* @brief The categories of random number generated.
*
* The values of the fields are carefully chose numbers
* These are values adviced by NR to use on page
* 348 in the first table. We used selected 4 numbers
* and know that they produce no correlation at all
* for the 4 different processes.
* the numbers are very large primes such that the IDs
* will not have a prime factorization with this coefficient
* this results in a very high period for the random number
* generator.
* Only change when you know what you are doing, changing
* the numbers to bad values will break the random number
* generator.
* In case new numbers need to be added other possible
* numbers could be:
* 4162943475, 3874257210, 2654432763
* 4947009007, 5947309451, 6977309513
*/
enum random_number_type {
random_number_star_formation = 0LL, //4294957665LL,
random_number_stellar_feedback = 3947008974LL,
random_number_stellar_enrichment = 2936881968LL,
random_number_BH_feedback = 1640531364LL
random_number_star_formation = 0LL,
random_number_stellar_feedback = 3947008991LL,
random_number_stellar_enrichment = 2936881973LL,
random_number_BH_feedback = 1640531371LL
};
/**
......@@ -89,7 +89,7 @@ INLINE static double random_unit_interval(const long long int id,
* in which we use the id part and the current time step bin.
*/
unsigned long long number = ti_current;
/* Multiply with carry (MWC) */
/* Multiply with carry (MWC), (adviced variables by NR) */
number = 4294957665LL * (number & (mwc_number)) + (number >> 32);
/* 64-bit Xorshift (adviced variables by NR) */
number ^= number << 21;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment