amep.pbc.find_pairs#
- amep.pbc.find_pairs(coords: ndarray, box_boundary: ndarray, ids: ndarray | None = None, sizes: ndarray | None = None, other_coords: ndarray | None = None, other_ids: ndarray | None = None, other_sizes: ndarray | None = None, pbc: bool = True, rmax: float = 1.122) ndarray #
Identifies pairs of particles based on the pairwise distance. Particles are considered as pairs, if their distance to each other is smaller than rmax (or smaller than rmax times the contact distance of the particles assuming that the particles are spherical).
- Parameters:
coords (numpy.ndarray) – Particle coordinates as array of shape (N,3).
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]]).
ids (numpy.ndarrays|None, optional) – Particle IDs of particles in coords as array of shape (N,). The default is None.
sizes (numpy.ndarray|None, optional) – Array of size (N,) containing the size, i.e., diameter of each particle (assuming that the particles are spherical). If None, rmax is used for finding pairs. If given, rmax scales the contact distances. The default is None.
other_coords (numpy.ndarray|None, optional) – Other coordinates as array of shape (N_other, 3). If None, coords is used. The default is None.
other_ids (numpy.ndarrays|None, optional) – Particle IDs of particles in other_coords as array of shape (N_other,). The default is None.
other_sizes (numpy.ndarray|None, optional) – Array of size (N_other,) containing the size of each particle in other (assuming that the particles are spherical). If None, rmax is used for finding pairs. If given, rmax scales the contact distances. The default is None.
pbc (bool, optional) – If True, periodic boundary conditions are considered. The default is True.
rmax (float, optional) – Maximum distance between two particles for which they are considered to be pairs. The default is 1.122.
- Returns:
pairs – Particle pairs as 2d array of particle indices.
- Return type:
numpy.ndarray
Examples
>>> import amep >>> import numpy as np >>> coords = np.array( ... [[2,0,0], [1,0,0], [4,0,0], [7,0,0], [9,0,0]], ... dtype=float ... ) >>> ids = np.array([0,1,2,3,4]) >>> sizes = np.array([1,1,3,3,1], dtype=float) >>> box_boundary = np.array([[0,10],[-5,5],[0,1.0]]) >>> pairs = amep.pbc.find_pairs( ... coords, box_boundary, rmax=2, sizes=sizes ... ) >>> print(pairs) [[0 1] [1 4] [0 2] [1 2] [1 3] [4 3] [2 3]] >>> fig, axs = amep.plot.new(figsize=(3,3)) >>> amep.plot.particles(axs, coords, box_boundary, sizes/2.) >>> axs.set_xlabel(r"$x$") >>> axs.set_ylabel(r"$y$") >>> fig.savefig("./figures/pbc/pbc-find_pairs.png") >>>