Exemple #1
0
    def setUp(self):
        """
        Default setup and tests used for 3D NNPS tests

        We run the tests on the following pairs of particle arrays:

        Set 1) Same particle arrays. Both have constant h.
        1) a -> a
        2) b -> b

        Set 2) Different particle arrays with constant h.
        1) a -> b
        2) b -> a

        Set 3) Variable h
        1) c -> c
        2) d -> d

        We then repeat the above tests again to ensure that we get the
        correct results even when running NNPS repeatedly
        """
        NNPSTestCase.setUp(self)
        self.nps = nnps.DictBoxSortNNPS(
            dim=3, particles=self.particles, radius_scale=2.0
        )
Exemple #2
0
    def setUp(self):
        """Default set-up used by all the tests

        Particles with the following coordinates (x, y, z) are placed in a box

        0 : -1.5 , 0.25 , 0.5
        1 : 0.33 , -0.25, 0.25
        2 : 1.25 , -1.25, 1.25
        3 : 0.05 , 1.25 , -0.5
        4 : -0.5 , 0.5  , -1.25
        5 : -0.75, 0.75 , -1.25
        6 : -1.25, 0.5  , 0.5
        7 : 0.5  , 1.5  , -0.5
        8 : 0.5  , -0.5 , 0.5
        9 : 0.5  , 1.75 , -0.75

        The cell size is set to 1. Valid cell indices and the
        particles they contain are given below:

        (-2, 0, 0) : particle 0, 6
        (0, -1, 0) : particle 1, 8
        (1, -2, 1) : particle 2
        (0, 1, -1) : particle 3, 7, 9
        (-1, 0, -2): particle 4, 5

        """
        x = numpy.array([
            -1.5, 0.33, 1.25, 0.05, -0.5, -0.75, -1.25, 0.5, 0.5, 0.5])

        y = numpy.array([
            0.25, -0.25, -1.25, 1.25, 0.5, 0.75, 0.5, 1.5, -0.5, 1.75])

        z = numpy.array([
            0.5, 0.25, 1.25, -0.5, -1.25, -1.25, 0.5, -0.5, 0.5, -0.75])

        # using a degenrate (h=0) array will set cell size to 1 for NNPS
        h = numpy.zeros_like(x)

        pa = get_particle_array(x=x, y=y, z=z, h=h)

        self.dict_box_sort_nnps = nnps.DictBoxSortNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        self.box_sort_nnps = nnps.BoxSortNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        self.ll_nnps = nnps.LinkedListNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        self.sp_hash_nnps = nnps.SpatialHashNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        self.ext_sp_hash_nnps = nnps.ExtendedSpatialHashNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        self.strat_radius_nnps = nnps.StratifiedHashNNPS(
            dim=3, particles=[pa], radius_scale=1.0
        )

        # these are the expected cells
        self.expected_cells = {
            IntPoint(-2, 0, 0): [0, 6],
            IntPoint(0, -1, 0): [1, 8],
            IntPoint(1, -2, 1): [2],
            IntPoint(0, 1, -1): [3, 7, 9],
            IntPoint(-1, 0, -2): [4, 5]
        }
Exemple #3
0
 def setUp(self):
     NNPS2DTestCase.setUp(self)
     self.nps = nnps.DictBoxSortNNPS(
         dim=2, particles=self.particles, radius_scale=2.0
     )