本文整理汇总了Python中pymatgen.core.periodic_table.DummySpecie类的典型用法代码示例。如果您正苦于以下问题:Python DummySpecie类的具体用法?Python DummySpecie怎么用?Python DummySpecie使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DummySpecie类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_string
def test_from_string(self):
sp = DummySpecie.from_string("X")
self.assertEqual(sp.oxi_state, 0)
sp = DummySpecie.from_string("X2+")
self.assertEqual(sp.oxi_state, 2)
sp = DummySpecie.from_string("X2+spin=5")
self.assertEqual(sp.oxi_state, 2)
self.assertEqual(sp.spin, 5)
示例2: from_dict
def from_dict(cls, d, lattice=None):
"""
Create PeriodicSite from dict representation.
Args:
d (dict): dict representation of PeriodicSite
lattice: Optional lattice to override lattice specified in d.
Useful for ensuring all sites in a structure share the same
lattice.
Returns:
PeriodicSite
"""
atoms_n_occu = {}
for sp_occu in d["species"]:
if "oxidation_state" in sp_occu and Element.is_valid_symbol(
sp_occu["element"]):
sp = Specie.from_dict(sp_occu)
elif "oxidation_state" in sp_occu:
sp = DummySpecie.from_dict(sp_occu)
else:
sp = Element(sp_occu["element"])
atoms_n_occu[sp] = sp_occu["occu"]
props = d.get("properties", None)
lattice = lattice if lattice else Lattice.from_dict(d["lattice"])
return cls(atoms_n_occu, d["abc"], lattice, properties=props)
示例3: test_safe_from_composition
def test_safe_from_composition(self):
c = Composition({'Xa': 1, 'Fe': 1})
self.assertEqual(DummySpecie.safe_from_composition(c).symbol, 'Xb')
self.assertEqual(DummySpecie.safe_from_composition(c, 1).symbol, 'Xb')