Wrap coord converting into unwrap coord by python code

Hi all,

I got a dump file with wrapped coordinate “ux,uy,uz”. And I am writing a python code to convert the dump to a dump with unwrapped coordinate “x, y, z”. And I use the method “fmod” in numpy package to get the reminder of (wrapped coordinate)/(box length). And the unwrap coordinate is computed by (the origin of box) + (reminder). But I found the results deviates from the lammps results. For example, the x unwrapped coordinate in my code is 1.922400000000000020e+01, while the lammps given as 19.1946. The y and z coordinates seems right and is coincide with lammps results. Why is this difference? Is my computation wrong? Thanks.

Best regards.

Dongbo Wang

two comments:

  • you are confusing wrapped and unwrapped. “xu, yu, zu” are unwrapped coordinates, i.e. include the distance traveled through periodic boundaries. “x, y, z” are wrapped coordinates, i.e. bounded by the principal cell (with minimal exceptions as explained in the dump command documentation).

  • how accurate you can convert one into the other after the fact depends on the precision with which to store or enter coordinates and box dimensions into your conversion code. keep in mind that if an atom has traveled through the box multiple times, the error due to the lacking precision of the box is multiplied.

Thanks for you reply. I think it results from the second comment. The atoms in my system have traveled through the box 206 times. Is there a existing code to convert the wrapped dump file to a unwrapped one?

Converting from wrapped to unwrapped is tricky, since you have to rely on the heuristic that atoms have not moved more than half a box length between two frames and then compare the current frame to the previous frame. If the trajectory was not written with a sufficient frequency, it is not possible.

I primarily use VMD for pre-/post-processing, visualizing, and analyzing trajectories and it has script tools included for both, wrapping and unwrapping of trajectories as well as trying to rejoin molecules that were broken due to coordinate wrapping with a variety of options. Of course, it is similarly subject to imprecise coordinate and box data.