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

Python cif.CifParser类代码示例

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

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



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

示例1: test_implicit_hydrogen

 def test_implicit_hydrogen(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         parser = CifParser(os.path.join(test_dir, 'Senegalite_implicit_hydrogen.cif'))
         for s in parser.get_structures():
             self.assertEqual(s.formula, "Al8 P4 O32")
             self.assertEqual(sum(s.site_properties['implicit_hydrogens']), 20)
开发者ID:czhengsci,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例2: test_one_line_symm

 def test_one_line_symm(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = os.path.join(test_dir, "OneLineSymmP1.cif")
         p = CifParser(f)
         s = p.get_structures()[0]
         self.assertEqual(s.formula, "Ga4 Pb2 O8")
开发者ID:dongsenfo,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例3: test_bad_cif

 def test_bad_cif(self):
     f = os.path.join(test_dir, "bad_occu.cif")
     p = CifParser(f)
     self.assertRaises(ValueError, p.get_structures)
     p = CifParser(f, occupancy_tolerance=2)
     s = p.get_structures()[0]
     self.assertAlmostEqual(s[0].species_and_occu["Al3+"], 0.5)
开发者ID:montoyjh,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例4: test_no_symmops

 def test_no_symmops(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = self.TEST_FILES_DIR / "nosymm.cif"
         p = CifParser(f)
         s = p.get_structures()[0]
         self.assertEqual(s.formula, "H96 C60 O8")
开发者ID:materialsproject,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例5: test_one_line_symm

 def test_one_line_symm(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = self.TEST_FILES_DIR / "OneLineSymmP1.cif"
         p = CifParser(f)
         s = p.get_structures()[0]
         self.assertEqual(s.formula, "Ga4 Pb2 O8")
开发者ID:materialsproject,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例6: setUp

 def setUp(self):
     warnings.filterwarnings("ignore")
     self.mcif = CifParser(self.TEST_FILES_DIR / "magnetic.example.NiO.mcif")
     self.mcif_ncl = CifParser(self.TEST_FILES_DIR / "magnetic.ncl.example.GdB4.mcif")
     self.mcif_incom = CifParser(self.TEST_FILES_DIR / "magnetic.incommensurate.example.Cr.mcif")
     self.mcif_disord = CifParser(self.TEST_FILES_DIR / "magnetic.disordered.example.CuMnO2.mcif")
     self.mcif_ncl2 = CifParser(self.TEST_FILES_DIR / "Mn3Ge_IR2.mcif")
开发者ID:materialsproject,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例7: test_jahn_teller_structure_analysis

    def test_jahn_teller_structure_analysis(self):
        parser = CifParser(os.path.join(test_dir, 'LiFePO4.cif'))
        LiFePO4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'Fe3O4.cif'))
        Fe3O4 = parser.get_structures()[0]

        self.assertTrue(self.jt.is_jahn_teller_active(LiFePO4))
        self.assertTrue(self.jt.is_jahn_teller_active(Fe3O4))

        LiFePO4_analysis = {
            'active': True,
            'strength': 'weak',
            'sites': [
                {
                    'ligand': 'O2-',
                    'ligand_bond_length_spread': 0.2111,
                    'ligand_bond_lengths': [2.1382,
                                            2.0840,
                                            2.0863,
                                            2.2383,
                                            2.2951,
                                            2.2215],
                    'strength': 'weak',
                    'motif': 'oct',
                    'motif_order_parameter': 0.1441,
                    'site_indices': [4, 5, 6, 7],
                    'species': 'Fe2+',
                    'spin_state': 'unknown'
                }
            ]
        }

        self.assertDictEqual(LiFePO4_analysis, self.jt.get_analysis(LiFePO4))
开发者ID:albalu,项目名称:pymatgen,代码行数:34,代码来源:test_jahnteller.py


示例8: test_no_symmops

 def test_no_symmops(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = os.path.join(test_dir, "nosymm.cif")
         p = CifParser(f)
         s = p.get_structures()[0]
         self.assertEqual(s.formula, "H96 C60 O8")
开发者ID:dongsenfo,项目名称:pymatgen,代码行数:7,代码来源:test_cif.py


示例9: setUp

 def setUp(self):
     """
     Setup Fe3O4  structure for testing multiple oxidation states
     """
     cif_ob = CifParser(os.path.join(test_dir, "Fe3O4.cif"))
     self._struct = cif_ob.get_structures()[0]
     self._valrad_evaluator = ValenceIonicRadiusEvaluator(self._struct)
     self._length = len(self._struct.sites)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:8,代码来源:test_point_defects.py


示例10: test_missing_atom_site_type_with_oxistates

 def test_missing_atom_site_type_with_oxistates(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         parser = CifParser(self.TEST_FILES_DIR / 'P24Ru4H252C296S24N16.cif')
         c = Composition({'S0+': 24, 'Ru0+': 4, 'H0+': 252, 'C0+': 296,
                          'N0+': 16, 'P0+': 24})
         for s in parser.get_structures(False):
             self.assertEqual(s.composition, c)
开发者ID:materialsproject,项目名称:pymatgen,代码行数:8,代码来源:test_cif.py


示例11: test_replacing_finite_precision_frac_coords

 def test_replacing_finite_precision_frac_coords(self):
     f = self.TEST_FILES_DIR / "cif_finite_precision_frac_coord_error.cif"
     with warnings.catch_warnings():
         p = CifParser(f)
         s = p.get_structures()[0]
         self.assertEqual(str(s.composition), "N5+24")
         self.assertIn("Some fractional co-ordinates rounded to ideal values to "
                       "avoid finite precision errors.", p.errors)
开发者ID:materialsproject,项目名称:pymatgen,代码行数:8,代码来源:test_cif.py


示例12: test_bad_cif

 def test_bad_cif(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = self.TEST_FILES_DIR / "bad_occu.cif"
         p = CifParser(f)
         self.assertRaises(ValueError, p.get_structures)
         p = CifParser(f, occupancy_tolerance=2)
         s = p.get_structures()[0]
         self.assertAlmostEqual(s[0].species["Al3+"], 0.5)
开发者ID:materialsproject,项目名称:pymatgen,代码行数:9,代码来源:test_cif.py


示例13: test_bad_cif

 def test_bad_cif(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         f = os.path.join(test_dir, "bad_occu.cif")
         p = CifParser(f)
         self.assertRaises(ValueError, p.get_structures)
         p = CifParser(f, occupancy_tolerance=2)
         s = p.get_structures()[0]
         self.assertAlmostEqual(s[0].species_and_occu["Al3+"], 0.5)
开发者ID:dongsenfo,项目名称:pymatgen,代码行数:9,代码来源:test_cif.py


示例14: test_cluster_from_file

 def test_cluster_from_file(self):
     r = CifParser(os.path.join(test_dir, "CoO19128.cif"))
     structure = r.get_structures()[0]
     atoms = Atoms(structure, "O", 10.0)
     atoms.write_file("ATOMS_test")
     mol_1 = Atoms.cluster_from_file("ATOMS_test")
     mol_2 = Atoms.cluster_from_file(os.path.join(test_dir, "ATOMS"))
     self.assertEqual(mol_1.formula, mol_2.formula)
     self.assertEqual(len(mol_1), len(mol_2))
     os.remove("ATOMS_test")
开发者ID:adozier,项目名称:pymatgen,代码行数:10,代码来源:test_inputs.py


示例15: setUp

 def setUp(self):
     self.mcif = CifParser(os.path.join(test_dir,
                                        "magnetic.example.NiO.mcif"))
     self.mcif_ncl = CifParser(os.path.join(test_dir,
                                            "magnetic.ncl.example.GdB4.mcif"))
     self.mcif_incom = CifParser(os.path.join(test_dir,
                                              "magnetic.incommensurate.example.Cr.mcif"))
     self.mcif_disord = CifParser(os.path.join(test_dir,
                                               "magnetic.disordered.example.CuMnO2.mcif"))
     self.mcif_ncl2 = CifParser(os.path.join(test_dir,
                                               "Mn3Ge_IR2.mcif"))
开发者ID:czhengsci,项目名称:pymatgen,代码行数:11,代码来源:test_cif.py


示例16: handle_insufficientpowderdata

def handle_insufficientpowderdata(cif_string):
    """
    Handles CIF parsing errors arising from too few or too many values in data loop for diffraction data.

    :param cif_string: (str) cif file
    :return: corrected cif string
    """
    smlineno = 0
    looplineno = 0
    cif_lines = json.loads(json.dumps(cif_string)).splitlines()
    powderdataline = False
    loopdataline = False
    cif_string_new = ''
    for lineno, line in enumerate(cif_lines):
        if '_sm_powderpattern_remark' in line:
            powderdataline = True
            smlineno = lineno + 1
            break
        else:
            cif_string_new += line + '\n'
    if powderdataline:
        for line in cif_lines[smlineno:]:
            line_list = line.split()
            if len(line_list) > 10:
                cif_string_new += line + '\n'
            elif 1 < len(line_list) < 11:
                cif_string_new += '#' + line + '\n'
    try:
        print CifParser.from_string(cif_string_new).get_structures()[0].as_dict()
        return cif_string_new
    except:
        print 'UNSUCCESSFUL 1st attempt (uncommenting lines with insufficient or too many values for powder pattern)'
        cif_string_new = ''
        for lineno, line in enumerate(cif_lines):
            if 'loop_' in line:
                if '_sm_powderpattern' in cif_lines[lineno + 1]:
                    cif_string_new += '#' + line + '\n'
                    loopdataline = True
                    looplineno = lineno + 1
                    break
                else:
                    cif_string_new += line + '\n'
            else:
                cif_string_new += line + '\n'
        if loopdataline:
            for line in cif_lines[looplineno:]:
                cif_string_new += '#' + line + '\n'
        try:
            print CifParser.from_string(cif_string_new).get_structures()[0].as_dict()
            return cif_string_new
        except:
            print 'UNSUCCESSFUL 2nd attempt (uncommenting all powder diffraction lines)'
            return cif_string_new
开发者ID:saurabh02,项目名称:mongoDB_postproc,代码行数:53,代码来源:cifEditor.py


示例17: setUp

 def setUp(self):
     filepath1 = os.path.join(test_dir, 'Li2O.cif')
     p = CifParser(filepath1).get_structures(False)[0]
     bv = BVAnalyzer()
     valences = bv.get_valences(p)
     el = [site.species_string for site in p.sites]
     val_dict = dict(zip(el, valences))
     self._radii = {}
     for k, v in val_dict.items():
         k1 = re.sub('[1-9,+,\-]', '', k)
         self._radii[k1] = float(Specie(k1, v).ionic_radius)
     p.remove(0)
     self._vac_struct = p
开发者ID:georgeyumnam,项目名称:pymatgen,代码行数:13,代码来源:test_zeoio.py


示例18: test_find_primitive

 def test_find_primitive(self):
     """
     F m -3 m Li2O testing of converting to primitive cell
     """
     parser = CifParser(os.path.join(test_dir, 'Li2O.cif'))
     structure = parser.get_structures(False)[0]
     s = SpacegroupAnalyzer(structure)
     primitive_structure = s.find_primitive()
     self.assertEqual(primitive_structure.formula, "Li2 O1")
     # This isn't what is expected. All the angles should be 60
     self.assertAlmostEqual(primitive_structure.lattice.alpha, 60)
     self.assertAlmostEqual(primitive_structure.lattice.beta, 60)
     self.assertAlmostEqual(primitive_structure.lattice.gamma, 60)
     self.assertAlmostEqual(primitive_structure.lattice.volume,
                            structure.lattice.volume / 4.0)
开发者ID:ansobolev,项目名称:pymatgen,代码行数:15,代码来源:test_analyzer.py


示例19: test_implicit_hydrogen

 def test_implicit_hydrogen(self):
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         parser = CifParser(self.TEST_FILES_DIR / 'Senegalite_implicit_hydrogen.cif')
         for s in parser.get_structures():
             self.assertEqual(s.formula, "Al8 P4 O32")
             self.assertEqual(sum(s.site_properties['implicit_hydrogens']), 20)
         self.assertIn("Structure has implicit hydrogens defined, "
                       "parsed structure unlikely to be suitable for use "
                       "in calculations unless hydrogens added.", parser.errors)
         parser = CifParser(self.TEST_FILES_DIR / 'cif_implicit_hydrogens_cod_1011130.cif')
         s = parser.get_structures()[0]
         self.assertIn("Structure has implicit hydrogens defined, "
                       "parsed structure unlikely to be suitable for use "
                       "in calculations unless hydrogens added.", parser.errors)
开发者ID:materialsproject,项目名称:pymatgen,代码行数:15,代码来源:test_cif.py


示例20: from_cif_file

    def from_cif_file(cif_file, source='', comment=''):
        """
        Static method to create Header object from cif_file

        Args:
            cif_file: cif_file path and name
            source: User supplied identifier, i.e. for Materials Project this
                would be the material ID number
            comment: User comment that goes in header

        Returns:
            Header Object
        """
        r = CifParser(cif_file)
        structure = r.get_structures()[0]
        return Header(structure, source, comment)
开发者ID:adozier,项目名称:pymatgen,代码行数:16,代码来源:inputs.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cifio.CifParser类代码示例发布时间:2022-05-25
下一篇:
Python cif.CifBlock类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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