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


Python MagOrderingTransformation.apply_transformation方法代码示例

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


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

示例1: test_apply_transformation

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
    def test_apply_transformation(self):
        trans = MagOrderingTransformation({"Fe": 5})
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        s = p.structure
        alls = trans.apply_transformation(s, 10)
        self.assertEqual(len(alls), 3)
        f = SymmetryFinder(alls[0]["structure"], 0.1)
        self.assertEqual(f.get_spacegroup_number(), 31)

        model = IsingModel(5, 5)
        trans = MagOrderingTransformation({"Fe": 5},
                                          energy_model=model)
        alls2 = trans.apply_transformation(s, 10)
        #Ising model with +J penalizes similar neighbor magmom.
        self.assertNotEqual(alls[0]["structure"], alls2[0]["structure"])
        self.assertEqual(alls[0]["structure"], alls2[2]["structure"])

        from pymatgen.io.smartio import read_structure
        s = read_structure(os.path.join(test_dir, 'Li2O.cif'))
        #Li2O doesn't have magnetism of course, but this is to test the
        # enumeration.
        trans = MagOrderingTransformation({"Li+": 1}, max_cell_size=3)
        alls = trans.apply_transformation(s, 100)
        self.assertEqual(len(alls), 10)
开发者ID:artemcpp,项目名称:pymatgen,代码行数:27,代码来源:test_advanced_transformations.py

示例2: test_apply_transformation

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
    def test_apply_transformation(self):
        trans = MagOrderingTransformation({"Fe": 5})
        p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                             check_for_POTCAR=False)
        s = p.structure
        alls = trans.apply_transformation(s, 10)
        self.assertEqual(len(alls), 3)
        f = SpacegroupAnalyzer(alls[0]["structure"], 0.1)
        self.assertEqual(f.get_space_group_number(), 31)

        model = IsingModel(5, 5)
        trans = MagOrderingTransformation({"Fe": 5},
                                          energy_model=model)
        alls2 = trans.apply_transformation(s, 10)
        # Ising model with +J penalizes similar neighbor magmom.
        self.assertNotEqual(alls[0]["structure"], alls2[0]["structure"])
        self.assertEqual(alls[0]["structure"], alls2[2]["structure"])

        s = self.get_structure('Li2O')
        # Li2O doesn't have magnetism of course, but this is to test the
        # enumeration.
        trans = MagOrderingTransformation({"Li+": 1}, max_cell_size=3)
        alls = trans.apply_transformation(s, 100)
        # TODO: check this is correct, unclear what len(alls) should be
        self.assertEqual(len(alls), 12)

        trans = MagOrderingTransformation({"Ni": 5})
        alls = trans.apply_transformation(self.NiO.get_primitive_structure(),
                                          return_ranked_list=10)
        self.assertEqual(self.NiO_AFM_111.lattice, alls[0]["structure"].lattice)
        self.assertEqual(self.NiO_AFM_001.lattice, alls[1]["structure"].lattice)
开发者ID:czhengsci,项目名称:pymatgen,代码行数:33,代码来源:test_advanced_transformations.py

示例3: test_ferrimagnetic

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
 def test_ferrimagnetic(self):
     trans = MagOrderingTransformation({"Fe": 5}, 0.75, max_cell_size=1)
     p = Poscar.from_file(os.path.join(test_dir, 'POSCAR.LiFePO4'),
                          check_for_POTCAR=False)
     s = p.structure
     alls = trans.apply_transformation(s, 10)
     self.assertEqual(len(alls), 2)
开发者ID:artemcpp,项目名称:pymatgen,代码行数:9,代码来源:test_advanced_transformations.py

示例4: test_zero_spin_case

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
 def test_zero_spin_case(self):
     #ensure that zero spin case maintains sites and formula
     s = self.get_structure('Li2O')
     trans = MagOrderingTransformation({"Li+": 0.0}, 0.5)
     alls = trans.apply_transformation(s)
     #Ensure s does not have a spin property
     self.assertFalse('spin' in s.sites[0].specie._properties)
     #ensure sites are assigned a spin property in alls
     self.assertTrue('spin' in alls.sites[0].specie._properties)
