本文整理汇总了Python中pymatgen.analysis.structure_matcher.StructureMatcher.as_dict方法的典型用法代码示例。如果您正苦于以下问题:Python StructureMatcher.as_dict方法的具体用法?Python StructureMatcher.as_dict怎么用?Python StructureMatcher.as_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.analysis.structure_matcher.StructureMatcher
的用法示例。
在下文中一共展示了StructureMatcher.as_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_as_dict_and_from_dict
# 需要导入模块: from pymatgen.analysis.structure_matcher import StructureMatcher [as 别名]
# 或者: from pymatgen.analysis.structure_matcher.StructureMatcher import as_dict [as 别名]
def test_as_dict_and_from_dict(self):
sm = StructureMatcher(ltol=0.1, stol=0.2, angle_tol=2,
primitive_cell=False, scale=False,
comparator=FrameworkComparator())
d = sm.as_dict()
sm2 = StructureMatcher.from_dict(d)
self.assertEqual(sm2.as_dict(), d)
示例2: compare_structures
# 需要导入模块: from pymatgen.analysis.structure_matcher import StructureMatcher [as 别名]
# 或者: from pymatgen.analysis.structure_matcher.StructureMatcher import as_dict [as 别名]
def compare_structures(options):
"""Inspired to a similar function in pmg_structure."""
paths = options.paths
if len(paths) < 2:
print("You need more than one structure to compare!")
return 1
try:
structures = [abilab.Structure.from_file(p) for p in paths]
except Exception as ex:
print("Error reading structures from files. Are they in the right format?")
print(str(ex))
return 1
from pymatgen.analysis.structure_matcher import StructureMatcher, ElementComparator
compareby = "species" if options.anonymous else "element"
m = StructureMatcher() if compareby == "species" else StructureMatcher(comparator=ElementComparator())
print("Grouping %s structures by `%s` with `anonymous: %s`" % (len(structures), compareby, options.anonymous))
for i, grp in enumerate(m.group_structures(structures, anonymous=options.anonymous)):
print("Group {}: ".format(i))
for s in grp:
spg_symbol, international_number = s.get_space_group_info()
print("\t- {} ({}), vol: {:.2f} A^3, {} ({})".format(
paths[structures.index(s)], s.formula, s.volume, spg_symbol, international_number))
print()
if options.verbose:
pprint(m.as_dict())