diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 76129569d4..9f9b504c33 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -1197,6 +1197,8 @@ void FixGCMC::attempt_atomic_translation_full() double **x = atom->x; double xtmp[3]; + + tagint tmptag = -1; if (i >= 0) { @@ -1232,6 +1234,8 @@ void FixGCMC::attempt_atomic_translation_full() x[i][0] = coord[0]; x[i][1] = coord[1]; x[i][2] = coord[2]; + + tmptag = atom->tag[i]; } double energy_after = energy_full(); @@ -1241,10 +1245,12 @@ void FixGCMC::attempt_atomic_translation_full() energy_stored = energy_after; ntranslation_successes += 1.0; } else { - if (i >= 0) { - x[i][0] = xtmp[0]; - x[i][1] = xtmp[1]; - x[i][2] = xtmp[2]; + for (int i = 0; i < atom->nlocal; i++) { + if (tmptag == atom->tag[i]) { + x[i][0] = xtmp[0]; + x[i][1] = xtmp[1]; + x[i][2] = xtmp[2]; + } } energy_stored = energy_before; }