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


Python Lattice.cubic方法代码示例

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


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

示例1: test_get_supercell_size

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_get_supercell_size(self):
        l = Lattice.cubic(1)
        l2 = Lattice.cubic(0.9)
        s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu', 'Ag'], [[0]*3]*5)
        s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)

        sm = StructureMatcher(supercell_size='volume')
        self.assertEqual(sm._get_supercell_size(s1, s2),
                         (1, True))
        self.assertEqual(sm._get_supercell_size(s2, s1),
                         (1, True))

        sm = StructureMatcher(supercell_size='num_sites')
        self.assertEqual(sm._get_supercell_size(s1, s2),
                         (2, False))
        self.assertEqual(sm._get_supercell_size(s2, s1),
                         (2, True))

        sm = StructureMatcher(supercell_size='Ag')
        self.assertEqual(sm._get_supercell_size(s1, s2),
                         (2, False))
        self.assertEqual(sm._get_supercell_size(s2, s1),
                         (2, True))

        sm = StructureMatcher(supercell_size='wfieoh')
        self.assertRaises(ValueError, sm._get_supercell_size, s1, s2)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:28,代码来源:test_structure_matcher.py

示例2: test_fit

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_fit(self):
        """
        Take two known matched structures
            1) Ensure match
            2) Ensure match after translation and rotations
            3) Ensure no-match after large site translation
            4) Ensure match after site shuffling
            """
        sm = StructureMatcher()

        self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))

        # Test rotational/translational invariance
        op = SymmOp.from_axis_angle_and_translation([0, 0, 1], 30, False,
                                                    np.array([0.4, 0.7, 0.9]))
        self.struct_list[1].apply_operation(op)
        self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))

        #Test failure under large atomic translation
        self.struct_list[1].translate_sites([0], [.4, .4, .2],
                                            frac_coords=True)
        self.assertFalse(sm.fit(self.struct_list[0], self.struct_list[1]))

        self.struct_list[1].translate_sites([0], [-.4, -.4, -.2],
                                            frac_coords=True)
        # random.shuffle(editor._sites)
        self.assertTrue(sm.fit(self.struct_list[0], self.struct_list[1]))
        #Test FrameworkComporator
        sm2 = StructureMatcher(comparator=FrameworkComparator())
        lfp = self.get_structure("LiFePO4")
        nfp = self.get_structure("NaFePO4")
        self.assertTrue(sm2.fit(lfp, nfp))
        self.assertFalse(sm.fit(lfp, nfp))

        #Test anonymous fit.
        self.assertEqual(sm.fit_anonymous(lfp, nfp), True)
        self.assertAlmostEqual(sm.get_rms_anonymous(lfp, nfp)[0],
                               0.060895871160262717)

        #Test partial occupancies.
        s1 = Structure(Lattice.cubic(3),
                       [{"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.5}],
                       [[0, 0, 0], [0.25, 0.25, 0.25],
                        [0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
        s2 = Structure(Lattice.cubic(3),
                       [{"Fe": 0.25}, {"Fe": 0.5}, {"Fe": 0.5}, {"Fe": 0.75}],
                       [[0, 0, 0], [0.25, 0.25, 0.25],
                        [0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
        self.assertFalse(sm.fit(s1, s2))
        self.assertFalse(sm.fit(s2, s1))
        s2 = Structure(Lattice.cubic(3),
                       [{"Mn": 0.5}, {"Mn": 0.5}, {"Mn": 0.5},
                        {"Mn": 0.5}],
                       [[0, 0, 0], [0.25, 0.25, 0.25],
                        [0.5, 0.5, 0.5], [0.75, 0.75, 0.75]])
        self.assertEqual(sm.fit_anonymous(s1, s2), True)

        self.assertAlmostEqual(sm.get_rms_anonymous(s1, s2)[0], 0)
开发者ID:eantono,项目名称:pymatgen,代码行数:60,代码来源:test_structure_matcher.py

示例3: setUp

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
 def setUp(self):
     c1 = [[0.5] * 3, [0.9] * 3]
     c2 = [[0.5] * 3, [0.9, 0.1, 0.1]]
     s1 = Structure(Lattice.cubic(5), ['Si', 'Si'], c1)
     s2 = Structure(Lattice.cubic(5), ['Si', 'Si'], c2)
     structs = []
     for s in s1.interpolate(s2, 3, pbc=True):
         structs.append(Structure.from_sites(s.sites, to_unit_cell=True))
     self.structures = structs
     self.vis = MITNEBSet(self.structures)
开发者ID:matk86,项目名称:pymatgen,代码行数:12,代码来源:test_sets.py

示例4: test_writestring

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
 def test_writestring(self):
     # Test for the string export of s atructure into the exciting input xml schema
     input_string = (
         '<input xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
         'xsi:noNamespaceSchemaLocation="http://xml.exciting-code.org/excitinginput'
         '.xsd">\n  <title>Na4 Cl4</title>\n  <structure speciespath="./">\n    '
         '<crystal scale="1.8897543768634038">\n      <basevect>      5.62000000'
         '       0.00000000       0.00000000</basevect>\n      <basevect>      '
         '0.00000000       5.62000000       0.00000000</basevect>\n      '
         '<basevect>      0.00000000       0.00000000       5.62000000</basevect>'
         '\n    </crystal>\n    <species speciesfile="Na.xml">\n      <atom coord='
         '"      0.00000000       0.00000000       0.00000000" />\n      <atom coor'
         'd="      0.50000000       0.50000000       0.00000000" />\n      <atom co'
         'ord="      0.50000000       0.00000000       0.50000000" />\n      <atom '
         'coord="      0.00000000       0.50000000       0.50000000" />\n    </spec'
         'ies>\n    <species speciesfile="Cl.xml">\n      <atom coord="      0.5000'
         '0000       0.00000000       0.00000000" />\n      <atom coord="      0.00'
         '000000       0.50000000       0.00000000" />\n      <atom coord="      0.'
         '00000000       0.00000000       0.50000000" />\n      <atom coord="      '
         '0.50000000       0.50000000       0.50000000" />\n    </species>\n  </str'
         'ucture>\n</input>\n')
     lattice = Lattice.cubic('5.62')
     structure = Structure(lattice, ['Na', 'Na', 'Na', 'Na',
                                     'Cl', 'Cl', 'Cl', 'Cl'],
                           [[0, 0, 0], [0.5, 0.5, 0.0], [0.5, 0.0, 0.5],
                            [0.0, 0.5, 0.5],
                            [0.5, 0.0, 0.0], [0.0, 0.5, 0.0],
                            [0.0, 0.0, 0.5], [0.5, 0.5, 0.5]])
     excin = ExcitingInput(structure)
     for l1, l2 in zip(input_string.split("\n"),
                       excin.write_string('unchanged').split("\n")):
         if not l1.strip().startswith("<crystal scale"):
             self.assertEqual(l1, l2)
开发者ID:ExpHP,项目名称:pymatgen,代码行数:35,代码来源:test_exciting.py

示例5: test_out_of_cell_s2_like_s1

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
 def test_out_of_cell_s2_like_s1(self):
     l = Lattice.cubic(5)
     s1 = Structure(l, ["Si", "Ag", "Si"], [[0, 0, -0.02], [0, 0, 0.001], [0.7, 0.4, 0.5]])
     s2 = Structure(l, ["Si", "Ag", "Si"], [[0, 0, 0.98], [0, 0, 0.99], [0.7, 0.4, 0.5]])
     new_s2 = StructureMatcher(primitive_cell=False).get_s2_like_s1(s1, s2)
     dists = np.sum((s1.cart_coords - new_s2.cart_coords) ** 2, axis=-1) ** 0.5
     self.assertLess(np.max(dists), 0.1)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:9,代码来源:test_structure_matcher.py

示例6: test_get_supercells

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_get_supercells(self):
        sm = StructureMatcher(comparator=ElementComparator())
        l = Lattice.cubic(1)
        l2 = Lattice.cubic(0.5)
        s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu'], [[0]*3]*4)
        s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)
        scs = list(sm._get_supercells(s1, s2, 8, False))
        for x in scs:
            self.assertAlmostEqual(abs(np.linalg.det(x[3])), 8)
            self.assertEqual(len(x[0]), 4)
            self.assertEqual(len(x[1]), 24)
        self.assertEqual(len(scs), 48)

        scs = list(sm._get_supercells(s2, s1, 8, True))
        for x in scs:
            self.assertAlmostEqual(abs(np.linalg.det(x[3])), 8)
            self.assertEqual(len(x[0]), 24)
            self.assertEqual(len(x[1]), 4)
        self.assertEqual(len(scs), 48)
开发者ID:eantono,项目名称:pymatgen,代码行数:21,代码来源:test_structure_matcher.py

示例7: test_get_mask

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_get_mask(self):
        sm = StructureMatcher(comparator=ElementComparator())
        l = Lattice.cubic(1)
        s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu'], [[0]*3]*4)
        s2 = Structure(l, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)

        result = [[True, False, True, False],
                  [True, False, True, False],
                  [True, True, False, True]]
        m, inds, i = sm._get_mask(s1, s2, 1, True)
        self.assertTrue(np.all(m == result))
        self.assertTrue(i == 2)
        self.assertEqual(inds, [2])

        #test supercell with match
        result = [[1, 1, 0, 0, 1, 1, 0, 0],
                  [1, 1, 0, 0, 1, 1, 0, 0],
                  [1, 1, 1, 1, 0, 0, 1, 1]]
        m, inds, i = sm._get_mask(s1, s2, 2, True)
        self.assertTrue(np.all(m == result))
        self.assertTrue(i == 2)
        self.assertTrue(np.allclose(inds, np.array([4])))

        #test supercell without match
        result = [[1, 1, 1, 1, 1, 1],
                  [0, 0, 0, 0, 1, 1],
                  [1, 1, 1, 1, 0, 0],
                  [0, 0, 0, 0, 1, 1]]
        m, inds, i = sm._get_mask(s2, s1, 2, True)
        self.assertTrue(np.all(m == result))
        self.assertTrue(i == 0)
        self.assertTrue(np.allclose(inds, np.array([])))

        #test s2_supercell
        result = [[1, 1, 1], [1, 1, 1],
                  [0, 0, 1], [0, 0, 1],
                  [1, 1, 0], [1, 1, 0],
                  [0, 0, 1], [0, 0, 1]]
        m, inds, i = sm._get_mask(s2, s1, 2, False)
        self.assertTrue(np.all(m == result))
        self.assertTrue(i == 0)
        self.assertTrue(np.allclose(inds, np.array([])))

        #test for multiple translation indices
        s1 = Structure(l, ['Cu', 'Ag', 'Cu', 'Ag', 'Ag'], [[0]*3]*5)
        s2 = Structure(l, ['Ag', 'Cu', 'Ag'], [[0]*3]*3)
        result = [[1, 0, 1, 0, 0],
                  [0, 1, 0, 1, 1],
                  [1, 0, 1, 0, 0]]
        m, inds, i = sm._get_mask(s1, s2, 1, True)

        self.assertTrue(np.all(m == result))
        self.assertTrue(i == 1)
        self.assertTrue(np.allclose(inds, [0, 2]))
开发者ID:eantono,项目名称:pymatgen,代码行数:56,代码来源:test_structure_matcher.py

示例8: test_get_supercell_size

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_get_supercell_size(self):
        l = Lattice.cubic(1)
        l2 = Lattice.cubic(0.9)
        s1 = Structure(l, ["Mg", "Cu", "Ag", "Cu", "Ag"], [[0] * 3] * 5)
        s2 = Structure(l2, ["Cu", "Cu", "Ag"], [[0] * 3] * 3)

        sm = StructureMatcher(supercell_size="volume")
        self.assertEqual(sm._get_supercell_size(s1, s2), (1, True))
        self.assertEqual(sm._get_supercell_size(s2, s1), (1, True))

        sm = StructureMatcher(supercell_size="num_sites")
        self.assertEqual(sm._get_supercell_size(s1, s2), (2, False))
        self.assertEqual(sm._get_supercell_size(s2, s1), (2, True))

        sm = StructureMatcher(supercell_size="Ag")
        self.assertEqual(sm._get_supercell_size(s1, s2), (2, False))
        self.assertEqual(sm._get_supercell_size(s2, s1), (2, True))

        sm = StructureMatcher(supercell_size="wfieoh")
        self.assertRaises(ValueError, sm._get_supercell_size, s1, s2)
开发者ID:dcossey014,项目名称:pymatgen,代码行数:22,代码来源:test_structure_matcher.py

示例9: test_nelect

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_nelect(self):
        coords = [[0] * 3, [0.5] * 3, [0.75] * 3]
        lattice = Lattice.cubic(4)
        s = Structure(lattice, ['Si', 'Si', 'Fe'], coords)
        self.assertAlmostEqual(MITRelaxSet(s).nelect, 16)

        # Check that it works even when oxidation states are present. Was a bug
        # previously.
        s = Structure(lattice, ['Si4+', 'Si4+', 'Fe2+'], coords)
        self.assertAlmostEqual(MITRelaxSet(s).nelect, 16)
        self.assertAlmostEqual(MPRelaxSet(s).nelect, 22)
开发者ID:matk86,项目名称:pymatgen,代码行数:13,代码来源:test_sets.py

示例10: test_metal_check

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_metal_check(self):
        structure = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                              ["Cu"], [[0, 0, 0]])

        with warnings.catch_warnings(record=True) as w:
            # Cause all warnings to always be triggered.
            warnings.simplefilter("always")
            # Trigger a warning.
            vis = MITRelaxSet(structure)
            incar = vis.incar
            # Verify some things
            self.assertIn("ISMEAR", str(w[-1].message))
开发者ID:blondegeek,项目名称:pymatgen,代码行数:14,代码来源:test_sets.py

示例11: test_get_supercell_size

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def test_get_supercell_size(self):
        l = Lattice.cubic(1)
        l2 = Lattice.cubic(0.9)
        s1 = Structure(l, ['Mg', 'Cu', 'Ag', 'Cu', 'Ag'], [[0]*3]*5)
        s2 = Structure(l2, ['Cu', 'Cu', 'Ag'], [[0]*3]*3)

        sm = StructureMatcher(supercell_size='volume')
        result = sm._get_supercell_size(s1, s2)
        self.assertEqual(result[0], 1)
        self.assertEqual(result[1], True)

        result = sm._get_supercell_size(s2, s1)
        self.assertEqual(result[0], 1)
        self.assertEqual(result[1], True)

        sm = StructureMatcher(supercell_size='num_sites')
        result = sm._get_supercell_size(s1, s2)
        self.assertEqual(result[0], 2)
        self.assertEqual(result[1], False)

        result = sm._get_supercell_size(s2, s1)
        self.assertEqual(result[0], 2)
        self.assertEqual(result[1], True)
开发者ID:eantono,项目名称:pymatgen,代码行数:25,代码来源:test_structure_matcher.py

示例12: setUp

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
    def setUp(self):
        parser = CifParser(os.path.join(test_dir, 'Fe.cif'))
        self.Fe = parser.get_structures()[0]

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

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

        parser = CifParser(os.path.join(test_dir, 'magnetic.ncl.example.GdB4.mcif'))
        self.GdB4 = parser.get_structures()[0]

        parser = CifParser(os.path.join(test_dir, 'magnetic.example.NiO.mcif'))
        self.NiO_expt = parser.get_structures()[0]

        latt = Lattice.cubic(4.17)
        species = ["Ni", "O"]
        coords = [[0, 0, 0],
                  [0.5, 0.5, 0.5]]
        self.NiO = Structure.from_spacegroup(225, latt, species, coords)

        latt = Lattice([[2.085, 2.085, 0.0],
                        [0.0, -2.085, -2.085],
                        [-2.085, 2.085, -4.17]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0, 0.5],
                  [0, 0, 0],
                  [0.25, 0.5, 0.25],
                  [0.75, 0.5, 0.75]]
        self.NiO_AFM_111 = Structure(latt, species, coords, site_properties={'magmom': [-5, 5, 0, 0]})

        latt = Lattice([[2.085, 2.085, 0],
                        [0, 0, -4.17],
                        [-2.085, 2.085, 0]])
        species = ["Ni", "Ni", "O", "O"]
        coords = [[0.5, 0.5, 0.5],
                  [0, 0, 0],
                  [0, 0.5, 0],
                  [0.5, 0, 0.5]]
        self.NiO_AFM_001 = Structure(latt, species, coords, site_properties={'magmom': [-5, 5, 0, 0]})
开发者ID:setten,项目名称:pymatgen,代码行数:43,代码来源:test_analyzer.py

示例13: Workflow

# 需要导入模块: from pymatgen.core import Lattice [as 别名]
# 或者: from pymatgen.core.Lattice import cubic [as 别名]
        if scan:
            wf_name += " - SCAN"
        wf = Workflow(fws, name=wf_name)

        wf = add_additional_fields_to_taskdocs(wf, {"wf_meta": self.wf_meta})

        tag = "magnetic_orderings group: >>{}<<".format(self.uuid)
        wf = add_tags(wf, [tag, ordered_structure_origins])

        return wf


if __name__ == "__main__":

    # for trying workflows

    from fireworks import LaunchPad

    latt = Lattice.cubic(4.17)
    species = ["Ni", "O"]
    coords = [[0.00000, 0.00000, 0.00000], [0.50000, 0.50000, 0.50000]]
    NiO = Structure.from_spacegroup(225, latt, species, coords)

    wf_deformation = get_wf_magnetic_deformation(NiO)

    wf_orderings = MagneticOrderingsWF(NiO).get_wf()

    lpad = LaunchPad.auto_load()
    lpad.add_wf(wf_orderings)
    lpad.add_wf(wf_deformation)
开发者ID:montoyjh,项目名称:MatMethods,代码行数:32,代码来源:magnetism.py


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