def test_add_particle_with_valid_coordinates(self): x = self.centre[0] + self.radius / 2.0 y = self.centre[1] z = 0.0 release_zone = ReleaseZone(self.group_id, self.radius, self.centre) release_zone.add_particle(x, y, z) particle_number = release_zone.get_number_of_particles() test.assert_equal(1, particle_number)
def test_get_coords(self): x = self.centre[0] y = self.centre[1] z = 0.0 release_zone = ReleaseZone(self.group_id, self.radius, self.centre) release_zone.add_particle(x, y, z) x_coords, y_coords, z_coords = release_zone.get_coords() test.assert_array_almost_equal(x, x_coords) test.assert_array_almost_equal(y, y_coords) test.assert_array_almost_equal(z, z_coords)
def test_add_particle_with_invalid_coordinates(self): x = self.centre[0] + self.radius * 2.0 y = self.centre[1] z = 0.0 release_zone = ReleaseZone(self.group_id, self.radius, self.centre) try: release_zone.add_particle(x, y, z) except ValueError: pass particle_number = release_zone.get_number_of_particles() test.assert_equal(0, particle_number)
def test_get_centre(self): release_zone = ReleaseZone(self.group_id, self.radius, self.centre) centre = release_zone.get_centre() test.assert_almost_equal(self.centre[0], centre[0]) test.assert_almost_equal(self.centre[1], centre[1])
def test_get_area(self): release_zone = ReleaseZone(self.group_id, self.radius, self.centre) area = release_zone.get_area() test.assert_almost_equal(np.pi * self.radius * self.radius, area)
def test_get_radius(self): release_zone = ReleaseZone(self.group_id, self.radius, self.centre) radius = release_zone.get_radius() test.assert_almost_equal(self.radius, radius)
def test_get_group_id(self): release_zone = ReleaseZone(self.group_id, self.radius, self.centre) group_id = release_zone.get_group_id() test.assert_equal(self.group_id, group_id)