开发者ID:montoyjh,项目名称:pymatgen,代码行数:11,代码来源:test_advanced_transformations.py

示例5: test_zero_spin_case

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
 def test_zero_spin_case(self):
     # ensure that zero spin case maintains sites and formula
     s = self.get_structure('Li2O')
     trans = MagOrderingTransformation({"Li+": 0.0}, order_parameter=0.5)
     alls = trans.apply_transformation(s)
     Li_site = alls.indices_from_symbol('Li')[0]
     # Ensure s does not have a spin property
     self.assertFalse('spin' in s.sites[Li_site].specie._properties)
     # ensure sites are assigned a spin property in alls
     self.assertTrue('spin' in alls.sites[Li_site].specie._properties)
     self.assertEqual(alls.sites[Li_site].specie._properties['spin'], 0)
开发者ID:czhengsci,项目名称:pymatgen,代码行数:13,代码来源:test_advanced_transformations.py

示例6: test_zero_spin_case

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
 def test_zero_spin_case(self):
     #ensure that zero spin case maintains sites and formula
     from pymatgen.io.smartio import read_structure
     s = read_structure(os.path.join(test_dir, 'Li2O.cif'))
     trans = MagOrderingTransformation({"Li+": 0.0}, 0.5)
     alls = trans.apply_transformation(s)
     #compositions will not be equal due to spin assignment
     #structure representations will be the same
     self.assertEqual(str(s), str(alls))
     #Ensure s does not have a spin property
     self.assertFalse('spin' in s.sites[0].specie._properties)
     #ensure sites are assigned a spin property in alls
     self.assertTrue('spin' in alls.sites[0].specie._properties)
开发者ID:NadezhdaBzhilyanskaya,项目名称:pymatgen,代码行数:15,代码来源:test_advanced_transformations.py

示例7: test_advanced_usage

