Example #1
0
    def test_set_force_throws_exception_for_zero_mass(self):
        testObj = Particle(self.positionList,
                           acceleration=np.array(self.acceleration),
                           mass=0)

        force = np.array([5.5, -3, 0.1])

        with self.assertRaises(ValueError):
            testObj.set_force(force)
Example #2
0
    def test_set_force_stores_expected_force_and_acceleration_value(self):
        testObj = Particle(
            self.positionList,
            acceleration=np.array(self.acceleration),
            mass=2.5,
        )

        force = np.array([5.5, -3, 0.1])

        testObj.set_force(force)

        expected_force = force
        expected_acceleration = force / 2.5

        actual_force = testObj.force
        actual_acceleration = testObj.acceleration

        np.testing.assert_equal(expected_force, actual_force)

        np.testing.assert_equal(expected_acceleration, actual_acceleration)
Example #3
0
    def test_set_force_gives_zero_acceleration_for_infinite_mass(self):
        testObj = Particle(
            self.positionList,
            acceleration=np.array(self.acceleration),
            mass=np.inf,
        )

        force = np.array([5.5, -3, 0.1])

        testObj.set_force(force)

        expected_force = force
        expected_acceleration = np.array([0, 0, 0])

        actual_force = testObj.force
        actual_acceleration = testObj.acceleration

        np.testing.assert_equal(expected_force, actual_force)

        np.testing.assert_equal(expected_acceleration, actual_acceleration)