From 946a49662f8307c4ec93b142856037a9bbce6380 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 2 Oct 2020 18:43:35 -0400 Subject: [PATCH] bond/react: rmsd constraint bugfix previously, eligible reactions could have been temporarily prevented, at the edge of the box, in serial --- src/USER-REACTION/fix_bond_react.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index 814f8a0fcf..28a7ca92e7 100644 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1863,6 +1863,8 @@ int FixBondReact::check_constraints() if (prrhob < rrhandom[(int) constraints[i][2]]->uniform()) return 0; } else if (constraints[i][1] == RMSD) { // call superpose + int iatom; + int iref = -1; // choose first atom as reference int n2superpose = 0; double **xfrozen; // coordinates for the "frozen" target molecule double **xmobile; // coordinates for the "mobile" molecule @@ -1875,20 +1877,28 @@ int FixBondReact::check_constraints() int myincr = 0; for (int j = 0; j < onemol->natoms; j++) { if (onemol->fragmentmask[ifragment][j]) { + iatom = atom->map(glove[j][1]); + if (iref == -1) iref = iatom; + iatom = domain->closest_image(iref,iatom); for (int k = 0; k < 3; k++) { - xfrozen[myincr][k] = x[atom->map(glove[j][1])][k]; + xfrozen[myincr][k] = x[iatom][k]; xmobile[myincr][k] = onemol->x[j][k]; } myincr++; } } } else { + int iatom; + int iref = -1; // choose first atom as reference n2superpose = onemol->natoms; memory->create(xfrozen,n2superpose,3,"bond/react:xfrozen"); memory->create(xmobile,n2superpose,3,"bond/react:xmobile"); for (int j = 0; j < n2superpose; j++) { + iatom = atom->map(glove[j][1]); + if (iref == -1) iref = iatom; + iatom = domain->closest_image(iref,iatom); for (int k = 0; k < 3; k++) { - xfrozen[j][k] = x[atom->map(glove[j][1])][k]; + xfrozen[j][k] = x[iatom][k]; xmobile[j][k] = onemol->x[j][k]; } }