• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python groups.SpaceGroup类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pymatgen.symmetry.groups.SpaceGroup的典型用法代码示例。如果您正苦于以下问题:Python SpaceGroup类的具体用法?Python SpaceGroup怎么用?Python SpaceGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test_get_settings

 def test_get_settings(self):
     self.assertEqual({'Fm-3m(a-1/4,b-1/4,c-1/4)', 'Fm-3m'},
                      SpaceGroup.get_settings("Fm-3m"))
     self.assertEqual({'Pmmn', 'Pmnm:1', 'Pnmm:2', 'Pmnm:2', 'Pnmm',
                       'Pnmm:1', 'Pmmn:1', 'Pmnm', 'Pmmn:2'},
                      SpaceGroup.get_settings("Pmmn"))
     self.assertEqual({'Pnmb', 'Pman', 'Pncm', 'Pmna', 'Pcnm', 'Pbmn'},
                      SpaceGroup.get_settings("Pmna"))
开发者ID:albalu,项目名称:pymatgen,代码行数:8,代码来源:test_groups.py


示例2: test_get_slab

    def test_get_slab(self):
        s = self.get_structure("LiFePO4")
        gen = SlabGenerator(s, [0, 0, 1], 10, 10)
        s = gen.get_slab(0.25)
        self.assertAlmostEqual(s.lattice.abc[2], 20.820740000000001)

        fcc = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3), ["Fe"],
                                        [[0, 0, 0]])
        gen = SlabGenerator(fcc, [1, 1, 1], 10, 10)
        slab = gen.get_slab()
        gen = SlabGenerator(fcc, [1, 1, 1], 10, 10, primitive=False)
        slab_non_prim = gen.get_slab()
        self.assertEqual(len(slab), 6)
        self.assertEqual(len(slab_non_prim), len(slab) * 4)

        #Some randomized testing of cell vectors
        for i in range(1, 231):
            i = random.randint(1, 230)
            sg = SpaceGroup.from_int_number(i)
            if sg.crystal_system == "hexagonal" or (sg.crystal_system == \
                    "trigonal" and sg.symbol.endswith("H")):
                latt = Lattice.hexagonal(5, 10)
            else:
                #Cubic lattice is compatible with all other space groups.
                latt = Lattice.cubic(5)
            s = Structure.from_spacegroup(i, latt, ["H"], [[0, 0, 0]])
            miller = (0, 0, 0)
            while miller == (0, 0, 0):
                miller = (random.randint(0, 6), random.randint(0, 6),
                          random.randint(0, 6))
            gen = SlabGenerator(s, miller, 10, 10)
            a, b, c = gen.oriented_unit_cell.lattice.matrix
            self.assertAlmostEqual(np.dot(a, gen._normal), 0)
            self.assertAlmostEqual(np.dot(b, gen._normal), 0)
开发者ID:tallakahath,项目名称:pymatgen,代码行数:34,代码来源:test_surface.py


示例3: test_equivalence_to_spacegroup

    def test_equivalence_to_spacegroup(self):

        # first 230 magnetic space groups have same symmetry operations
        # as normal space groups, so should give same orbits

        labels = ["Fm-3m", "Pnma", "P2/c", "P-1"]

        points = [[0, 0, 0],
                  [0.5, 0, 0],
                  [0.11, 0.22, 0.33]]

        for label in labels:
            sg = SpaceGroup(label)
            msg = MagneticSpaceGroup(label)
            self.assertEqual(sg.crystal_system, msg.crystal_system)
            for p in points:
                pp_sg = np.array(sg.get_orbit(p))
                pp_msg = np.array(msg.get_orbit(p, 0)[0])  # discarding magnetic moment information
                pp_sg = pp_sg[np.lexsort(np.transpose(pp_sg)[::-1])]  # sorting arrays so we can compare them
                pp_msg = pp_msg[np.lexsort(np.transpose(pp_msg)[::-1])]
                self.assertTrue(np.allclose(pp_sg, pp_msg))
开发者ID:ExpHP,项目名称:pymatgen,代码行数:21,代码来源:test_maggroups.py


