Hi,
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.
- specifically
dx = xcm2[0] - xcm[0] - xc;
dy = xcm2[1] - xcm[1] - yc;
dz = xcm2[2] - xcm[2] - zc;
When I changed this to
dx=xcm2[0]-xcm[0];
dy=xcm2[1]-xcm[1];
dz=xcm2[2]-xcm[2];
domain->minimum_image(dx,dy,dz);
dx-=xc;
dy-=yc;
dz-=zc;
(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.
Regards,
David