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


Python IStructure.interpolate方法代码示例

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


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

示例1: test_interpolate_lattice

# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import interpolate [as 别名]
    def test_interpolate_lattice(self):
        coords = list()
        coords.append([0, 0, 0])
        coords.append([0.75, 0.5, 0.75])
        struct = IStructure(self.lattice, ["Si"] * 2, coords)
        coords2 = list()
        coords2.append([0, 0, 0])
        coords2.append([0.5, 0.5, 0.5])
        l2 = Lattice.from_lengths_and_angles([3,4,4], [100,100,70])
        struct2 = IStructure(l2, ["Si"] * 2, coords2)
        int_s = struct.interpolate(struct2, 2, interpolate_lattices=True)
        self.assertArrayAlmostEqual(struct.lattice.abc,
                                    int_s[0].lattice.abc)
        self.assertArrayAlmostEqual(struct.lattice.angles,
                                    int_s[0].lattice.angles)
        self.assertArrayAlmostEqual(struct2.lattice.abc,
                                    int_s[2].lattice.abc)
        self.assertArrayAlmostEqual(struct2.lattice.angles,
                                    int_s[2].lattice.angles)
        int_angles = [110.3976469, 94.5359731, 64.5165856]
        self.assertArrayAlmostEqual(int_angles,
                                    int_s[1].lattice.angles)

        # Assert that volume is monotonic
        self.assertTrue(struct2.lattice.volume >= int_s[1].lattice.volume)
        self.assertTrue(int_s[1].lattice.volume >= struct.lattice.volume)
开发者ID:gpetretto,项目名称:pymatgen,代码行数:28,代码来源:test_structure.py

示例2: test_interpolate_lattice_rotation

# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import interpolate [as 别名]
    def test_interpolate_lattice_rotation(self):
        l1 = Lattice([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
        l2 = Lattice([[-1.01, 0, 0], [0, -1.01, 0], [0, 0, 1]])
        coords = [[0, 0, 0], [0.75, 0.5, 0.75]]
        struct1 = IStructure(l1, ["Si"] * 2, coords)
        struct2 = IStructure(l2, ["Si"] * 2, coords)
        int_s = struct1.interpolate(struct2, 2, interpolate_lattices=True)

        # Assert that volume is monotonic
        self.assertTrue(struct2.lattice.volume >= int_s[1].lattice.volume)
        self.assertTrue(int_s[1].lattice.volume >= struct1.lattice.volume)
开发者ID:gpetretto,项目名称:pymatgen,代码行数:13,代码来源:test_structure.py

示例3: test_interpolate

# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import interpolate [as 别名]
    def test_interpolate(self):
        coords = list()
        coords.append([0, 0, 0])
        coords.append([0.75, 0.5, 0.75])
        struct = IStructure(self.lattice, ["Si"] * 2, coords)
        coords2 = list()
        coords2.append([0, 0, 0])
        coords2.append([0.5, 0.5, 0.5])
        struct2 = IStructure(self.struct.lattice, ["Si"] * 2, coords2)
        int_s = struct.interpolate(struct2, 10)
        for s in int_s:
            self.assertIsNotNone(s, "Interpolation Failed!")
            self.assertEqual(int_s[0].lattice, s.lattice)
        self.assertArrayEqual(int_s[1][1].frac_coords, [0.725, 0.5, 0.725])

        badlattice = [[1, 0.00, 0.00], [0, 1, 0.00], [0.00, 0, 1]]
        struct2 = IStructure(badlattice, ["Si"] * 2, coords2)
        self.assertRaises(ValueError, struct.interpolate, struct2)

        coords2 = list()
        coords2.append([0, 0, 0])
        coords2.append([0.5, 0.5, 0.5])
        struct2 = IStructure(self.struct.lattice, ["Si", "Fe"], coords2)
        self.assertRaises(ValueError, struct.interpolate, struct2)

        # Test autosort feature.
        s1 = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                       ["Fe"], [[0, 0, 0]])
        s1.pop(0)
        s2 = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                       ["Fe"], [[0, 0, 0]])
        s2.pop(2)
        random.shuffle(s2)

        for s in s1.interpolate(s2, autosort_tol=0.5):
            self.assertArrayAlmostEqual(s1[0].frac_coords, s[0].frac_coords)
            self.assertArrayAlmostEqual(s1[2].frac_coords, s[2].frac_coords)

        # Make sure autosort has no effect on simpler interpolations,
        # and with shuffled sites.
        s1 = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                       ["Fe"], [[0, 0, 0]])
        s2 = Structure.from_spacegroup("Fm-3m", Lattice.cubic(3),
                                       ["Fe"], [[0, 0, 0]])
        s2[0] = "Fe", [0.01, 0.01, 0.01]
        random.shuffle(s2)

        for s in s1.interpolate(s2, autosort_tol=0.5):
            self.assertArrayAlmostEqual(s1[1].frac_coords, s[1].frac_coords)
            self.assertArrayAlmostEqual(s1[2].frac_coords, s[2].frac_coords)
            self.assertArrayAlmostEqual(s1[3].frac_coords, s[3].frac_coords)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:53,代码来源:test_structure.py

