Beispiel #1
0
 def test_equal(self):
     s1 = Site((1, 2, 0), 'S')
     s2 = Site((1, 2, 0), Specie('S'))
     s3 = Site((1, 2, 0), 16)
     self.assertEqual(s1, s1)
     self.assertEqual(s1, s2)
     self.assertEqual(s1, s3)
Beispiel #2
0
 def test_append_sites(self):
     l_sites = [Site((0, 0, k), 'S') for k in [0.1, 0.2, 0.3]]
     initstru = self.initstru.copy()
     new_stru = initstru.append_sites(l_sites)
     gcell = new_stru.to_gcell()
     new_pos = np.array([[0, 0, 0], [0, 0, 0.1], [0, 0, 0.2], [0, 0, 0.3]])
     self.assertTrue(np.array_equal(gcell.positions, new_pos))
Beispiel #3
0
 def __init__(self,
              lattice,
              positions=np.array([[0, 0, 0]]),
              numbers=np.array([0])):
     self._lattice = lattice
     lsites = [s for s in zip(positions.tolist(), numbers.tolist())]
     self._sites = [Site(s[0], s[1]) for s in lsites]
Beispiel #4
0
 def test_append_site(self):
     site_s = Site((0, 0, 0.222), 'S')
     initstru = self.initstru.copy()
     new_stru = initstru.append_site(site_s)
     gcell = new_stru.to_gcell()
     new_pos = np.append([[0, 0, 0]], [[0, 0, 0.222]], axis=0)
     self.assertTrue(new_stru is initstru)
     self.assertTrue(np.array_equal(gcell.positions, new_pos))
Beispiel #5
0
 def test_append(self):
     site_s = Site((0, 0, 0.222), 'S')
     zb = self.full_initzb.copy()
     zb.append(site_s)
     gcell = zb.to_gcell()
     new_pos = np.insert(self.pos, 1, [[0, 0, 0.222]], axis=0)
     new_numbers = np.insert(self.numbers, 1, 16)
     self.assertTrue(np.array_equal(gcell.positions, new_pos))
     self.assertTrue(np.array_equal(gcell.numbers, new_numbers))
Beispiel #6
0
    def test_get_points_in_sphere(self):
        latt = np.array([[4.898979, 0.000000, 0.000000],
                         [2.449490, 4.242641, 0.000000],
                         [1.632993, -0.000000, 4.618802]])
        pos = np.array([[0.208333, 0.333333, 0.375000],
                        [0.375000, 0.000000, 0.875000],
                        [0.541667, 0.666667, 0.375000],
                        [0.708333, 0.333333, 0.875000],
                        [0.875000, 0.000000, 0.375000],
                        [0.000000, 0.000000, 0.000000],
                        [0.166667, 0.666667, 0.500000],
                        [0.333333, 0.333333, 0.000000],
                        [0.500000, 0.000000, 0.500000],
                        [0.666667, 0.666667, 0.000000],
                        [0.833333, 0.333333, 0.500000],
                        [0.041667, 0.666667, 0.875000]])
        numbers = np.array([16, 16, 16, 16, 16, 30, 30, 30, 30, 30, 30, 55])
        modcell = ModifiedCell(latt, pos, numbers)
        dict_sites = modcell.get_points_incell_insphere(
            np.array([0.041667, 0.666667, 0.875000]), 2)

        sites = [
            Site(pos[5], 'Zn'),
            Site(pos[9], 'Zn'),
            Site(pos[7], 'Zn'),
            Site(pos[6], 'Zn'),
            Site(pos[11], 'Cs')
        ]
        self.assertEqual(len(dict_sites), 5)
        for s in dict_sites.values():
            self.assertTrue(s in sites)

        #  Test for find giving element
        modcell = ModifiedCell(latt, pos, numbers)
        dict_sites = modcell.get_points_incell_insphere(
            np.array([0.041667, 0.666667, 0.875000]), 2, Specie('Zn'))

        sites = [
            Site(pos[5], 'Zn'),
            Site(pos[9], 'Zn'),
            Site(pos[7], 'Zn'),
            Site(pos[6], 'Zn')
        ]
        self.assertEqual(len(dict_sites), 4)
        for s in dict_sites.values():
            self.assertTrue(s in sites)
Beispiel #7
0
 def test_init(self):
     s = Site((1, 2, 0), 'S')
     s = Site((1, 2, 0), Specie('S'))
     s = Site((1, 2, 0), 16)