def test_list(self):
     particle_positions = np.array([[19, -18]])
     box_space = np.array([4, 4])
     cutoff = 1
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     print(s1.calculate_index(np.array([-1, 1])))
     print(s1.cell_neighbour_list_2D())
 def test_list3d(self):
     particle_positions = np.array([[9, 6, 4]])
     box_space = np.array([8, 6, 4])
     cutoff = 2
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     print(s1.calculate_index(np.array([1, 0, 0])))
     lol = s1.cell_neighbour_list_3D()
     print(lol)
Esempio n. 3
0
    def __init__(self, particles, parameters):
        self.particles = particles
        self.energy = Energy()
        self.k_vectors = [1, 1, 1]

        particle_positions = self.get_particle_position_array()

        self.neighbourlist = Neighbourlist(particles=particle_positions, Box=parameters.box, rc=parameters.cutoff_radius)

        if System.cell_neighbour_list is None:
            System.cell_neighbour_list = self.neighbourlist.calc_cell_neighbours()
 def test_benchmark(self):
     particle_positions = []
     for i in range(0, 100000):
         xtest = np.random.rand(3)
         particle_positions.append(xtest)
     particle_positions = np.array(particle_positions)
     box_space = np.array([50, 50, 50])
     cutoff = 2
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     print("rdy")
     for i in range(10):
         s1.construct_neighbourlist()
     print(s1.cell_list)
     print(s1.particle_neighbour_list)
Esempio n. 5
0
 def test_cnlist1d_1(self):
     particle_positions = np.array([[9], [4], [1]])
     box_space = np.array([12])
     cutoff = 3
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     print(s1.calculate_index(np.array([1, 0, 0])))
     reference_CnList = np.array([[3, 0, 1, 2], [0, 1, 2, 3], [1, 2, 3, 0]])
     cnlist = s1.cell_neighbour_list_1D()
     print(cnlist)
     sorted_referenceCnList = np.sort(reference_CnList, axis=0)
     sorted_outputCnList = np.sort(cnlist[:, :, 0], axis=0)
     npt.assert_equal(sorted_referenceCnList,
                      sorted_outputCnList,
                      'Failed',
                      verbose=True)
Esempio n. 6
0
class System:
    cell_neighbour_list = None

    # Test Positions are same dimension

    def __init__(self, particles, parameters):
        self.particles = particles
        self.energy = Energy()

        particle_positions = self.get_particle_position_array()

        self.neighbourlist = Neighbourlist(particles=particle_positions,
                                           Box=parameters.box,
                                           rc=parameters.cutoff_radius)

        if System.cell_neighbour_list is None:
            System.cell_neighbour_list = self.neighbourlist.calc_cell_neighbours(
            )

    def get_particle_position_array(self):

        x = []
        for i in range(len(self.particles)):
            x.append(self.particles[i].position)
        y = np.array(x)

        return y
    def test_1d(self):
        particle_positions = np.array([[1], [0], [3], [4], [0]])
        box_space = np.array([4])
        cutoff = 2
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.cell_list)
        print(s1.particle_neighbour_list)
Esempio n. 8
0
 def test_determine_box_shift(self):
     EC = EnergyCalculator(box=np.array([2, 3, 2]),
                           cutoff_radius=1,
                           es_sigma=1,
                           charges=np.array([1]),
                           lj_sigmas=np.array([1]),
                           lj_epsilons=np.array([1]),
                           k_vector=np.array([[1]]))
     vector1 = np.array([3, 4, 1])
     NL = Neighbourlist(Box=np.array([2, 3, 2]),
                        particles=np.array([[3, 4, 1]]),
                        rc=1)
     cell_nl = NL.cell_neighbour_list_3D()
     EC.cell_neighbour_list = cell_nl
     calc_shift = EC._determine_box_shift(0, 2)
     reference_shift = np.array([-2, 0, 0])
     self.assertTrue(np.array_equal(calc_shift, reference_shift))
