Ejemplo n.º 1
0
    def test_cms(self):
        parts = self.system.part[:]
        g = GalileiTransform()

        total_mass = np.sum(parts.mass)
        com = np.sum(np.multiply(parts.mass.reshape((-1, 1)), parts.pos),
                     axis=0) / total_mass

        np.testing.assert_allclose(np.copy(g.system_CMS()), com)
Ejemplo n.º 2
0
    def test_galilei_transform(self):
        g = GalileiTransform()
        no_virtual = self.system.part.select(virtual=False)

        # Center of mass
        np.testing.assert_allclose(
            np.copy(g.system_CMS()),
            np.average(no_virtual.pos, weights=no_virtual.mass, axis=0))
        # Center of mass velocity
        np.testing.assert_allclose(
            np.copy(g.system_CMS_velocity()),
            np.average(no_virtual.v, weights=no_virtual.mass, axis=0))