当前位置: 首页>>代码示例>>Python>>正文


Python Structure.make_supercell方法代码示例

本文整理汇总了Python中pymatgen.core.Structure.make_supercell方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.make_supercell方法的具体用法?Python Structure.make_supercell怎么用?Python Structure.make_supercell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymatgen.core.Structure的用法示例。


在下文中一共展示了Structure.make_supercell方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_supercell_matrix

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_get_supercell_matrix(self):
        sm = StructureMatcher(ltol=0.1, stol=0.3, angle_tol=2,
                              primitive_cell=False, scale=True,
                              attempt_supercell=True)

        l = Lattice.orthorhombic(1, 2, 3)

        s1 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0,0.1],[0,0,0.2],[.7,.4,.5]])
        s1.make_supercell([2,1,1])
        s2 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0.1,0],[0,0.1,-0.95],[-.7,.5,.375]])
        result = sm.get_supercell_matrix(s1, s2)
        self.assertTrue((result == [[-2,0,0],[0,1,0],[0,0,1]]).all())

        s1 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0,0.1],[0,0,0.2],[.7,.4,.5]])
        s1.make_supercell([[1, -1, 0],[0, 0, -1],[0, 1, 0]])

        s2 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0.1,0],[0,0.1,-0.95],[-.7,.5,.375]])
        result = sm.get_supercell_matrix(s1, s2)
        self.assertTrue((result == [[-1,-1,0],[0,0,-1],[0,1,0]]).all())

        #test when the supercell is a subset
        sm = StructureMatcher(ltol=0.1, stol=0.3, angle_tol=2,
                              primitive_cell=False, scale=True,
                              attempt_supercell=True, allow_subset=True)
        del s1[0]
        result = sm.get_supercell_matrix(s1, s2)
        self.assertTrue((result == [[-1,-1,0],[0,0,-1],[0,1,0]]).all())
开发者ID:eantono,项目名称:pymatgen,代码行数:33,代码来源:test_structure_matcher.py

示例2: test_disordered_primitive_to_ordered_supercell

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_disordered_primitive_to_ordered_supercell(self):
        sm_atoms = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                                    primitive_cell=False, scale=True,
                                    attempt_supercell=True,
                                    allow_subset=True,
                                    supercell_size = 'num_atoms',
                                    comparator=OrderDisorderElementComparator())
        sm_sites = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                                    primitive_cell=False, scale=True,
                                    attempt_supercell=True,
                                    allow_subset=True,
                                    supercell_size = 'num_sites',
                                    comparator=OrderDisorderElementComparator())
        lp = Lattice.orthorhombic(10, 20, 30)
        pcoords = [[0,   0,   0],
                   [0.5, 0.5, 0.5]]
        ls = Lattice.orthorhombic(20,20,30)
        scoords = [[0,    0,   0],
                   [0.75, 0.5, 0.5]]
        prim = Structure(lp, [{'Na':0.5}, {'Cl':0.5}], pcoords)
        supercell = Structure(ls, ['Na', 'Cl'], scoords)
        supercell.make_supercell([[-1,1,0],[0,1,1],[1,0,0]])

        self.assertFalse(sm_sites.fit(prim, supercell))
        self.assertTrue(sm_atoms.fit(prim, supercell))

        self.assertRaises(ValueError, sm_atoms.get_s2_like_s1, prim, supercell)
        self.assertEqual(len(sm_atoms.get_s2_like_s1(supercell, prim)), 4)
开发者ID:eantono,项目名称:pymatgen,代码行数:30,代码来源:test_structure_matcher.py

示例3: test_get_mapping

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_get_mapping(self):
        sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                              primitive_cell=False, scale=True,
                              attempt_supercell=False,
                              allow_subset = True)
        l = Lattice.orthorhombic(1, 2, 3)
        s1 = Structure(l, ['Ag', 'Si', 'Si'],
                       [[.7,.4,.5],[0,0,0.1],[0,0,0.2]])
        s1.make_supercell([2,1,1])
        s2 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0.1,-0.95],[0,0.1,0],[-.7,.5,.375]])

        shuffle = [2,0,1,3,5,4]
        s1 = Structure.from_sites([s1[i] for i in shuffle])
        #test the mapping
        s2.make_supercell([2,1,1])
        #equal sizes
        for i, x in enumerate(sm.get_mapping(s1, s2)):
            self.assertEqual(s1[x].species_and_occu,
                             s2[i].species_and_occu)

        del s1[0]
        #s1 is subset of s2
        for i, x in enumerate(sm.get_mapping(s2, s1)):
            self.assertEqual(s1[i].species_and_occu,
                             s2[x].species_and_occu)
        #s2 is smaller than s1
        del s2[0]
        del s2[1]
        self.assertRaises(ValueError, sm.get_mapping, s2, s1)
