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
Fixed typo in description of conversion factors.

Change-Id: I5f9875ef94e8d5526f84c029f539fab642319a04
Issue a warning for using gmx_rms -prev with large trajectories.

Refs #716.

Change-Id: I607d6a63259e0dd9de7c8c99e4917bbe9f37ff8e
Process negative sigma correctly with combrule 2 or 3

The initial combination rule code (for sigma/epsilon)
did not take negative sigma rules into account, which
caused segfaults instead of the values reaching the code
in convparm.c that handles sigma<0 during conversion
to c6/c12 (where it is used to signal c6=0).

Fixes #1391.

Change-Id: I437f06d67c5ecfb58d236590288ad122bcdf2df0
Print in higher precision repl_ex timestep.

Fixes #1486.

Change-Id: Ibe5bcee18f761bea96e1b4a432774a4472a40f47
Avoid writing xvgr formatting with -xvg none

Several tools were writing xvgr formatting code directly
to output files, even when the users selects -xvg none as
a command line option.

Fixes #1407, #1479.

Change-Id: I1db10c2ad7455332e2a415a922885cddaec5efd1
Made repl_ex time step more readable

A recent change made the repl_ex time print %e, now it's %.5f,
as in the log file.

Refs #1486.

Change-Id: I2e669d91a61e6a696ce6d123c701fa8b773a3c2f
Mapped HIS1 to HSD in charmm27.

Fixes #1133.

Change-Id: I6c289af9b58c8e7cd66f36982bf118505aa38f7d
Make sure genrestr uses the disre_up2 parameter

Previously, a constant value of 1.0 was used instead of the
margin read from the command line.

Fixes #1357.

Change-Id: I65ef225159e7b6ef818c71d062b619e78fa7ea22
Made gmxcheck -rmsd work again with forces

Change-Id: I776b282b17ee7c6cc4e56130dd804aa0ea04bce6
Fixed perturbed wall interactions

With free-energy calculations, the B-state wall force and potential
were set to zero.
Fixes #1501

Change-Id: Ib53073c19fee19979ade96455b6505001187a2fa
Added dummy mass for charmm TYR aromatic vsites

pdb2gmx was not able to create aromatic vsites
for charmm27 since this dummy mass center was missing.
Note that aromatic vsites are still largely untested,
and not recommended for general usage.

Fixes #587.

Change-Id: Ic7d2976536c6269d1dcf12b7d33bddab096c353f
Made shells work with the Verlet scheme

The issue was that atoms iso charge group should be put in the box.
Additionally water_pol only worked within a charge group, now fixed.
Note that with shells working across charge groups, which is always
the case with the Verlet scheme, no shell prediction is done.
We should implement prediction, since it improves performance.

Fixes #1429.

Change-Id: I2ebfc2d91fc161167f8f2573b61e1f519cf11fd8
Force g_bond to use structure file

Previous versions of Gromacs never wrote broken molecules, but
this is no longer true for domain decomposition. Box dimensions
are set from the trajectory, but the molecular connectivity
from the structure file.

Fixes #834.

Change-Id: I61ecb4957ef11e03bfeef10095a406cbddd23a34
Fix memory-usage error in g_chi

Out of array bounds writing error as pointed out by valgrind
is fixed by this patch, preventing a SEGV.

Fixes #1503

Change-Id: I57959f4751f3eb645ff66bbcd4418607af56c1a4
Changed appending file name error message

The error message now mentiones potential names issues.

Fixes #1497.

Change-Id: I0c0195abd21c5012b49119024505b18a906078be
Make sure figure legends are adapted to xmgr/xmgrace

A few programs were not using the xvgr_legend call. g_mdmat
has been modified to use it, and for g_analyse and g_enemat
I at least fixed the existing direct-writing code by adding
a conditional.

Fixes #783.

Change-Id: I782af539b93737b570f266ba744e718fbd846e5f
Fixed PME bug with #OpenMP-threads a large prime

With hybrid MPI+OpenMP parallelization and the rank local FFT grid
size for a dimension not divisible by the number of OpenMP threads
in that dimension, a very small amount of the FFT grid overlap part
could set/added twice. This would only occur at low-medium MPI
parallelization with OpenMP thread counts with large prime factors,
which is practice means almost never. Even when it occured, no actual
differences in PME energies or forces were observed.
This issue was due to a leftover from when space was uniformly
divided over the grids iso assigning whole grid lines.

Fixes #1388.

Change-Id: I22904c7f55d2e96fc4b8cd1498af2087eaed47ac
Removed rounding issue in nbnxn Ewald table

The nbnxn Ewald table could got the spacing dx passed as a real.
Changing this to double improves the accuracy of the single precision
table by two orders of magnitude, because rounding errors are avoided.

Change-Id: I11b6c27bd3f4e306c412da8f01761b03dc337ce7
Fix that skipping fails if target is 2nd frame

With bSeekForwardOnly the current file position should be an inclusive boundary,
but because the binary search stops if the search region (high-low) becomes
header_size, the current frame wasn't found. Because trjconv always reads the
first frame before calling seek, it failed if the target was the 2nd frame.

Fixes #1154

Change-Id: Id4151f0106abdb68d6067f02fe2927a4ec6d77a0