本文整理匯總了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')