amep.cluster.inertia_tensor#
- amep.cluster.inertia_tensor(coords: ndarray, box_boundary: ndarray, mass: ndarray, pbc: bool = True, clusters: list | None = None) ndarray#
Calculates the moment of inertia tensor of the cluster containing the given coordinates. Uses the minimum image convention if pbc is True.
Parameters:#
- coordsnp.ndarray of shape (N,3)
Coordinates of all particles inside the cluster.
- box_boundarynp.ndarray of shape (3,2)
Boundary of the simulation box in the form of np.array([[xmin, xmax], [ymin, ymax], [zmin, zmax]]).
- massnp.ndarray of shape (N,)
Mass of all particles inside the cluster.
- pbcbool, optional
If True, periodic boundary conditions are considered. The default is True.
- clusterslist or None, optional
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:
Moment of inertia tensor of the given set of points or each cluster in clusters.
- rtype:
np.ndarray of shape (3,3) or (N,3,3)
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/lammps.h5amep") >>> frame = traj[-1] >>> clusters, idx = amep.cluster.identify( ... frame.coords(), frame.box, pbc=True ... ) >>> i = 1 >>> coords = frame.coords()[idx==i] >>> mass = frame.mass()[idx==i] >>> it = amep.cluster.inertia_tensor( ... coords, frame.box, mass, pbc=True ... ) >>> print(it) [[ 24639.74804688 -12499.14453125 0. ] [-12499.14453125 18386.97460938 0. ] [ 0. 0. 43026.7265625 ]] >>> its = amep.cluster.inertia_tensor( ... frame.coords(), frame.box, frame.mass(), ... pbc=True, clusters=clusters ... ) >>> print(its.shape) (52, 3, 3) >>>