  Kinetic energy equipartition is a premise for many deterministic and
stochastic molecular dynamics methods that aim at sampling a canonical
ensemble. While this is expected for real systems, discretization errors
introduced by the numerical integration may distort such assumption.
Fortunately, backward error analysis allows us to identify the quantity that is
actually subject to equipartition. This is related to a shadow Hamiltonian,
which coincides with the specified Hamiltonian only when the time-step size
approaches zero. This paper deals with discretization effects in a
straightforward way. With a small computational overhead, we obtain refined
versions of the kinetic and potential energies, whose sum is a suitable
estimator of the shadow Hamiltonian. Then, we tune the thermostatting procedure
by employing the refined kinetic energy instead of the conventional one. This
procedure is shown to reproduce a canonical ensemble compatible with the
refined system, as opposed to the original one, but canonical averages
regarding the latter can be easily recovered by reweighting. Water, modeled as
a rigid body, is an excellent test case for our proposal because its numerical
stability extends up to time steps large enough to yield pronounced
discretization errors in Verlet-type integrators. By applying our new approach,
we were able to mitigate discretization effects in equilibrium properties of
liquid water for time-step sizes up to 5 fs.