示例4: get_symops

    def get_symops(self, data):
        """
        In order to generate symmetry equivalent positions, the symmetry
        operations are parsed. If the symops are not present, the space
        group symbol is parsed, and symops are generated.
        """
        symops = []
        for symmetry_label in ["_symmetry_equiv_pos_as_xyz",
                               "_symmetry_equiv_pos_as_xyz_",
                               "_space_group_symop_operation_xyz",
                               "_space_group_symop_operation_xyz_"]:
            if data.data.get(symmetry_label):
                try:
                    symops = [SymmOp.from_xyz_string(s)
                              for s in data.data.get(symmetry_label)]
                    break
                except ValueError:
                    continue
        if not symops:
            # Try to parse symbol
            for symmetry_label in ["_symmetry_space_group_name_H-M",
                                   "_symmetry_space_group_name_H_M",
                                   "_symmetry_space_group_name_H-M_",
                                   "_symmetry_space_group_name_H_M_",
                                   "_space_group_name_Hall",
                                   "_space_group_name_Hall_",
                                   "_space_group_name_H-M_alt",
                                   "_space_group_name_H-M_alt_",
                                   "_symmetry_space_group_name_hall",
                                   "_symmetry_space_group_name_hall_",
                                   "_symmetry_space_group_name_h-m",
                                   "_symmetry_space_group_name_h-m_"]:

                if data.data.get(symmetry_label):
                    try:
                        spg = space_groups.get(sub_spgrp(
                                        data.data.get(symmetry_label)))
                        if spg:
                            symops = SpaceGroup(spg).symmetry_ops
                            break
                    except ValueError:
                        continue
        if not symops:
            # Try to parse International number
            for symmetry_label in ["_space_group_IT_number",
                                   "_space_group_IT_number_",
                                   "_symmetry_Int_Tables_number",
                                   "_symmetry_Int_Tables_number_"]:
                if data.data.get(symmetry_label):
                    try:
                        i = int(str2float(data.data.get(symmetry_label)))
                        symops = SpaceGroup.from_int_number(i).symmetry_ops
                        break
                    except ValueError:
                        continue

        if not symops:
            warnings.warn("No _symmetry_equiv_pos_as_xyz type key found. "
                          "Defaulting to P1.")
            symops = [SymmOp.from_xyz_string(s) for s in ['x', 'y', 'z']]

        return symops
开发者ID:shyamd,项目名称:pymatgen,代码行数:62,代码来源:cif.py


示例5: test_is_compatible

    def test_is_compatible(self):
        cubic = Lattice.cubic(1)
        hexagonal = Lattice.hexagonal(1, 2)
        rhom = Lattice.rhombohedral(3, 80)
        tet = Lattice.tetragonal(1, 2)
        ortho = Lattice.orthorhombic(1, 2, 3)
        sg = SpaceGroup("Fm-3m")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertFalse(sg.is_compatible(hexagonal))
        sg = SpaceGroup("R-3m:H")
        self.assertFalse(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(hexagonal))
        sg = SpaceGroup("R-3m:R")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(rhom))
        self.assertFalse(sg.is_compatible(hexagonal))
        sg = SpaceGroup("Pnma")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(tet))
        self.assertTrue(sg.is_compatible(ortho))
        self.assertFalse(sg.is_compatible(rhom))
        self.assertFalse(sg.is_compatible(hexagonal))
        sg = SpaceGroup("P12/c1")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(tet))
        self.assertTrue(sg.is_compatible(ortho))
        self.assertFalse(sg.is_compatible(rhom))
        self.assertFalse(sg.is_compatible(hexagonal))
        sg = SpaceGroup("P-1")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(tet))
        self.assertTrue(sg.is_compatible(ortho))
        self.assertTrue(sg.is_compatible(rhom))
        self.assertTrue(sg.is_compatible(hexagonal))
        sg = SpaceGroup("Pmmn:2")
        self.assertTrue(sg.is_compatible(cubic))
        self.assertTrue(sg.is_compatible(tet))
        self.assertTrue(sg.is_compatible(ortho))
        self.assertFalse(sg.is_compatible(rhom))
        self.assertFalse(sg.is_compatible(hexagonal))

        sg = SpaceGroup.from_int_number(165)
        self.assertFalse(sg.is_compatible(cubic))
        self.assertFalse(sg.is_compatible(tet))
        self.assertFalse(sg.is_compatible(ortho))
        self.assertFalse(sg.is_compatible(rhom))
        self.assertTrue(sg.is_compatible(hexagonal))