开发者ID:eantono,项目名称:pymatgen,代码行数:32,代码来源:test_structure_matcher.py

示例4: test_find_match2

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_find_match2(self):
        sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False)
        l = Lattice.orthorhombic(1, 2, 3)
        s1 = Structure(l, ["Si", "Si"], [[0, 0, 0.1], [0, 0, 0.2]])
        s2 = Structure(l, ["Si", "Si"], [[0, 0.1, 0], [0, 0.1, -0.95]])

        s1, s2, fu, s1_supercell = sm._preprocess(s1, s2, False)

        match = sm._strict_match(s1, s2, fu, s1_supercell=False, use_rms=True, break_on_match=False)
        scale_matrix = match[2]
        s2.make_supercell(scale_matrix)
        s2.translate_sites(range(len(s2)), match[3])

        self.assertAlmostEqual(np.sum(s2.frac_coords), 0.3)
        self.assertAlmostEqual(np.sum(s2.frac_coords[:, :2]), 0)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:17,代码来源:test_structure_matcher.py

示例5: test_find_match1

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_find_match1(self):
        sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, primitive_cell=True, scale=True, attempt_supercell=False)
        l = Lattice.orthorhombic(1, 2, 3)
        s1 = Structure(l, ["Si", "Si", "Ag"], [[0, 0, 0.1], [0, 0, 0.2], [0.7, 0.4, 0.5]])
        s2 = Structure(l, ["Si", "Si", "Ag"], [[0, 0.1, 0], [0, 0.1, -0.95], [0.7, 0.5, 0.375]])

        s1, s2, fu, s1_supercell = sm._preprocess(s1, s2, False)
        match = sm._strict_match(s1, s2, fu, s1_supercell=True, use_rms=True, break_on_match=False)
        scale_matrix = match[2]
        s2.make_supercell(scale_matrix)
        fc = s2.frac_coords + match[3]
        fc -= np.round(fc)
        self.assertAlmostEqual(np.sum(fc), 0.9)
        self.assertAlmostEqual(np.sum(fc[:, :2]), 0.1)
        cart_dist = np.sum(match[1] * (l.volume / 3) ** (1 / 3))
        self.assertAlmostEqual(cart_dist, 0.15)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:18,代码来源:test_structure_matcher.py

示例6: test_find_match2

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
 def test_find_match2(self):
     sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, 
                           primitive_cell=True, scale=True, 
                           attempt_supercell=False)
     l = Lattice.orthorhombic(1, 2, 3)
     s1 = Structure(l, ['Si', 'Si'], [[0,0,0.1],[0,0,0.2]])
     s2 = Structure(l, ['Si', 'Si'], [[0,0.1,0],[0,0.1,-0.95]])
     match = sm._find_match(s1, s2, break_on_match = False, 
                            use_rms = True, niggli = False)
     scale_matrix = np.round(np.dot(match[2].matrix, 
                                    s2.lattice.inv_matrix)).astype('int')
     s2.make_supercell(scale_matrix)
     fc = s2.frac_coords + match[3]
     fc -= np.round(fc)
     
     self.assertAlmostEqual(np.sum(fc), 0.3)
     self.assertAlmostEqual(np.sum(fc[:,:2]), 0)
开发者ID:leicheng,项目名称:pymatgen,代码行数:19,代码来源:test_structure_matcher.py

示例7: test_get_s2_like_s1

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
 def test_get_s2_like_s1(self):
     sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5, 
                           primitive_cell=False, scale=True, 
                           attempt_supercell=True)
     l = Lattice.orthorhombic(1, 2, 3)
     s1 = Structure(l, ['Si', 'Si', 'Ag'], 
                    [[0,0,0.1],[0,0,0.2],[.7,.4,.5]])
     s1.make_supercell([2,1,1])
     s2 = Structure(l, ['Si', 'Si', 'Ag'], 
                    [[0,0.1,0],[0,0.1,-0.95],[-.7,.5,.375]])
     result = sm.get_s2_like_s1(s1, s2)
     
     self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, 
                                                 [0.35,0.4,0.5])), 1)
     self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, 
                                                 [0,0,0.125])), 1)
     self.assertEqual(len(find_in_coord_list_pbc(result.frac_coords, 
                                                 [0,0,0.175])), 1)
开发者ID:leicheng,项目名称:pymatgen,代码行数:20,代码来源:test_structure_matcher.py

