本文整理汇总了Python中pymatgen.core.structure_modifier.StructureEditor.add_oxidation_state_by_site方法的典型用法代码示例。如果您正苦于以下问题:Python StructureEditor.add_oxidation_state_by_site方法的具体用法?Python StructureEditor.add_oxidation_state_by_site怎么用?Python StructureEditor.add_oxidation_state_by_site使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.structure_modifier.StructureEditor
的用法示例。
在下文中一共展示了StructureEditor.add_oxidation_state_by_site方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_oxi_state_decorated_structure
# 需要导入模块: from pymatgen.core.structure_modifier import StructureEditor [as 别名]
# 或者: from pymatgen.core.structure_modifier.StructureEditor import add_oxidation_state_by_site [as 别名]
def get_oxi_state_decorated_structure(self, structure):
"""
Get an oxidation state decorated structure. This currently works only
for ordered structures only.
Args:
structure:
Structure to analyze
Returns:
A modified structure that is oxidation state decorated.
Raises:
A ValueError is the valences cannot be determined.
"""
valences = self.get_valences(structure)
editor = StructureEditor(structure)
editor.add_oxidation_state_by_site(valences)
return editor.modified_structure
示例2: test_add_oxidation_states
# 需要导入模块: from pymatgen.core.structure_modifier import StructureEditor [as 别名]
# 或者: from pymatgen.core.structure_modifier.StructureEditor import add_oxidation_state_by_site [as 别名]
def test_add_oxidation_states(self):
si = Element("Si")
fe = Element("Fe")
coords = list()
coords.append([0, 0, 0])
coords.append([0.75, 0.5, 0.75])
lattice = Lattice.cubic(10)
s = Structure(lattice, [si, fe], coords)
oxidation_states = {"Fe": 2, "Si": -4}
mod = StructureEditor(s)
mod.add_oxidation_state_by_element(oxidation_states)
mod_s = mod.modified_structure
for site in mod_s:
for k in site.species_and_occu.keys():
self.assertEqual(k.oxi_state, oxidation_states[k.symbol],
"Wrong oxidation state assigned!")
oxidation_states = {"Fe": 2}
self.assertRaises(ValueError, mod.add_oxidation_state_by_element,
oxidation_states)
mod.add_oxidation_state_by_site([2, -4])
mod_s = mod.modified_structure
self.assertEqual(mod_s[0].specie.oxi_state, 2)
self.assertRaises(ValueError, mod.add_oxidation_state_by_site,
[1])