%load_ext autoreload
%autoreload 2
import molsysmt as msm
import numpy as np
import matplotlib.pyplot as plt

Unwrap#

molsys = msm.convert(msm.systems['two LJ particles']['traj_two_lj_particles.trjpk'],
                     to_form='molsysmt.StructuresDict')
for particle, coordinate in [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)]:
    plt.scatter(molsys['time'], molsys['coordinates'][:, particle, coordinate], s=1, color='grey', marker='.')
plt.show()
MOLSYSMT WARNING | UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
../../../../_images/b95e0ff297db64fbbd67bbdaf92b11624c5d780bf1e40198527fd297633bae9e.png
box_shape, box_lengths = msm.get(molsys, element='system', box_shape=True, box_lengths=True)
box_shape
'cubic'
box_lengths[0]
Magnitude
[3.0 3.0 3.0]
Unitsnanometer
molsys_wrapped = msm.pbc.wrap_to_pbc(molsys)
for particle, coordinate in [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)]:
    plt.scatter(molsys_wrapped['time'], molsys_wrapped['coordinates'][:, particle, coordinate], s=1, color='grey', marker='.')
plt.show()
MOLSYSMT WARNING | UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
../../../../_images/f4e97896203a8a1c139ca8c10729e332922296f3463f1005aa84792e463c44dc.png
molsys_unwrapped = msm.pbc.unwrap(molsys_wrapped)
for particle, coordinate in [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2)]:
    plt.scatter(molsys_unwrapped['time'], molsys_unwrapped['coordinates'][:, particle, coordinate], s=1, color='grey', marker='.')
plt.show()
../../../../_images/6b25c04e04514245de8d57db0c027e39545fa95e54b530029ef89b579bfbfa1b.png
np.allclose(molsys_unwrapped['coordinates'][:,:,:], molsys['coordinates'][:,:,:])
False