开发者ID:albalu,项目名称:pymatgen,代码行数:47,代码来源:test_groups.py


示例6: test_get_orbit

 def test_get_orbit(self):
     sg = SpaceGroup("Fm-3m")
     p = np.random.randint(0, 100 + 1, size=(3,)) / 100
     self.assertLessEqual(len(sg.get_orbit(p)), sg.order)
开发者ID:albalu,项目名称:pymatgen,代码行数:4,代码来源:test_groups.py


示例7: test_subgroup_supergroup

 def test_subgroup_supergroup(self):
     with warnings.catch_warnings() as w:
         warnings.simplefilter("ignore")
         self.assertTrue(SpaceGroup('Pma2').is_subgroup(SpaceGroup('Pccm')))
         self.assertFalse(SpaceGroup.from_int_number(229).is_subgroup(
             SpaceGroup.from_int_number(230)))
开发者ID:albalu,项目名称:pymatgen,代码行数:6,代码来源:test_groups.py


示例8: get_symops

    def get_symops(self, data):
        """
        In order to generate symmetry equivalent positions, the symmetry
        operations are parsed. If the symops are not present, the space
        group symbol is parsed, and symops are generated.
        """
        symops = []
        for symmetry_label in ["_symmetry_equiv_pos_as_xyz",
                               "_symmetry_equiv_pos_as_xyz_",
                               "_space_group_symop_operation_xyz",
                               "_space_group_symop_operation_xyz_"]:
            if data.data.get(symmetry_label):
                xyz = data.data.get(symmetry_label)
                if isinstance(xyz, six.string_types):
                    warnings.warn("A 1-line symmetry op P1 CIF is detected!")
                    xyz = [xyz]
                try:
                    symops = [SymmOp.from_xyz_string(s)
                              for s in xyz]
                    break
                except ValueError:
                    continue
        if not symops:
            # Try to parse symbol
            for symmetry_label in ["_symmetry_space_group_name_H-M",
                                   "_symmetry_space_group_name_H_M",
                                   "_symmetry_space_group_name_H-M_",
                                   "_symmetry_space_group_name_H_M_",
                                   "_space_group_name_Hall",
                                   "_space_group_name_Hall_",
                                   "_space_group_name_H-M_alt",
                                   "_space_group_name_H-M_alt_",
                                   "_symmetry_space_group_name_hall",
                                   "_symmetry_space_group_name_hall_",
                                   "_symmetry_space_group_name_h-m",
                                   "_symmetry_space_group_name_h-m_"]:
                sg = data.data.get(symmetry_label)

                if sg:
                    sg = sub_spgrp(sg)
                    try:
                        spg = space_groups.get(sg)
                        if spg:
                            symops = SpaceGroup(spg).symmetry_ops
                            warnings.warn(
                                "No _symmetry_equiv_pos_as_xyz type key found. "
                                "Spacegroup from %s used." % symmetry_label)
                            break
                    except ValueError:
                        # Ignore any errors
                        pass

                    try:
                        for d in _get_cod_data():
                            if sg == re.sub("\s+", "",
                                            d["hermann_mauguin"]) :
                                xyz = d["symops"]
                                symops = [SymmOp.from_xyz_string(s)
                                          for s in xyz]
                                warnings.warn(
                                    "No _symmetry_equiv_pos_as_xyz type key found. "
                                    "Spacegroup from %s used." % symmetry_label)
                                break
                    except Exception as ex:
                        continue

                    if symops:
                        break
        if not symops:
            # Try to parse International number
            for symmetry_label in ["_space_group_IT_number",
                                   "_space_group_IT_number_",
                                   "_symmetry_Int_Tables_number",
                                   "_symmetry_Int_Tables_number_"]:
                if data.data.get(symmetry_label):
                    try:
                        i = int(str2float(data.data.get(symmetry_label)))
                        symops = SpaceGroup.from_int_number(i).symmetry_ops
                        break
                    except ValueError:
                        continue

        if not symops:
            warnings.warn("No _symmetry_equiv_pos_as_xyz type key found. "
                          "Defaulting to P1.")
            symops = [SymmOp.from_xyz_string(s) for s in ['x', 'y', 'z']]

        return symops