示例4: test_interpolate_lattice

# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import interpolate [as 别名]
 def test_interpolate_lattice(self):
     coords = list()
     coords.append([0, 0, 0])
     coords.append([0.75, 0.5, 0.75])
     struct = IStructure(self.lattice, ["Si"] * 2, coords)
     coords2 = list()
     coords2.append([0, 0, 0])
     coords2.append([0.5, 0.5, 0.5])
     l2 = Lattice.from_lengths_and_angles([3, 4, 4], [100, 100, 70])
     struct2 = IStructure(l2, ["Si"] * 2, coords2)
     int_s = struct.interpolate(struct2, 2, interpolate_lattices=True)
     self.assertArrayAlmostEqual(struct.lattice.abc, int_s[0].lattice.abc)
     self.assertArrayAlmostEqual(struct.lattice.angles, int_s[0].lattice.angles)
     self.assertArrayAlmostEqual(struct2.lattice.abc, int_s[2].lattice.abc)
     self.assertArrayAlmostEqual(struct2.lattice.angles, int_s[2].lattice.angles)
     int_angles = [(a + struct2.lattice.angles[i]) / 2 for i, a in enumerate(struct.lattice.angles)]
     self.assertArrayAlmostEqual(int_angles, int_s[1].lattice.angles)
开发者ID:richardtran415,项目名称:pymatgen,代码行数:19,代码来源:test_structure.py

示例5: test_interpolate

# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import interpolate [as 别名]
    def test_interpolate(self):
        coords = list()
        coords.append([0, 0, 0])
        coords.append([0.75, 0.5, 0.75])
        struct = IStructure(self.lattice, ["Si"] * 2, coords)
        coords2 = list()
        coords2.append([0, 0, 0])
        coords2.append([0.5, 0.5, 0.5])
        struct2 = IStructure(self.struct.lattice, ["Si"] * 2, coords2)
        int_s = struct.interpolate(struct2, 10)
        for s in int_s:
            self.assertIsNotNone(s, "Interpolation Failed!")
        self.assertArrayEqual(int_s[1][1].frac_coords, [0.725, 0.5, 0.725])

        badlattice = [[1, 0.00, 0.00], [0, 1, 0.00], [0.00, 0, 1]]
        struct2 = IStructure(badlattice, ["Si"] * 2, coords2)
        self.assertRaises(ValueError, struct.interpolate, struct2)

        coords2 = list()
        coords2.append([0, 0, 0])
        coords2.append([0.5, 0.5, 0.5])
        struct2 = IStructure(self.struct.lattice, ["Si", "Fe"], coords2)
        self.assertRaises(ValueError, struct.interpolate, struct2)
开发者ID:miaoliu,项目名称:pymatgen,代码行数:25,代码来源:test_structure.py


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