amep.cluster.sizes#
- amep.cluster.sizes(clusters: list) ndarray #
Calculates the sizes of the given clusters.
Parameters:#
- clusterslist
List of lists, where each list contains the indices of the particles that belong to the same cluster. If None, the geometric center of the given coords is calculated. If not None, the geometric center of each cluster in clusters is calculated, where coords must be the coordinates of the particles in clusters. The default is None.
- returns:
Sizes of the clusters.
- rtype:
np.ndarray
Examples
>>> import amep >>> import numpy as np >>> coords = np.array([[1,0,0], [4,0,0], [0.5,0,0], [4.5,0,0]]) >>> box = np.array([[-5,5],[-5,5],[-0.5,0.5]]) >>> clusters, idx = amep.cluster.identify( ... coords, box, pbc=True, rmax=0.5 ... ) >>> sizes = amep.cluster.sizes(clusters) >>> print(sizes) [2 2] >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> frame = traj[-1] >>> clusters, idx = amep.cluster.identify( ... frame.coords(), frame.box, pbc=True ... ) >>> sizes = amep.cluster.sizes(clusters) >>> print(sizes[:10]) [3611 8 7 6 6 5 5 5 4 4] >>>