本文整理汇总了Python中pymatgen.core.periodic_table.Specie.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Specie.from_dict方法的具体用法?Python Specie.from_dict怎么用?Python Specie.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.periodic_table.Specie
的用法示例。
在下文中一共展示了Specie.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_dict
# 需要导入模块: from pymatgen.core.periodic_table import Specie [as 别名]
# 或者: from pymatgen.core.periodic_table.Specie import from_dict [as 别名]
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)
示例2: from_dict
# 需要导入模块: from pymatgen.core.periodic_table import Specie [as 别名]
# 或者: from pymatgen.core.periodic_table.Specie import from_dict [as 别名]
def from_dict(d):
"""
Create Site from dict representation
"""
atoms_n_occu = {}
for sp_occu in d["species"]:
sp = Specie.from_dict(sp_occu) if "oxidation_state" in sp_occu \
else Element(sp_occu["element"])
atoms_n_occu[sp] = sp_occu["occu"]
props = d.get("properties", None)
return Site(atoms_n_occu, d["xyz"], properties=props)
示例3: from_dict
# 需要导入模块: from pymatgen.core.periodic_table import Specie [as 别名]
# 或者: from pymatgen.core.periodic_table.Specie import from_dict [as 别名]
def from_dict(cls, d):
return SubStructureSpecie.from_specie(Specie.from_dict(d['specie']), d.get('weight', 0.0))