示例8: test_get_s2_large_s2

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_get_s2_large_s2(self):
        sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                              primitive_cell=False, scale=False,
                              attempt_supercell=True, allow_subset=False,
                              supercell_size='volume')

        l = Lattice.orthorhombic(1, 2, 3)
        s1 = Structure(l, ['Ag', 'Si', 'Si'],
                       [[.7,.4,.5],[0,0,0.1],[0,0,0.2]])

        l2 = Lattice.orthorhombic(1.01, 2.01, 3.01)
        s2 = Structure(l2, ['Si', 'Si', 'Ag'],
                       [[0,0.1,-0.95],[0,0.1,0],[-.7,.5,.375]])
        s2.make_supercell([[0,-1,0],[1,0,0],[0,0,1]])

        result = sm.get_s2_like_s1(s1, s2)

        for x,y in zip(s1, result):
            self.assertLess(x.distance(y), 0.08)
开发者ID:eantono,项目名称:pymatgen,代码行数:21,代码来源:test_structure_matcher.py

示例9: test_supercell_subsets

# 需要导入模块: from pymatgen.core import Structure [as 别名]
# 或者: from pymatgen.core.Structure import make_supercell [as 别名]
    def test_supercell_subsets(self):
        sm = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                              primitive_cell=False, scale=True,
                              attempt_supercell=True, allow_subset=True,
                              supercell_size='volume')
        sm_no_s = StructureMatcher(ltol=0.2, stol=0.3, angle_tol=5,
                              primitive_cell=False, scale=True,
                              attempt_supercell=True, allow_subset=False,
                              supercell_size='volume')
        l = Lattice.orthorhombic(1, 2, 3)
        s1 = Structure(l, ['Ag', 'Si', 'Si'],
                       [[.7,.4,.5],[0,0,0.1],[0,0,0.2]])
        s1.make_supercell([2,1,1])
        s2 = Structure(l, ['Si', 'Si', 'Ag'],
                       [[0,0.1,-0.95],[0,0.1,0],[-.7,.5,.375]])

        shuffle = [0,2,1,3,4,5]
        s1 = Structure.from_sites([s1[i] for i in shuffle])

        #test when s1 is exact supercell of s2
        result = sm.get_s2_like_s1(s1, s2)
        for a, b in zip(s1, result):
            self.assertTrue(a.distance(b) < 0.08)
            self.assertEqual(a.species_and_occu, b.species_and_occu)

        self.assertTrue(sm.fit(s1, s2))
        self.assertTrue(sm.fit(s2, s1))
        self.assertTrue(sm_no_s.fit(s1, s2))
        self.assertTrue(sm_no_s.fit(s2, s1))

        rms = (0.048604032430991401, 0.059527539448807391)
        self.assertTrue(np.allclose(sm.get_rms_dist(s1, s2), rms))
        self.assertTrue(np.allclose(sm.get_rms_dist(s2, s1), rms))

        #test when the supercell is a subset of s2
        subset_supercell = s1.copy()
        del subset_supercell[0]
        result = sm.get_s2_like_s1(subset_supercell, s2)
        self.assertEqual(len(result), 6)
        for a, b in zip(subset_supercell, result):
            self.assertTrue(a.distance(b) < 0.08)
            self.assertEqual(a.species_and_occu, b.species_and_occu)

        self.assertTrue(sm.fit(subset_supercell, s2))
        self.assertTrue(sm.fit(s2, subset_supercell))
        self.assertFalse(sm_no_s.fit(subset_supercell, s2))
        self.assertFalse(sm_no_s.fit(s2, subset_supercell))

        rms = (0.053243049896333279, 0.059527539448807336)
        self.assertTrue(np.allclose(sm.get_rms_dist(subset_supercell, s2), rms))
        self.assertTrue(np.allclose(sm.get_rms_dist(s2, subset_supercell), rms))

        #test when s2 (once made a supercell) is a subset of s1
        s2_missing_site = s2.copy()
        del s2_missing_site[1]
        result = sm.get_s2_like_s1(s1, s2_missing_site)
        for a, b in zip((s1[i] for i in (0, 2, 4, 5)), result):
            self.assertTrue(a.distance(b) < 0.08)
            self.assertEqual(a.species_and_occu, b.species_and_occu)

        self.assertTrue(sm.fit(s1, s2_missing_site))
        self.assertTrue(sm.fit(s2_missing_site, s1))
        self.assertFalse(sm_no_s.fit(s1, s2_missing_site))
        self.assertFalse(sm_no_s.fit(s2_missing_site, s1))

        rms = (0.029763769724403633, 0.029763769724403987)
        self.assertTrue(np.allclose(sm.get_rms_dist(s1, s2_missing_site), rms))
        self.assertTrue(np.allclose(sm.get_rms_dist(s2_missing_site, s1), rms))
开发者ID:eantono,项目名称:pymatgen,代码行数:70,代码来源:test_structure_matcher.py


注:本文中的pymatgen.core.Structure.make_supercell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。