%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()
/home/diego/Myopt/miniconda3/envs/MolSysMT@uibcdf_3.12/lib/python3.12/site-packages/numpy/ma/core.py:2820: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
  _data = np.array(data, dtype=dtype, copy=copy,
../../../../_images/37d741e3eef00711f3c49287edbe20d2dcf2bf666b139e4ba69f7a98a050ca6a.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()
/home/diego/Myopt/miniconda3/envs/MolSysMT@uibcdf_3.12/lib/python3.12/site-packages/numpy/ma/core.py:2820: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
  _data = np.array(data, dtype=dtype, copy=copy,
../../../../_images/e27aa31dfec6e34abc63f28f20f66f66624f1fbc83eb9e8bd0b31ba75f3170d2.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/df066919b7b8d33623f5ba18a4446f3a26ffdb3619635750aa25116b6bddb135.png
np.allclose(molsys_unwrapped['coordinates'][:,:,:], molsys['coordinates'][:,:,:])
False