  In molecular dynamics simulations under periodic boundary conditions,
particle positions are typically wrapped into a reference box. For diffusion
coefficient calculations using the Einstein relation, the particle positions
need to be unwrapped. Here, we show that a widely used heuristic unwrapping
scheme is not suitable for long simulations at constant pressure. Improper
accounting for box-volume fluctuations creates, at long times, unphysical
trajectories and, in turn, grossly exaggerated diffusion coefficients. We
propose an alternative unwrapping scheme that resolves this issue. At each time
step, we add the minimal displacement vector according to periodic boundary
conditions for the instantaneous box geometry. Here and in a companion paper
[J. Chem. Phys. XXX, YYYYY (2020)], we apply the new unwrapping scheme to
extensive molecular dynamics and Brownian dynamics simulation data. We provide
practitioners with a formula to assess if and by how much earlier results might
have been affected by the widely used heuristic unwrapping scheme.
