diff --git a/src/DPD-MESO/pair_mdpd.cpp b/src/DPD-MESO/pair_mdpd.cpp index bdadb8fb23..53994800d0 100644 --- a/src/DPD-MESO/pair_mdpd.cpp +++ b/src/DPD-MESO/pair_mdpd.cpp @@ -217,9 +217,12 @@ void PairMDPD::settings(int narg, char **arg) seed = utils::inumeric(FLERR,arg[2],false,lmp); // initialize Marsaglia RNG with processor-unique seed + // create a positive seed based on the system clock, if requested. - if (seed <= 0) - seed = (int) (platform::walltime() * 1073741824.0); + if (seed <= 0) { + constexpr double LARGE_NUM = 2<<30; + seed = int(fmod(platform::walltime() * LARGE_NUM, LARGE_NUM)) + 1; + } delete random; random = new RanMars(lmp,(seed + comm->me) % 900000000); diff --git a/src/DPD-MESO/pair_tdpd.cpp b/src/DPD-MESO/pair_tdpd.cpp index 1f48e12f55..70168c0e2a 100644 --- a/src/DPD-MESO/pair_tdpd.cpp +++ b/src/DPD-MESO/pair_tdpd.cpp @@ -239,9 +239,12 @@ void PairTDPD::settings(int narg, char **arg) seed = utils::inumeric(FLERR,arg[2],false,lmp); // initialize Marsaglia RNG with processor-unique seed + // create a positive seed based on the system clock, if requested. - if (seed <= 0) - seed = (int) (platform::walltime() * 1073741824.0); + if (seed <= 0) { + constexpr double LARGE_NUM = 2<<30; + seed = int(fmod(platform::walltime() * LARGE_NUM, LARGE_NUM)) + 1; + } delete random; random = new RanMars(lmp,(seed + comm->me) % 900000000);