Esempio n. 9
0
    def __init__(self, particles, parameters):
        self.particles = particles
        self.energy = Energy()
        self.k_vectors = [1, 1, 1]

        x = []
        for i in range(len(particles)):
            x.append(particles[i].position)
        y = np.array(x)

        self.neighbourlist = Neighbourlist(particles=y,
                                           Box=parameters.box,
                                           rc=parameters.cutoff_radius)

        if System.cell_neighbour_list is None:
            System.cell_neighbour_list = self.neighbourlist.calc_cell_neighbours(
            )
    def test_periodicity(self):
        particle_positions = np.array([[19, -18]], dtype=np.int32)
        box_space = np.array([2, 2], dtype=np.int32)
        cutoff = 1
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.cell_list)
        print(s1.particle_neighbour_list)
    def test_3dsecond(self):
        particle_positions = np.array([[9, 6, 4], [2.25, 2, 2], [2.3, 4, 1], [9, 4, 2], [0, 0, 0]])
        box_space = np.array([9, 6, 4])
        cutoff = 2
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.cell_list)
        print(s1.particle_neighbour_list)
    def test_3d(self):
        particle_positions = np.array([[1, 1, 3], [0, 3, 1], [3, 4, 2], [4, 4, 4], [0, 0, 0]])
        box_space = np.array([4, 4, 4])
        cutoff = 2
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.cell_list)
        print(s1.particle_neighbour_list)
    def test_2dsecond(self):
        particle_positions = np.array(
            [[0.01, 0.01], [0, 0.03], [0.03, 0.04], [0.05, 0.05], [0.09, 0.09], [0.09, 0], [0.1, 0.1]])
        box_space = np.array([0.10, 0.10])
        cutoff = 0.025
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.particle_neighbour_list)
        print(s1.cell_list)
 def test_string_value(self):
     # particle_position_dimension_diff_with_box
     particle_positions = np.array([[0.0, 0.5], [1.5, 4.5], [2.5, 2.5],
                                    [3.0, 4.5], [4.5, 5.5], [5.5, 3.5],
                                    [6.0, 5.0], [6.5, 9.5], [7.0, 1.1],
                                    [8.25, 2.0], [9.75, 11.0], ['h', 'm']])
     box_space = np.array([10.5, 11.0])
     cutoff = 4.6
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
 def test_2d_output_validation_2(self):
     particle_positions = np.array([[13.5, 2.], [14., 5.], [-2., 2.], [25.5, 2.],
                                    [-14., 2.], [13.5, 15.], [-1., -2.]])
     box_space = np.array([12., 13.])
     cutoff = 3
     reference_head = np.asarray([5, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, 6])
     reference_neighlist = np.asarray([-1, -1, -1, 0, 2, 3, -1])
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     npt.assert_equal(reference_head, s1.cell_list, 'Failed', verbose=True)
     npt.assert_equal(reference_neighlist, s1.particle_neighbour_list, 'Failed', verbose=True)
 def test_cnlist2d_1(self):
     particle_positions = np.array([[9, 6], [4, 5], [1, 3]])
     box_space = np.array([12, 13])
     cutoff = 3
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     reference_CnList = np.array([
         [13, 14, 15, 12, 1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8],
         [1, 2, 3, 0, 5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12],
         [5, 6, 7, 4, 9, 10, 11, 8, 13, 14, 15, 12, 1, 2, 3, 0],
         [12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
         [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
         [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3],
         [15, 12, 13, 14, 3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10],
         [3, 0, 1, 2, 7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14],
         [7, 4, 5, 6, 11, 8, 9, 10, 15, 12, 13, 14, 3, 0, 1, 2]
     ])
     cnlist = s1.cell_neighbour_list_2D()
     sorted_referenceCnList = np.sort(reference_CnList, axis=0)
     sorted_outputCnList = np.sort(cnlist[:, :, 0], axis=0)
     npt.assert_equal(sorted_referenceCnList, sorted_outputCnList, 'Failed', verbose=True)
    def test_Bench(self):
        particle_positions = []
        for i in range(0, 100000):
            xtest = np.random.rand(2)
            particle_positions.append(xtest)
        particle_positions = np.array(particle_positions)
        box_space = np.array([1, 1])
        cutoff = 0.1
        s1 = Neighbourlist(particle_positions, box_space, cutoff)

        print(s1.cell_list)
        print(s1.particle_neighbour_list)
 def test_1d_output_validation_2(self):
     particle_positions = np.array([[1.5], [2.5],
                                    [3.0], [4.5], [5.5],
                                    [6.0], [6.5], [7.0],
                                    [8.25], [9.75], [10.0], [11.5], [12.5]])
     reference_head = np.asarray([12.0, 6.0, 9.0])
     reference_neighlist = np.asarray([-1.0, 0.0, 1.0, -1.0, 3.0, 4.0, 5.0, -1.0, 7.0, 8.0, 2.0, 10.0, 11.0])
     box_space = np.array([10])
     cutoff = 3
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     npt.assert_equal(reference_head, s1.cell_list, 'Failed', verbose=True)
     npt.assert_equal(reference_neighlist, s1.particle_neighbour_list, 'Failed', verbose=True)
 def test_2d_output_validation_1(self):
     particle_positions = np.array([[1.5, 2.], [2, 5.], [2.5, 8.],
                                    [4., 4.], [4., 8.], [5.5, 9.],
                                    [8., 11.], [7., 2.], [6., 5.],
                                    [6., 6.5], [7., 6.5], [10., 2.],
                                    [11., 9.], [11., 11.], [13.5, 2.],
                                    [14., 5.], [-2., 2.], [25.5, 2.],
                                    [-14., 2.], [13.5, 15.], [-1., -2.]])
     box_space = np.array([12., 13.])
     cutoff = 3
     reference_head = np.asarray([19, 15, 2, -1, -1, 3, 5, -1, 7, 8, 10, 6, 18, -1, 12, 20])
     reference_neighlist = np.asarray([-1, -1, -1, -1, -1, 4, -1, -1, -1, -1, 9,
                                       -1, -1, -1, 0, 1, 11, 14, 16, 17, 13])
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     npt.assert_equal(reference_head, s1.cell_list, 'Failed', verbose=True)
     npt.assert_equal(reference_neighlist, s1.particle_neighbour_list, 'Failed', verbose=True)
    def test_3d_output_validation(self):
        particle_positions = np.array([[1.5, 1., 2.5], [1.5, 4., 2.5], [1.5, 8.5, 2.5],
                                       [1.5, 1., 5.5], [1.5, 4., 5.5], [1.5, 5.5, 5.5],
                                       [1.5, 10., 5.5], [1.5, 1., 8.5], [1.5, 4., 8.5],
                                       [1.5, 8.5, 8.5], [1.5, 4., 11.5], [1.5, 11.5, 11.5],
                                       [4.5, 1., 2.5], [4.5, 5.5, 2.5], [4.5, 7., 2.5],
                                       [4.5, 1., 5.5], [4.5, 4., 5.5], [4.5, 5.5, 5.5],
                                       [4.5, 7., 5.5], [4.5, 10., 5.5], [4.5, 2.5, 8.5],
                                       [4.5, 4., 8.5], [4.5, 5.5, 8.5], [4.5, 8.5, 8.5],
                                       [4.5, 1., 11.5], [4.5, 5.5, 11.5], [7.5, 1., 2.5],
                                       [7.5, 5.5, 2.5], [7.5, 7., 2.5], [7.5, 11.5, 2.5],
                                       [7.5, 1., 5.5], [7.5, 4., 5.5], [7.5, 5.5, 5.5],
                                       [7.5, 10., 5.5], [7.5, 2.5, 8.5], [7.5, 5.5, 8.5],
                                       [7.5, 7., 8.5], [7.5, 11.5, 8.5], [7.5, 4., 11.5],
                                       [7.5, 7., 11.5], [10.5, 1., 2.5], [10.5, 5.5, 2.5],
                                       [10.5, 11.5, 2.5], [10.5, 1., 5.5], [10.5, 2.5, 5.5],
                                       [10.5, 4., 5.5], [10.5, 10., 5.5], [10.5, 11.5, 5.5],
                                       [10.5, 1., 8.5], [10.5, 4., 8.5], [10.5, 11.5, 8.5],
                                       [10.5, 1., 11.5], [10.5, 4., 11.5], [10.5, 11.5, 11.5],
                                       [3., 3.25, 3.5], [6.0, 6.5, 7.0], [6.5, 5.0, 7.0],
                                       [8.0, 6.5, 7.0], [12.0, 6.5, 7.0], [12.0, 6.5, 3.5],
                                       [12.0, 13.0, 7.0], [6.0, 13.0, 7.0], [13.5, 1., 5.5],
                                       [13.5, 4., 5.5], [13.5, 5.5, 5.5], [13.5, 10., 5.5],
                                       [13.5, 14, 5.5], [13.5, 15.5, 5.5], [-1.5, 1., 5.5],
                                       [-1.5, 2.5, 5.5], [-1.5, 4., 5.5], [-1.5, 10., 5.5],
                                       [-1.5, 11.5, 5.5]])

        box_space = np.array([12., 13., 14.])
        reference_head = np.asarray([0, 67, 60, -1, 1, 64, 8, 10, 2, 59, 58, -1, -1, 65, -1, 11,
                                     12, 15, 20, 24, 13, 54, 22, 25, 14, 18, 23, -1, -1, 19, -1,
                                     - 1, 26, 30, 61, -1, 27, 32, 56, 38, 28, -1, 57, 39, 29, 33,
                                     37, -1, 40, 69, 48, 51, 41, 70, 49, 52, -1, -1, -1, -1, 42,
                                     72, 50, 53])
        reference_neighlist = np.asarray([-1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1,
                                          - 1, -1, -1, 16, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1,
                                          - 1, -1, -1, -1, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1,
                                          - 1, -1, 43, -1, -1, 46, -1, -1, -1, -1, -1, -1, 17, 36,
                                          35, 55, 9, -1, 7, 34, 3, 5, 63, 6, 62, 66, 44, 68, 45,
                                          47, 71, ])

        cutoff = 3
        s1 = Neighbourlist(particle_positions, box_space, cutoff)
        npt.assert_equal(reference_head, s1.cell_list, 'Failed', verbose=True)
        npt.assert_equal(reference_neighlist, s1.particle_neighbour_list, 'Failed', verbose=True)
Esempio n. 21
0
 def test_cnlist3d_2(self):
     particle_positions = np.array([[9, 6, 4], [4, 5, 6], [1, 3, 6]])
     box_space = np.array([12, 10, 10])
     cutoff = 3
     s1 = Neighbourlist(particle_positions, box_space, cutoff)
     reference_CnList = np.array(
         [[
             31, 32, 30, 34, 35, 33, 28, 29, 27, 4, 5, 3, 7, 8, 6, 1, 2, 0,
             13, 14, 12, 16, 17, 15, 10, 11, 9, 22, 23, 21, 25, 26, 24, 19,
             20, 18
         ],
          [
              4, 5, 3, 7, 8, 6, 1, 2,
              0, 13, 14, 12, 16, 17, 15, 10, 11,
              9, 22, 23, 21, 25, 26, 24, 19, 20, 18, 31, 32, 30, 34, 35, 33,
              28, 29, 27
          ],
          [
              13, 14, 12, 16, 17, 15,
              10, 11, 9, 22, 23, 21, 25, 26, 24, 19, 20, 18, 31, 32, 30, 34,
              35, 33, 28, 29, 27, 4, 5, 3, 7, 8, 6, 1, 2, 0
          ],
          [
              28, 29, 27, 31, 32,
              30, 34, 35, 33, 1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11,
              9, 13, 14, 12, 16, 17, 15, 19, 20, 18, 22, 23, 21, 25, 26, 24
          ],
          [
              1, 2, 0, 4, 5, 3, 7, 8,
              6, 10, 11, 9, 13, 14, 12, 16, 17, 15, 19, 20, 18, 22, 23, 21,
              25, 26, 24, 28, 29, 27,
              31, 32, 30, 34, 35, 33
          ],
          [
              10, 11, 9, 13, 14, 12, 16, 17, 15, 19, 20, 18, 22, 23, 21, 25,
              26, 24, 28, 29, 27, 31,
              32, 30, 34, 35, 33, 1, 2, 0, 4, 5, 3, 7, 8, 6
          ],
          [
              34, 35, 33, 28, 29,
              27, 31, 32, 30, 7, 8, 6, 1, 2, 0, 4, 5, 3, 16, 17, 15, 10, 11,
              9, 13, 14, 12, 25, 26, 24, 19, 20, 18, 22, 23, 21
          ],
          [
              7, 8, 6, 1, 2, 0, 4, 5, 3, 16, 17, 15, 10, 11, 9, 13, 14, 12,
              25, 26, 24, 19, 20, 18, 22, 23, 21, 34, 35, 33, 28, 29, 27,
              31, 32, 30
          ],
          [
              16, 17, 15, 10, 11, 9, 13, 14, 12, 25, 26, 24, 19, 20, 18, 22,
              23, 21, 34, 35, 33, 28, 29, 27, 31, 32, 30, 7, 8, 6, 1, 2, 0,
              4, 5, 3
          ],
          [
              30, 31, 32, 33, 34, 35, 27, 28, 29, 3, 4, 5, 6, 7, 8, 0, 1, 2,
              12, 13, 14, 15, 16, 17, 9, 10, 11, 21, 22, 23, 24, 25, 26, 18,
              19, 20
          ],
          [
              3, 4, 5, 6, 7, 8, 0, 1, 2, 12, 13, 14, 15, 16, 17, 9, 10, 11,
              21, 22, 23, 24, 25, 26, 18, 19, 20, 30, 31, 32, 33, 34, 35,
              27, 28, 29
          ],
          [
              12, 13, 14, 15, 16, 17, 9, 10, 11, 21, 22, 23, 24, 25, 26, 18,
              19, 20, 30, 31, 32, 33, 34, 35, 27, 28, 29, 3, 4, 5, 6, 7, 8,
              0, 1, 2
          ],
          [
              27, 28, 29, 30, 31, 32, 33, 34, 35, 0, 1, 2, 3, 4, 5, 6, 7, 8,
              9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
              25, 26
          ],
          [
              0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
              18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
              33, 34, 35
          ],
          [
              9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
              25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 0, 1, 2, 3, 4, 5,
              6, 7, 8
          ],
          [
              33, 34, 35, 27, 28, 29, 30, 31, 32, 6, 7, 8, 0, 1, 2, 3, 4, 5,
              15, 16, 17, 9, 10, 11, 12, 13, 14, 24, 25, 26, 18, 19, 20, 21,
              22, 23
          ],
          [
              6, 7, 8, 0, 1, 2, 3, 4, 5, 15, 16, 17, 9, 10, 11, 12, 13, 14,
              24, 25, 26, 18, 19, 20, 21, 22, 23, 33, 34, 35, 27, 28, 29,
              30, 31, 32
          ],
          [
              15, 16, 17, 9, 10, 11, 12, 13, 14, 24, 25, 26, 18, 19, 20, 21,
              22, 23, 33, 34, 35, 27, 28, 29, 30, 31, 32, 6, 7, 8, 0, 1, 2,
              3, 4, 5
          ],
          [
              32, 30, 31, 35, 33, 34, 29, 27, 28, 5, 3, 4, 8, 6, 7, 2, 0, 1,
              14, 12, 13, 17, 15, 16, 11, 9, 10, 23, 21, 22, 26, 24, 25, 20,
              18, 19
          ],
          [
              5, 3, 4, 8, 6, 7, 2, 0, 1, 14, 12, 13, 17, 15, 16, 11, 9, 10,
              23, 21, 22, 26, 24, 25, 20, 18, 19, 32, 30, 31, 35, 33, 34,
              29, 27, 28
          ],
          [
              14, 12, 13, 17, 15, 16, 11, 9, 10, 23, 21, 22, 26, 24, 25, 20,
              18, 19, 32, 30, 31, 35, 33, 34, 29, 27, 28, 5, 3, 4, 8, 6, 7,
              2, 0, 1
          ],
          [
              29, 27, 28, 32, 30, 31, 35, 33, 34, 2, 0, 1, 5, 3, 4, 8, 6, 7,
              11, 9, 10, 14, 12, 13, 17, 15, 16, 20, 18, 19, 23, 21, 22, 26,
              24, 25
          ],
          [
              2, 0, 1, 5, 3, 4, 8, 6, 7, 11, 9, 10, 14, 12, 13, 17, 15, 16,
              20, 18, 19, 23, 21, 22, 26, 24, 25, 29, 27, 28, 32, 30, 31,
              35, 33, 34
          ],
          [
              11, 9, 10, 14, 12, 13, 17, 15, 16, 20, 18, 19, 23, 21, 22, 26,
              24, 25, 29, 27, 28, 32, 30, 31, 35, 33, 34, 2, 0, 1, 5, 3, 4,
              8, 6, 7
          ],
          [
              35, 33, 34, 29, 27, 28, 32, 30, 31, 8, 6, 7, 2, 0, 1, 5, 3, 4,
              17, 15, 16, 11, 9, 10, 14, 12, 13, 26, 24, 25, 20, 18, 19, 23,
              21, 22
          ],
          [
              8, 6, 7, 2, 0, 1, 5, 3, 4, 17, 15, 16, 11, 9, 10, 14, 12, 13,
              26, 24, 25, 20, 18, 19, 23, 21, 22, 35, 33, 34, 29, 27, 28,
              32, 30, 31
          ],
          [
              17, 15, 16, 11, 9, 10, 14, 12, 13, 26, 24, 25, 20, 18, 19, 23,
              21, 22, 35, 33, 34, 29, 27, 28, 32, 30, 31, 8, 6, 7, 2, 0, 1,
              5, 3, 4
          ]])
     cnlist = s1.cell_neighbour_list_3D()
     print(cnlist)
     sorted_referenceCnList = np.sort(reference_CnList, axis=0)
     sorted_outputCnList = np.sort(cnlist[:, :, 0], axis=0)
     npt.assert_equal(sorted_referenceCnList,
                      sorted_outputCnList,
                      'Failed',
                      verbose=True)