本文整理汇总了Python中pymatgen.core.structure.IStructure.to方法的典型用法代码示例。如果您正苦于以下问题:Python IStructure.to方法的具体用法?Python IStructure.to怎么用?Python IStructure.to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.structure.IStructure
的用法示例。
在下文中一共展示了IStructure.to方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IStructureTest
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import to [as 别名]
#.........这里部分代码省略.........
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)
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)