# 需要导入模块: from pymatgen.transformations.advanced_transformations import MagOrderingTransformation [as 别名]
# 或者: from pymatgen.transformations.advanced_transformations.MagOrderingTransformation import apply_transformation [as 别名]
    def test_advanced_usage(self):

        # test spin on just one oxidation state
        magtypes = {"Fe2+": 5}
        trans = MagOrderingTransformation(magtypes)
        alls = trans.apply_transformation(self.Fe3O4_oxi)
        self.assertIsInstance(alls, Structure)
        self.assertEqual(str(alls[0].specie), "Fe2+,spin=5")
        self.assertEqual(str(alls[2].specie), "Fe3+")

        # test multiple order parameters
        # this should only order on Fe3+ site, but assign spin to both
        magtypes = {"Fe2+": 5, "Fe3+": 5}
        order_parameters = [
            MagOrderParameterConstraint(1, species_constraints="Fe2+"),
            MagOrderParameterConstraint(0.5, species_constraints="Fe3+")
        ]
        trans = MagOrderingTransformation(magtypes, order_parameter=order_parameters)
        alls = trans.apply_transformation(self.Fe3O4_oxi)
        # using this 'sorted' syntax because exact order of sites in first
        # returned structure varies between machines: we just want to ensure
        # that the order parameter is accurate
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(0,2)]),
                         sorted(["Fe2+,spin=5", "Fe2+,spin=5"]))
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(2, 6)]),
                         sorted(["Fe3+,spin=5", "Fe3+,spin=5",
                                 "Fe3+,spin=-5", "Fe3+,spin=-5"]))
        self.assertEqual(str(alls[0].specie), "Fe2+,spin=5")

        # this should give same results as previously
        # but with opposite sign on Fe2+ site
        magtypes = {"Fe2+": -5, "Fe3+": 5}
        order_parameters = [
            MagOrderParameterConstraint(1, species_constraints="Fe2+"),
            MagOrderParameterConstraint(0.5, species_constraints="Fe3+")
        ]
        trans = MagOrderingTransformation(magtypes, order_parameter=order_parameters)
        alls = trans.apply_transformation(self.Fe3O4_oxi)
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(0,2)]),
                         sorted(["Fe2+,spin=-5", "Fe2+,spin=-5"]))
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(2, 6)]),
                         sorted(["Fe3+,spin=5", "Fe3+,spin=5",
                                 "Fe3+,spin=-5", "Fe3+,spin=-5"]))

        # while this should order on both sites
        magtypes = {"Fe2+": 5, "Fe3+": 5}
        order_parameters = [
            MagOrderParameterConstraint(0.5, species_constraints="Fe2+"),
            MagOrderParameterConstraint(0.25, species_constraints="Fe3+")
        ]
        trans = MagOrderingTransformation(magtypes, order_parameter=order_parameters)
        alls = trans.apply_transformation(self.Fe3O4_oxi)
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(0,2)]),
                         sorted(["Fe2+,spin=5", "Fe2+,spin=-5"]))
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(2, 6)]),
                         sorted(["Fe3+,spin=5", "Fe3+,spin=-5",
                                 "Fe3+,spin=-5", "Fe3+,spin=-5"]))

        # add coordination numbers to our test case
        # don't really care what these are for the test case
        cns = [6, 6, 6, 6, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0]
        self.Fe3O4.add_site_property('cn', cns)

        # this should give FM ordering on cn=4 sites, and AFM ordering on cn=6 sites
        magtypes = {"Fe": 5}
        order_parameters = [
            MagOrderParameterConstraint(0.5, species_constraints="Fe",
                                        site_constraint_name="cn", site_constraints=6),
            MagOrderParameterConstraint(1.0, species_constraints="Fe",
                                        site_constraint_name="cn", site_constraints=4)
        ]
        trans = MagOrderingTransformation(magtypes, order_parameter=order_parameters)
        alls = trans.apply_transformation(self.Fe3O4)
        alls.sort(key=lambda x: x.properties['cn'], reverse=True)
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(0, 4)]),
                         sorted(["Fe,spin=-5", "Fe,spin=-5",
                                 "Fe,spin=5", "Fe,spin=5"]))
        self.assertEqual(sorted([str(alls[idx].specie) for idx in range(4,6)]),
                         sorted(["Fe,spin=5", "Fe,spin=5"]))

        # now ordering on both sites, equivalent to order_parameter = 0.5
        magtypes = {"Fe2+": 5, "Fe3+": 5}
        order_parameters = [
            MagOrderParameterConstraint(0.5, species_constraints="Fe2+"),
            MagOrderParameterConstraint(0.5, species_constraints="Fe3+")
        ]
        trans = MagOrderingTransformation(magtypes, order_parameter=order_parameters)
        alls = trans.apply_transformation(self.Fe3O4_oxi, return_ranked_list=10)
        struct = alls[0]["structure"]
        self.assertEqual(sorted([str(struct[idx].specie) for idx in range(0,2)]),
                         sorted(["Fe2+,spin=5", "Fe2+,spin=-5"]))
        self.assertEqual(sorted([str(struct[idx].specie) for idx in range(2, 6)]),
                         sorted(["Fe3+,spin=5", "Fe3+,spin=-5",
                                 "Fe3+,spin=-5", "Fe3+,spin=5"]))
        self.assertEqual(len(alls), 4)

        # now mixed orderings where neither are equal or 1
        magtypes = {"Fe2+": 5, "Fe3+": 5}
        order_parameters = [
            MagOrderParameterConstraint(0.5, species_constraints="Fe2+"),
#.........这里部分代码省略.........
开发者ID:czhengsci,项目名称:pymatgen,代码行数:103,代码来源:test_advanced_transformations.py


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