diff options
author | 2020-02-20 09:22:30 -0800 | |
---|---|---|
committer | 2020-02-20 09:22:30 -0800 | |
commit | 4fe858ae90dee5355fbb6c90d496ab85ac31d77b (patch) | |
tree | 13ca39262851fee22c4a28415a290c435fac0f67 /Source/WarpX.cpp | |
parent | 6e5b96e3219807c97a1161ed9dd28a22ea802d85 (diff) | |
download | WarpX-4fe858ae90dee5355fbb6c90d496ab85ac31d77b.tar.gz WarpX-4fe858ae90dee5355fbb6c90d496ab85ac31d77b.tar.zst WarpX-4fe858ae90dee5355fbb6c90d496ab85ac31d77b.zip |
Add Reset Random Seed Feature (#717)
* Add ResetRandomSeed
* Add doc
* Modify and change location of the code.
* Small fix
* Try to fix an alert
* Try to fix an alert
* Modify based on suggestions
* Use INT_MAX
* Modify based on suggestions.
* Modify based on suggestions.
Diffstat (limited to '')
-rw-r--r-- | Source/WarpX.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 8ffc22ea7..7d6637e38 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -340,6 +340,24 @@ WarpX::ReadParameters () { ParmParse pp("warpx"); + // set random seed + std::string random_seed = "default"; + pp.query("random_seed", random_seed); + if ( random_seed != "default" ) { + unsigned long myproc_1 = ParallelDescriptor::MyProc() + 1; + if ( random_seed == "random" ) { + std::random_device rd; + std::uniform_int_distribution<int> dist(2, INT_MAX); + unsigned long seed = myproc_1 * dist(rd); + ResetRandomSeed(seed); + } else if ( std::stoi(random_seed) > 0 ) { + unsigned long seed = myproc_1 * std::stoul(random_seed); + ResetRandomSeed(seed); + } else { + Abort("warpx.random_seed must be \"default\", \"random\" or an integer > 0."); + } + } + pp.query("cfl", cfl); pp.query("verbose", verbose); pp.query("regrid_int", regrid_int); |