  In molecular dynamics simulations in the NPT ensemble at constant pressure,
the size and shape of the periodic simulation box fluctuate with time. For
particle images far from the origin, the rescaling of the box by the barostat
results in unbounded position displacements. Special care is thus required when
a particle trajectory is unwrapped from a projection into the central box under
periodic boundary conditions to a trajectory in full three-dimensional space,
e.g., for the calculation of diffusion coefficients. Here, we review and
compare different schemes in use for trajectory unwrapping. We also specify the
corresponding rewrapping schemes to put an unwrapped trajectory back into the
central box. On this basis, we then identify a scheme for the calculation of
meaningful diffusion coefficients, which is a primary application of trajectory
unwrapping. In this scheme, the wrapped and unwrapped trajectory are mutually
consistent and their statistical properties are preserved. We conclude with
advice on best practice for the consistent unwrapping of constant-pressure
simulation trajectories and the calculation of accurate translational diffusion
coefficients.
