Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
77479d45
Commit
77479d45
authored
6 years ago
by
Folkert Nobels
Browse files
Options
Downloads
Patches
Plain Diff
Change difference between different kind of random numbers to make it robust
parent
8b553991
No related branches found
No related tags found
1 merge request
!742
Fix the random number generator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/random.h
+10
-10
10 additions, 10 deletions
src/random.h
with
10 additions
and
10 deletions
src/random.h
+
10
−
10
View file @
77479d45
...
@@ -30,22 +30,22 @@
...
@@ -30,22 +30,22 @@
* @brief The categories of random number generated.
* @brief The categories of random number generated.
*
*
* The values of the fields are carefully chose numbers
* The values of the fields are carefully chose numbers
*
T
he
se are values adviced by NR to use on page
*
t
he
numbers are very large primes such that the IDs
*
348 in the first table. We used selected 4 numbers
*
will not have a prime factorization with this coefficient
*
and know that they produce no correlation at all
*
this results in a very high period for the random number
*
for the 4 different processes
.
*
generator
.
* Only change when you know what you are doing, changing
* Only change when you know what you are doing, changing
* the numbers to bad values will break the random number
* the numbers to bad values will break the random number
* generator.
* generator.
* In case new numbers need to be added other possible
* In case new numbers need to be added other possible
* numbers could be:
* numbers could be:
* 4
162943475, 3874257210, 2654432763
* 4
947009007, 5947309451, 6977309513
*/
*/
enum
random_number_type
{
enum
random_number_type
{
random_number_star_formation
=
0LL
,
//4294957665LL,
random_number_star_formation
=
0LL
,
random_number_stellar_feedback
=
39470089
74
LL
,
random_number_stellar_feedback
=
39470089
91
LL
,
random_number_stellar_enrichment
=
29368819
68
LL
,
random_number_stellar_enrichment
=
29368819
73
LL
,
random_number_BH_feedback
=
16405313
64
LL
random_number_BH_feedback
=
16405313
71
LL
};
};
/**
/**
...
@@ -89,7 +89,7 @@ INLINE static double random_unit_interval(const long long int id,
...
@@ -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.
* in which we use the id part and the current time step bin.
*/
*/
unsigned
long
long
number
=
ti_current
;
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
);
number
=
4294957665LL
*
(
number
&
(
mwc_number
))
+
(
number
>>
32
);
/* 64-bit Xorshift (adviced variables by NR) */
/* 64-bit Xorshift (adviced variables by NR) */
number
^=
number
<<
21
;
number
^=
number
<<
21
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment