Esempio n. 1
0
def surfscreen(structure, MI_lib, r=5):
    MI_List = []
    for site in structure:
        nearbysites = structure.get_neighbors(site, r)
        perm = combinations(nearbysites, 2)

        for two_sites in perm:
            three_coords = [site.coords]
            for X in two_sites:
                three_coords.append(X[0].coords)

            MI = miller_index_from_sites(structure.lattice.matrix,
                                         three_coords)
            if any(np.abs(MI) > 4):
                continue
            if np.isnan(MI).any():
                continue
            MI_rounded = np.round(MI)
            if npl.norm(MI_rounded - MI) > 0.01:
                continue
            MI_List.append(MI_rounded)

    PlotDict = {}
    for index in MI_List:
        for key in MI_lib.keys():
            if any((index == x).all() for x in MI_lib[key]):
                if key not in PlotDict.keys():
                    PlotDict[key] = 0
                PlotDict[key] += 1
                print(index, MI_lib[key])

    import matplotlib.pyplot as plt

    plt.bar(PlotDict.keys(), PlotDict.values(), color='g')
    plt.show()
Esempio n. 2
0
    def test_miller_index_from_sites(self):
        """Test surface miller index convenience function"""

        # test on a cubic system
        m = Lattice.cubic(1)
        s1 = np.array([0.5, -1.5, 3])
        s2 = np.array([0.5, 3.0, -1.5])
        s3 = np.array([2.5, 1.5, -4.0])
        self.assertEqual(miller_index_from_sites(m, [s1, s2, s3]), (2, 1, 1))

        # test casting from matrix to Lattice
        m = [[2.319, -4.01662582, 0.0], [2.319, 4.01662582, 0.0], [0.0, 0.0, 7.252]]

        s1 = np.array([2.319, 1.33887527, 6.3455])
        s2 = np.array([1.1595, 0.66943764, 4.5325])
        s3 = np.array([1.1595, 0.66943764, 0.9065])
        hkl = miller_index_from_sites(m, [s1, s2, s3])
        self.assertEqual(hkl, (2, -1, 0))
Esempio n. 3
0
    def test_miller_index_from_sites(self):
        """Test surface miller index convenience function"""

        # test on a cubic system
        m = Lattice.cubic(1)
        s1 = np.array([0.5, -1.5, 3])
        s2 = np.array([0.5, 3., -1.5])
        s3 = np.array([2.5, 1.5, -4.])
        self.assertEqual(miller_index_from_sites(m, [s1, s2, s3]),
                         (2, 1, 1))

        # test casting from matrix to Lattice
        m = [[2.319, -4.01662582, 0.], [2.319, 4.01662582, 0.], [0., 0., 7.252]]

        s1 = np.array([2.319, 1.33887527, 6.3455])
        s2 = np.array([1.1595, 0.66943764, 4.5325])
        s3 = np.array([1.1595, 0.66943764, 0.9065])
        hkl = miller_index_from_sites(m, [s1, s2, s3])
        self.assertEqual(hkl, (2, -1, 0))
Esempio n. 4
0
    def test_miller_index_from_sites(self):
        # test on a cubic system
        m = Lattice.cubic(1).matrix
        s1 = np.array([0.5, -1.5, 3])
        s2 = np.array([0.5, 3.,-1.5])
        s3 = np.array([2.5, 1.5,-4.])
        self.assertEqual(tuple(miller_index_from_sites(m, [s1, s2, s3])),
                         (-2,-1,-1))

        # test on a hexagonal system
        m = np.array([[2.319, -4.01662582, 0.],
                      [2.319, 4.01662582, 0.],
                      [0., 0., 7.252]])

        s1 = np.array([2.319, 1.33887527, 6.3455])
        s2 = np.array([1.1595, 0.66943764, 4.5325])
        s3 = np.array([1.1595, 0.66943764, 0.9065])
        hkl = [np.round(i, 6) for i in miller_index_from_sites(m, [s1, s2, s3])]
        self.assertEqual(tuple(hkl), (2, -1, 0))
Esempio n. 5
0
    def test_miller_index_from_sites(self):
        # test on a cubic system
        m = Lattice.cubic(1).matrix
        s1 = np.array([0.5, -1.5, 3])
        s2 = np.array([0.5, 3.,-1.5])
        s3 = np.array([2.5, 1.5,-4.])
        self.assertEqual(tuple(miller_index_from_sites(m, [s1, s2, s3])),
                         (-2,-1,-1))

        # test on a hexagonal system
        m = np.array([[2.319, -4.01662582, 0.],
                      [2.319, 4.01662582, 0.],
                      [0., 0., 7.252]])

        s1 = np.array([2.319, 1.33887527, 6.3455])
        s2 = np.array([1.1595, 0.66943764, 4.5325])
        s3 = np.array([1.1595, 0.66943764, 0.9065])
        hkl = [np.round(i, 6) for i in miller_index_from_sites(m, [s1, s2, s3])]
        self.assertEqual(tuple(hkl), (2, -1, 0))