diff --git a/doc/src/fix_atom_swap.txt b/doc/src/fix_atom_swap.txt index 22091eca00..cb6bc26aa1 100644 --- a/doc/src/fix_atom_swap.txt +++ b/doc/src/fix_atom_swap.txt @@ -141,11 +141,16 @@ specify if this should be done. This fix writes the state of the fix to "binary restart files"_restart.html. This includes information about the random -number generator seed, the next timestep for MC exchanges, etc. See +number generator seed, the next timestep for MC exchanges, the number +of exchange attempts and successes etc. See the "read_restart"_read_restart.html command for info on how to re-specify a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. diff --git a/doc/src/fix_deposit.txt b/doc/src/fix_deposit.txt index fd12d4bb45..9ab125a55f 100644 --- a/doc/src/fix_deposit.txt +++ b/doc/src/fix_deposit.txt @@ -261,6 +261,10 @@ next timestep for deposition, etc. See the a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various "output commands"_Howto_output.html. No parameter diff --git a/doc/src/fix_gcmc.txt b/doc/src/fix_gcmc.txt index 8a66a007a3..3c0f2c2f17 100644 --- a/doc/src/fix_gcmc.txt +++ b/doc/src/fix_gcmc.txt @@ -373,11 +373,16 @@ adds all inserted atoms of the specified type to the This fix writes the state of the fix to "binary restart files"_restart.html. This includes information about the random -number generator seed, the next timestep for MC exchanges, etc. See +number generator seed, the next timestep for MC exchanges, the number +of MC step attempts and successes etc. See the "read_restart"_read_restart.html command for info on how to re-specify a fix in an input script that reads a restart file, so that the operation of the fix continues in an uninterrupted fashion. +NOTE: For this to work correctly, the timestep must [not] be changed +after reading the restart with "reset_timestep"_reset_timestep.html. +The fix will try to detect it and stop with an error. + None of the "fix_modify"_fix_modify.html options are relevant to this fix. diff --git a/src/MC/fix_atom_swap.cpp b/src/MC/fix_atom_swap.cpp index 12b5d65f4a..7d817ffbb1 100644 --- a/src/MC/fix_atom_swap.cpp +++ b/src/MC/fix_atom_swap.cpp @@ -771,10 +771,13 @@ double FixAtomSwap::memory_usage() void FixAtomSwap::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[6]; list[n++] = random_equal->state(); list[n++] = random_unequal->state(); - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; + list[n++] = nswap_attempts; + list[n++] = nswap_successes; + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -798,5 +801,12 @@ void FixAtomSwap::restart(char *buf) seed = static_cast (list[n++]); random_unequal->reset(seed); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; + + nswap_attempts = static_cast(list[n++]); + nswap_successes = static_cast(list[n++]); + + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting fix atom/swap"); } diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index f1664e3540..7ab0879335 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -2531,10 +2531,19 @@ double FixGCMC::memory_usage() void FixGCMC::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[12]; list[n++] = random_equal->state(); list[n++] = random_unequal->state(); - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; + list[n++] = ntranslation_attempts; + list[n++] = ntranslation_successes; + list[n++] = nrotation_attempts; + list[n++] = nrotation_successes; + list[n++] = ndeletion_attempts; + list[n++] = ndeletion_successes; + list[n++] = ninsertion_attempts; + list[n++] = ninsertion_successes; + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -2558,7 +2567,20 @@ void FixGCMC::restart(char *buf) seed = static_cast (list[n++]); random_unequal->reset(seed); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; + + ntranslation_attempts = list[n++]; + ntranslation_successes = list[n++]; + nrotation_attempts = list[n++]; + nrotation_successes = list[n++]; + ndeletion_attempts = list[n++]; + ndeletion_successes = list[n++]; + ninsertion_attempts = list[n++]; + ninsertion_successes = list[n++]; + + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting fix gcmc"); } void FixGCMC::grow_molecule_arrays(int nmolatoms) { diff --git a/src/MISC/fix_deposit.cpp b/src/MISC/fix_deposit.cpp index 1428299eb7..66aed34846 100644 --- a/src/MISC/fix_deposit.cpp +++ b/src/MISC/fix_deposit.cpp @@ -798,11 +798,12 @@ void FixDeposit::options(int narg, char **arg) void FixDeposit::write_restart(FILE *fp) { int n = 0; - double list[4]; + double list[5]; list[n++] = random->state(); list[n++] = ninserted; list[n++] = nfirst; - list[n++] = next_reneighbor; + list[n++] = ubuf(next_reneighbor).d; + list[n++] = ubuf(update->ntimestep).d; if (comm->me == 0) { int size = n * sizeof(double); @@ -823,7 +824,11 @@ void FixDeposit::restart(char *buf) seed = static_cast (list[n++]); ninserted = static_cast (list[n++]); nfirst = static_cast (list[n++]); - next_reneighbor = static_cast (list[n++]); + next_reneighbor = (bigint) ubuf(list[n++]).i; + + bigint ntimestep_restart = (bigint) ubuf(list[n++]).i; + if (ntimestep_restart != update->ntimestep) + error->all(FLERR,"Must not reset timestep when restarting this fix"); random->reset(seed); }