amep.pbc.pbc_points#

amep.pbc.pbc_points(coords: ndarray, box_boundary: ndarray, enforce_nd: int | None = None, thickness: float | None = None, width: float | None = None, index: bool = False, inclusive: bool = True, verbose: bool = False, fold_coords: bool = False) ndarray#

Returns the points and their first periodic images.

Notes

Copied from mdevaluate’s pbc.py (data/robin/mdevaluate/mdevaluate) and slightly modified for 2D use.

Parameters:
  • coords (np.ndarray of shape (N,3)) – Particle coordinates.

  • box_boundary (np.ndarray of shape (3,2)) – Boundary of the simulation box in the form of np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]]).

  • enforce_nd (int, None, optional) – enforces the number of dimensions. 2 for 2d, 3 for 3d. If None is supplied, a best guess is used by checking if all particles have the same dimension in the last coordinate. See utils.dimension()

  • width (float or None, optional) – Width of the periodic images relative to the box dimensions. None means the original and all periodic images are returned; positive means points are cutoff at box*(1+width); negative values mean that less than the box is returned. At most one periodic image in each direction is returned. This keyword is preferred before thickness. The default is None.

  • thickness (float or None, optional) – Absolute width of the periodic images in each direction. None means the original and all periodic images are returned; positive means points are cutoff at box+thickness; negative values mean that less than the box is returned. If width is supplied, this keyword is ignored. The default is None.

  • index – If True, also the indices with indices of images being their original values are returned. The default is False.

  • inclusive (bool, optional) – If False, only the images are returned. The default is True.

  • fold_coords (bool, optional) – If True, points in coordinates are fold back into the box. The default is False.

  • verbose (bool, optional) – If True, some information is printed. The default is False.

Returns:

Array of all coordinates (including periodic images; array of floats)

Return type:

np.ndarray

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> frame = traj[-1]
>>> images = amep.pbc.pbc_points(
...     frame.coords(), frame.box, inclusive=False
... )
>>> perm_vectors = np.array([
...     [-1, -1,  0],
...     [-1,  0,  0],
...     [-1,  1,  0],
...     [ 0, -1,  0],
...     [ 0,  1,  0],
...     [ 1, -1,  0],
...     [ 1,  0,  0],
...     [ 1,  1,  0]
... ]).astype(float)
>>> fig, axs = amep.plot.new(figsize=(3,3))
>>> amep.plot.particles(
...     axs, images, frame.box, 0.5, color="tab:blue",
...     set_ax_limits=False
... )
>>> amep.plot.particles(
...     axs, frame.coords(), frame.box, 0.5, color="tab:orange",
...     set_ax_limits=False
... )
>>> amep.plot.box(axs, frame.box, color='k', linewidth=2)
>>> for p in perm_vectors:
...     shift = p*(frame.box[:,1]-frame.box[:,0])
...     amep.plot.box(
...         axs, frame.box+shift[:,None], color='k',
...         linewidth=1, linestyle='--'
...     )
>>> axs.set_xlabel(r'$x$')
>>> axs.set_ylabel(r'$y$')
>>> fig.savefig('./figures/pbc/pbc-pbc_points.png')
>>>
../_images/pbc-pbc_points.png