本文整理汇总了Python中pymatgen.core.structure.IStructure.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python IStructure.from_dict方法的具体用法?Python IStructure.from_dict怎么用?Python IStructure.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.core.structure.IStructure
的用法示例。
在下文中一共展示了IStructure.from_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_dict
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import from_dict [as 别名]
def test_from_dict(self):
d = self.propertied_structure.as_dict()
s = IStructure.from_dict(d)
self.assertEqual(s[0].magmom, 5)
d = self.propertied_structure.as_dict(0)
s2 = IStructure.from_dict(d)
self.assertEqual(s, s2)
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)
示例2: test_from_dict
# 需要导入模块: from pymatgen.core.structure import IStructure [as 别名]
# 或者: from pymatgen.core.structure.IStructure import from_dict [as 别名]
def test_from_dict(self):
d = self.propertied_structure.to_dict
s = IStructure.from_dict(d)
self.assertEqual(s[0].magmom, 5)
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)