本文整理汇总了Python中pymatgen.core.structure.IStructure.copy方法的典型用法代码示例。如果您正苦于以下问题:Python IStructure.copy方法的具体用法?Python IStructure.copy怎么用?Python IStructure.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.structure.IStructure
的用法示例。
在下文中一共展示了IStructure.copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_copy
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import copy [as 别名]
def test_copy(self):
new_struct = self.propertied_structure.copy(site_properties={"charge": [2, 3]})
self.assertEqual(new_struct[0].magmom, 5)
self.assertEqual(new_struct[1].magmom, -5)
self.assertEqual(new_struct[0].charge, 2)
self.assertEqual(new_struct[1].charge, 3)
coords = list()
coords.append([0, 0, 0])
coords.append([0.0, 0, 0.0000001])
structure = IStructure(self.lattice, ["O", "Si"], coords, site_properties={"magmom": [5, -5]})
new_struct = structure.copy(site_properties={"charge": [2, 3]}, sanitize=True)
self.assertEqual(new_struct[0].magmom, -5)
self.assertEqual(new_struct[1].magmom, 5)
self.assertEqual(new_struct[0].charge, 3)
self.assertEqual(new_struct[1].charge, 2)
self.assertAlmostEqual(new_struct.volume, structure.volume)
示例2: IStructureTest
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import copy [as 别名]
#.........这里部分代码省略.........
d = {'lattice': {'a': 3.8401979337, 'volume': 40.044794644251596,
'c': 3.8401979337177736, 'b': 3.840198994344244,
'matrix': [[3.8401979337, 0.0, 0.0],
[1.9200989668, 3.3257101909, 0.0],
[0.0, -2.2171384943, 3.1355090603]],
'alpha': 119.9999908639842, 'beta': 90.0,
'gamma': 60.000009137322195},
'sites': [{'properties': {'magmom': 5}, 'abc': [0.0, 0.0, 0.0],
'occu': 1.0, 'species': [{'occu': 1.0,
'oxidation_state': -2,
'properties': {'spin': 3},
'element': 'O'}],
'label': 'O2-', 'xyz': [0.0, 0.0, 0.0]},
{'properties': {'magmom': -5},
'abc': [0.75, 0.5, 0.75],
'occu': 0.8, 'species': [{'occu': 0.8,
'oxidation_state': 2,
'properties': {'spin': 2},
'element': 'Mg'}],
'label': 'Mg2+:0.800',
'xyz': [3.8401979336749994, 1.2247250003039056e-06,
2.351631795225]}]}
s = IStructure.from_dict(d)
self.assertEqual(s[0].magmom, 5)
self.assertEqual(s[0].specie.spin, 3)
self.assertEqual(type(s), IStructure)
def test_site_properties(self):
site_props = self.propertied_structure.site_properties
self.assertEqual(site_props['magmom'], [5, -5])
self.assertEqual(self.propertied_structure[0].magmom, 5)
self.assertEqual(self.propertied_structure[1].magmom, -5)
def test_copy(self):
new_struct = self.propertied_structure.copy(site_properties={'charge':
[2, 3]})
self.assertEqual(new_struct[0].magmom, 5)
self.assertEqual(new_struct[1].magmom, -5)
self.assertEqual(new_struct[0].charge, 2)
self.assertEqual(new_struct[1].charge, 3)
coords = list()
coords.append([0, 0, 0])
coords.append([0., 0, 0.0000001])
structure = IStructure(self.lattice, ["O", "Si"], coords,
site_properties={'magmom': [5, -5]})
new_struct = structure.copy(site_properties={'charge': [2, 3]},
sanitize=True)
self.assertEqual(new_struct[0].magmom, -5)
self.assertEqual(new_struct[1].magmom, 5)
self.assertEqual(new_struct[0].charge, 3)
self.assertEqual(new_struct[1].charge, 2)
self.assertAlmostEqual(new_struct.volume, structure.volume)
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)
示例3: IStructureTest
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import copy [as 别名]
#.........这里部分代码省略.........
d = {'lattice': {'a': 3.8401979337, 'volume': 40.044794644251596,
'c': 3.8401979337177736, 'b': 3.840198994344244,
'matrix': [[3.8401979337, 0.0, 0.0],
[1.9200989668, 3.3257101909, 0.0],
[0.0, -2.2171384943, 3.1355090603]],
'alpha': 119.9999908639842, 'beta': 90.0,
'gamma': 60.000009137322195},
'sites': [{'properties': {'magmom': 5}, 'abc': [0.0, 0.0, 0.0],
'occu': 1.0, 'species': [{'occu': 1.0,
'oxidation_state': -2,
'properties': {'spin': 3},
'element': 'O'}],
'label': 'O2-', 'xyz': [0.0, 0.0, 0.0]},
{'properties': {'magmom': -5},
'abc': [0.75, 0.5, 0.75],
'occu': 0.8, 'species': [{'occu': 0.8,
'oxidation_state': 2,
'properties': {'spin': 2},
'element': 'Mg'}],
'label': 'Mg2+:0.800',
'xyz': [3.8401979336749994, 1.2247250003039056e-06,
2.351631795225]}]}
s = IStructure.from_dict(d)
self.assertEqual(s[0].magmom, 5)
self.assertEqual(s[0].specie.spin, 3)
self.assertEqual(type(s), IStructure)
def test_site_properties(self):
site_props = self.propertied_structure.site_properties
self.assertEqual(site_props['magmom'], [5, -5])
self.assertEqual(self.propertied_structure[0].magmom, 5)
self.assertEqual(self.propertied_structure[1].magmom, -5)
def test_copy(self):
new_struct = self.propertied_structure.copy(site_properties={'charge':
[2, 3]})
self.assertEqual(new_struct[0].magmom, 5)
self.assertEqual(new_struct[1].magmom, -5)
self.assertEqual(new_struct[0].charge, 2)
self.assertEqual(new_struct[1].charge, 3)
coords = list()
coords.append([0, 0, 0])
coords.append([0., 0, 0.0000001])
structure = IStructure(self.lattice, ["O", "Si"], coords,
site_properties={'magmom': [5, -5]})
new_struct = structure.copy(site_properties={'charge': [2, 3]},
sanitize=True)
self.assertEqual(new_struct[0].magmom, -5)
self.assertEqual(new_struct[1].magmom, 5)
self.assertEqual(new_struct[0].charge, 3)
self.assertEqual(new_struct[1].charge, 2)
self.assertAlmostEqual(new_struct.volume, structure.volume)
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)