I’ve been trying to use fix spring in the couple mode to perform umbrella sampling simulations and found that when separation vector between the two fix groups crosses a periodic boundary the forces/energy from the fix are incorrect (via comparing the forces/energies output from the fix to the analytic spring force/energy).
Checking the code I found that the minimum image convention wasn’t being applied when the separation vector between the groups was calculated.
dx = xcm2 - xcm - xc;
dy = xcm2 - xcm - yc;
dz = xcm2 - xcm - zc;
When I changed this to
(I confess I have only checked the case when the xc=yc=zc=0 but I think the should be subtracted off after the minimum image correction) the output from the fix agrees with the analytic value. I can’t think of any reason why the minimum image convention wasn’t being applied here (but am prepared to be corrected) - this would also affect simulations where the separation between the groups is comparable to half the box length.