Fixed shift and switch modifiers, particularly for free-energy
authorBerk Hess <hess@kth.se>
Mon, 17 Mar 2014 17:24:50 +0000 (18:24 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Thu, 5 Jun 2014 12:55:12 +0000 (14:55 +0200)
commitdced970a9c73bc251c460f1cfc40811682e9f371
tree15e9ac196649f51cb7f2c4a288e8c0f4dfa62c90
parenta75db633a2e363d48c66a440d2890592f4431d52
Fixed shift and switch modifiers, particularly for free-energy

When using tabulated interactions (historically with PME-Switch), the
previous free-energy kernels used tabulated interactions which gave
correct results. However, as we have moved to using the new
interaction modifiers, Ewald short-ranged interactions are computed
analytically. To extend the range over which we apply the soft-core
interaction, the free-energy kernels evaluated interactions by
subtracting the reciprocal-space component, and then applying the
free-energy evaluation to the Coulomb (1/r) short-range
interaction. This works fine for vanilla PME, but led to problems when
combined with a switch modifier, since we are switching a different
function compared to the non-free-energy kernels. This could lead to
large artefacts where the free energy was 100x off if we were applying
the cutoff to r while the switch was applied to the scaled soft-core
radius.

This patch modifies the free-energy kernel so that the vanilla, shift,
and exact-cutoff versions still use the compensation trick, while the
switch modifier always operates on the traditional short-range Ewald
functional form.

The (very small) Ewald shift has also been added when computing free
energy in combination with Ewald summation and potential-shift
modifiers. As the perturbation goes to zero, the interaction will also
approach the non-free-energy interactions. Tested to match the
non-free-energy kernel to with 1e-8 in the fully coupled state, it
conserves energy, and produces reasonable free energies for ethanol in
water.

This also modifies table-generation, table-usage, and
dispersion-correction code to use shift/switch forms (and correctly),
when that has been selected in the interaction modifiers. This
provides much more accurate results for our new shifted interactions.

Correct (unmodified) tables are now generated for 1-4 interactions
in a few corner cases in the presence of modifiers for non-bonded
interactions.

Code paths for using exact cutoffs now work correctly when
rcoulomb-switch != rvdw-switch, or if only one kind of switch is
active.

Free-energy calculations using a plain Coulomb interaction now
incorporate a potential shift if one exists.

The GMX_NB_GENERIC environment variable can now be used to specify the
use of the generic kernel even with shifts or switches active.

Fixes #1463.

Change-Id: Ia63a1ed7d6c9cdf9cd9e6209b6326a49043060ec
include/nonbonded.h
src/gmxlib/nonbonded/nb_free_energy.c
src/gmxlib/nonbonded/nb_generic.c
src/gmxlib/nonbonded/nonbonded.c
src/kernel/readir.c
src/mdlib/forcerec.c
src/mdlib/ns.c
src/mdlib/sim_util.c
src/mdlib/tables.c