當前位置: 首頁>>代碼示例>>Python>>正文


Python advanced_transformations.EnumerateStructureTransformation類代碼示例

本文整理匯總了Python中pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation的典型用法代碼示例。如果您正苦於以下問題:Python EnumerateStructureTransformation類的具體用法?Python EnumerateStructureTransformation怎麽用?Python EnumerateStructureTransformation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EnumerateStructureTransformation類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_apply_transformation

    def test_apply_transformation(self):
        enum_trans = EnumerateStructureTransformation(refine_structure=True)
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        struct = p.structure
        expected_ans = [1, 3, 1]
        for i, frac in enumerate([0.25, 0.5, 0.75]):
            trans = SubstitutionTransformation({'Fe': {'Fe': frac}})
            s = trans.apply_transformation(struct)
            oxitrans = OxidationStateDecorationTransformation({'Li': 1,
                                                               'Fe': 2,
                                                               'P': 5,
                                                               'O': -2})
            s = oxitrans.apply_transformation(s)
            alls = enum_trans.apply_transformation(s, 100)
            self.assertEquals(len(alls), expected_ans[i])
            self.assertIsInstance(trans.apply_transformation(s), Structure)
            for s in alls:
                self.assertIn("energy", s)

        #make sure it works for non-oxidation state decorated structure
        trans = SubstitutionTransformation({'Fe': {'Fe': 0.5}})
        s = trans.apply_transformation(struct)
        alls = enum_trans.apply_transformation(s, 100)
        self.assertEquals(len(alls), 3)
        self.assertIsInstance(trans.apply_transformation(s), Structure)
        for s in alls:
            self.assertNotIn("energy", s)
開發者ID:artemcpp,項目名稱:pymatgen,代碼行數:28,代碼來源:test_advanced_transformations.py

示例2: test_max_disordered_sites

 def test_max_disordered_sites(self):
     l = Lattice.cubic(4)
     s_orig = Structure(l, [{"Li": 0.2, "Na": 0.2, "K": 0.6}, {"O": 1}],
                   [[0, 0, 0], [0.5, 0.5, 0.5]])
     est = EnumerateStructureTransformation(max_cell_size=None,
                                            max_disordered_sites=5)
     s = est.apply_transformation(s_orig)
     self.assertEqual(len(s), 8)
開發者ID:czhengsci,項目名稱:pymatgen,代碼行數:8,代碼來源:test_advanced_transformations.py

示例3: test_max_disordered_sites

 def test_max_disordered_sites(self):
     l = Lattice.cubic(4)
     s_orig = Structure(l, [{"Li": 0.2, "Na": 0.2, "K": 0.6}, {"O": 1}],
                        [[0, 0, 0], [0.5, 0.5, 0.5]])
     est = EnumerateStructureTransformation(max_cell_size=None,
                                            max_disordered_sites=5)
     dd = est.apply_transformation(s_orig, return_ranked_list=100)
     self.assertEqual(len(dd), 9)
     for d in dd:
         self.assertEqual(len(d["structure"]), 10)
開發者ID:ExpHP,項目名稱:pymatgen,代碼行數:10,代碼來源:test_advanced_transformations.py

示例4: enumerate_ordering

    def enumerate_ordering(self, structure):
        # Generate the disordered structure first.
        s = Structure.from_sites(structure.sites)
        for indices, fraction in zip(self._indices, self._fractions):
            for ind in indices:
                new_sp = {sp: occu * fraction for sp, occu in structure[ind].species_and_occu.items()}
                s[ind] = new_sp
        # Perform enumeration
        from pymatgen.transformations.advanced_transformations import EnumerateStructureTransformation

        trans = EnumerateStructureTransformation()
        return trans.apply_transformation(s, 10000)
開發者ID:dcossey014,項目名稱:pymatgen,代碼行數:12,代碼來源:site_transformations.py

示例5: enumerate_ordering

 def enumerate_ordering(self, structure):
     # Generate the disordered structure first.
     editor = StructureEditor(structure)
     for indices, fraction in zip(self._indices, self._fractions):
         for ind in indices:
             new_sp = {sp: occu * fraction
                       for sp, occu
                       in structure[ind].species_and_occu.items()}
             editor.replace_site(ind, new_sp)
     mod_s = editor.modified_structure
     # Perform enumeration
     from pymatgen.transformations.advanced_transformations import \
         EnumerateStructureTransformation
     trans = EnumerateStructureTransformation()
     return trans.apply_transformation(mod_s, 10000)
開發者ID:materialsgenome,項目名稱:pymatgen,代碼行數:15,代碼來源:site_transformations.py

示例6: test_to_from_dict

 def test_to_from_dict(self):
     if not enumlib_present:
         raise SkipTest("enumlib not present. Skipping "
                        "EnumerateStructureTransformationTest...")
     trans = EnumerateStructureTransformation()
     d = trans.to_dict
     trans = EnumerateStructureTransformation.from_dict(d)
     self.assertEqual(trans.symm_prec, 0.1)
開發者ID:jesuansito,項目名稱:pymatgen,代碼行數:8,代碼來源:test_advanced_transformations.py

示例7: test_to_from_dict

 def test_to_from_dict(self):
     trans = EnumerateStructureTransformation()
     d = trans.to_dict
     trans = EnumerateStructureTransformation.from_dict(d)
     self.assertEqual(trans.symm_prec, 0.1)
開發者ID:artemcpp,項目名稱:pymatgen,代碼行數:5,代碼來源:test_advanced_transformations.py


注:本文中的pymatgen.transformations.advanced_transformations.EnumerateStructureTransformation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。