%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.
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] |
|---|---|
| Units | nanometer |
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.
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()
np.allclose(molsys_unwrapped['coordinates'][:,:,:], molsys['coordinates'][:,:,:])
False