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
Merge release-4-6 into release-5-0

This merges commit dced970, which changes many free-energy,
modifier and table-generation code paths, and its fix 349d8056.
That patch 349d8056 contains fixes to potential-shift and
potential-switch, as well as the shift/switch interactions
in combination with free energy. Since 5.0 has undergone
changes in the same areas (both nbnxn free energy, LJ-PME
and force-switch), this commit is a likely place for
bugs to have been introduced, so we keep it as a separate
commit.

Uncrustified the result of the merge.

Conflicts:
	src/gmxlib/nonbonded/nb_free_energy.c
Resolved in favour of whichever branch seemed most right; changes from
dced970, 99aa704d and 5f59569a8 were all relevant here. We have
introduced some new LJ-PME-related variables so that code path is
reasonably similar to the coulomb path. We have also fixed a small
bug where the LJPME self-energy (i==j for verlet kernels) was not
multiplied by 0.5.

	src/gromacs/gmxlib/nonbonded/nonbonded.c
Resolved as for dced970

	src/gromacs/gmxpreprocess/readir.c
Resolved as for dced970

	src/gromacs/mdlib/forcerec.c
Resolved from both branches

	src/gromacs/mdlib/sim_util.c
Resolved from both branches, and from 349d8056

	src/gromacs/mdlib/tables.c
Resolved from both branches, and added a few lines of code
to make LJ-PME work with shift modifiers.

As noted above, to avoid breaking the 5.0 branch, we have
manually added the changes corresponding to 349d8056 to make
sure force-switch (same as vdwtype=shift) results in correct
dispersion correction, and we have added a fix for the sign
of the LJPME grid c6 term in the generic nonbonded kernels.
This means 349d8056 should not be merged in again to 5.0 later.

Change-Id: Ida29b143a1bcb727ff38f9c63bf133bf749477b1
Merge "Merge release-4-6 into release-5-0" into release-5-0