add center of mass

This commit is contained in:
rstiskalek 2022-11-25 10:54:09 +00:00
parent 161c27d995
commit 9fe745b0b4

View file

@ -425,8 +425,7 @@ class Clump:
Returns
-------
m : 1-dimensional array
Array of shape `(n_particles, )`.
m : 1-dimensional array of shape `(n_particles, )`
"""
return self._m
@ -437,6 +436,17 @@ class Clump:
raise TypeError("`r` and `m` must be equal size 1-dim arrays.")
self._m = m
@property
def center_mass(self):
"""
Clump center of mass.
Returns
-------
cm : 1-dimensional array
"""
return numpy.average(self.pos, axis=0, weights=self.m)
@property
def index(self):
"""