本文整理汇总了Python中pymatgen.alchemy.materials.TransformedStructure.from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python TransformedStructure.from_dict方法的具体用法?Python TransformedStructure.from_dict怎么用?Python TransformedStructure.from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.alchemy.materials.TransformedStructure
的用法示例。
在下文中一共展示了TransformedStructure.from_dict方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_dict
# 需要导入模块: from pymatgen.alchemy.materials import TransformedStructure [as 别名]
# 或者: from pymatgen.alchemy.materials.TransformedStructure import from_dict [as 别名]
def test_from_dict(self):
d = json.load(open(os.path.join(test_dir, "transformations.json"), "r"))
d["other_parameters"] = {"tags": ["test"]}
ts = TransformedStructure.from_dict(d)
ts.other_parameters["author"] = "Will"
ts.append_transformation(SubstitutionTransformation({"Fe": "Mn"}))
self.assertEqual("MnPO4", ts.final_structure.composition.reduced_formula)
self.assertEqual(ts.other_parameters, {"author": "Will", "tags": ["test"]})
示例2: test_from_dict
# 需要导入模块: from pymatgen.alchemy.materials import TransformedStructure [as 别名]
# 或者: from pymatgen.alchemy.materials.TransformedStructure import from_dict [as 别名]
def test_from_dict(self):
d = json.load(open(os.path.join(test_dir, 'transformations.json'), 'r'))
d['other_parameters'] = {'tags': ['test']}
ts = TransformedStructure.from_dict(d)
ts.set_parameter('author', 'Will')
ts.append_transformation(SubstitutionTransformation({"Fe":"Mn"}))
self.assertEqual("MnPO4", ts.final_structure.composition.reduced_formula)
self.assertEqual(ts.other_parameters, {'author': 'Will', 'tags': ['test']})
示例3: CifParser
# 需要导入模块: from pymatgen.alchemy.materials import TransformedStructure [as 别名]
# 或者: from pymatgen.alchemy.materials.TransformedStructure import from_dict [as 别名]
excluded_bonding_elements = args.exclude_bonding[0].split(',') if args.exclude_bonding else []
file_format = args.format
filename = args.input_file[0]
s = None
if filename.endswith(".cif"):
file_format = "cif"
elif filename.startswith("POSCAR"):
file_format = "poscar"
elif re.search('\.json', filename):
file_format = 'mpjson'
if file_format == 'poscar':
p = Poscar.from_file(filename)
s = p.struct
elif file_format == 'cif':
r = CifParser(filename)
s = r.get_structures(False)[0]
else:
d = json.load(file_open_zip_aware(filename))
ts = TransformedStructure.from_dict(d)
s = ts.final_structure
if s:
vis = StructureVis(excluded_bonding_elements=excluded_bonding_elements)
vis.set_structure(s)
vis.show()