amep.order.voronoi#
- amep.order.voronoi(coords: ndarray, box_boundary: ndarray, pbc: bool = True, width: float | None = 0.5, closed: bool = True, enforce_nd: int | None = None, verbose: bool = False) Voronoi #
Calculates the Voronoi tesselation for given coordinates by using the scipy package (see Ref. [1]). For periodic boundary conditions, a part of the box with partial width is periodically repeated around the original box. Periodic mirrors are created in case of non-periodic boundary conditions to create the correct closed voronoi diagram.
References
- Parameters:
coords (np.ndarray of shape (N,3)) – Coordinates of the particles for the voronoi tesselation.
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]]).
pbc (bool or None, optional) – Specifier whether periodic boundary conditions are used (True) or not (False). The default is True.
width (float, optional) – Relative width (to the box) of the periodic images or mirrors used. For very low densities, this value might have to be set to a larger value than the default. For higher densities, this value can easily be set to 0.3 or 0.1 or even smaller. Please check the Voronoi plot to ensure the correct calculation. Range: [0,1]. Default is 0.5.
closed (bool, optional) – If True, the closed Voronoi diagram is calculated using the mirrored boxes. If False, the open Voronoi diagram is returned which can result in unphysical measures of number of neighbors and local density. This keyword is ignored if pbc is True. The default is True.
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()
verbose (bool, optional) – If True, runtime information is printed. The default is False.
- Returns:
scipy.spatial.voronoi – scipy Voronoi object
np.ndarray or None – Indices of the points within the original box (None for opened Voronoi diagram or width=0.0).
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> frame = traj[-1] >>> vor, idx = amep.order.voronoi( ... frame.coords(), frame.box, pbc=True ... ) >>> fig, axs = amep.plot.new(figsize=(3,3)) >>> amep.plot.voronoi( ... axs, vor, show_vertices=False, ... line_colors='orange', line_width=1, ... line_alpha=0.6, point_size=1, c="b" ... ) >>> amep.plot.box(axs, frame.box) >>> axs.set_xlabel(r'$x$') >>> axs.set_ylabel(r'$y$') >>> axs.set_xlim(frame.box[0]) >>> axs.set_ylim(frame.box[1]) >>> fig.savefig('./figures/order/order-voronoi.png')