开发者ID:zulissi,项目名称:pymatgen,代码行数:88,代码来源:cif.py


示例9: _generate_ordered_structures


#.........这里部分代码省略.........
                            structures_to_remove.append(check_idx)

        if len(structures_to_remove):
            self.logger.info(
                "Removing {} duplicate ordered structures".format(
                    len(structures_to_remove)
                )
            )
            ordered_structures = [
                s
                for idx, s in enumerate(ordered_structures)
                if idx not in structures_to_remove
            ]
            ordered_structures_origins = [
                o
                for idx, o in enumerate(ordered_structures_origins)
                if idx not in structures_to_remove
            ]

        # also remove low symmetry structures
        if self.truncate_by_symmetry:

            # by default, keep structures with 5 most symmetric space groups
            if not isinstance(self.truncate_by_symmetry, int):
                self.truncate_by_symmetry = 5

            self.logger.info("Pruning low symmetry structures.")

            # first get a list of symmetries present
            symmetry_int_numbers = [
                s.get_space_group_info()[1] for s in ordered_structures
            ]

            # then count the number of symmetry operations for that space group
            num_sym_ops = [
                len(SpaceGroup.from_int_number(n).symmetry_ops)
                for n in symmetry_int_numbers
            ]

            # find the largest values...
            max_symmetries = sorted(list(set(num_sym_ops)), reverse=True)

            # ...and decide which ones to keep
            if len(max_symmetries) > self.truncate_by_symmetry:
                max_symmetries = max_symmetries[0:5]
            structs_to_keep = [
                (idx, num)
                for idx, num in enumerate(num_sym_ops)
                if num in max_symmetries
            ]

            # sort so that highest symmetry structs are first
            structs_to_keep = sorted(
                structs_to_keep, key=lambda x: (x[1], -x[0]), reverse=True
            )

            self.logger.info(
                "Removing {} low symmetry "
                "ordered structures".format(
                    len(ordered_structures) - len(structs_to_keep)
                )
            )

            ordered_structures = [ordered_structures[i] for i, _ in structs_to_keep]
            ordered_structures_origins = [
                ordered_structures_origins[i] for i, _ in structs_to_keep
            ]

            # and ensure fm is always at index 0
            fm_index = ordered_structures_origins.index("fm")
            ordered_structures.insert(0, ordered_structures.pop(fm_index))
            ordered_structures_origins.insert(
                0, ordered_structures_origins.pop(fm_index)
            )

        # if our input structure isn't in our generated structures,
        # let's add it manually and also keep a note of which structure
        # is our input: this is mostly for book-keeping/benchmarking
        self.input_index = None
        self.input_origin = None
        if self.input_analyzer.ordering != Ordering.NM:
            matches = [
                self.input_analyzer.matches_ordering(s) for s in ordered_structures
            ]
            if not any(matches):
                ordered_structures.append(self.input_analyzer.structure)
                ordered_structures_origins.append("input")
                self.logger.info(
                    "Input structure not present in enumerated structures, adding..."
                )
            else:
                self.logger.info(
                    "Input structure was found in enumerated "
                    "structures at index {}".format(matches.index(True))
                )
                self.input_index = matches.index(True)
                self.input_origin = ordered_structures_origins[self.input_index]

        self.ordered_structures = ordered_structures
        self.ordered_structure_origins = ordered_structures_origins
开发者ID:blondegeek,项目名称:pymatgen,代码行数:101,代码来源:analyzer.py


示例10: test_get_orbit

 def test_get_orbit(self):
     sg = SpaceGroup("Fm-3m")
     p = np.random.random_integers(0, 100, size=(3,))
     p /= 100
     self.assertLessEqual(len(sg.get_orbit(p)), sg.order)
开发者ID:orex,项目名称:pymatgen,代码行数:5,代码来源:test_groups.py


示例11: test_subgroup_supergroup

 def test_subgroup_supergroup(self):
     self.assertTrue(SpaceGroup('Pma2').is_subgroup(SpaceGroup('Pccm')))
     self.assertFalse(SpaceGroup.from_int_number(229).is_subgroup(
         SpaceGroup.from_int_number(230)))
开发者ID:zulissi,项目名称:pymatgen,代码行数:4,代码来源:test_groups.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap