Skip to content

Commit

Permalink
Use pymatgen symmetry analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 6, 2025
1 parent 070a430 commit 419f515
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/aiidalab_qe/app/result/components/summary/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _generate_report_parameters(self):
return {}

inputs = qeapp_wc.inputs
structure = inputs.structure
structure: orm.StructureData = inputs.structure
basic = ui_parameters["workchain"]
advanced = ui_parameters["advanced"]
ctime = qeapp_wc.ctime
Expand All @@ -190,21 +190,8 @@ def _generate_report_parameters(self):
}
}

symmetry = spglib.get_symmetry_dataset(
ase2spglib(structure.get_ase()),
symprec=1e-5,
angle_tolerance=1.0,
)
if any(structure.pbc):
report["initial_structure_properties"] |= {
"space_group": f"{symmetry['international']} ({symmetry['number']})",
"cell_lengths": "{:.3f} {:.3f} {:.3f}".format(*structure.cell_lengths),
"cell_angles": "{:.0f} {:.0f} {:.0f}".format(*structure.cell_angles),
}
else:
report["initial_structure_properties"] |= {
"point_group": symmetry["pointgroup"],
}
symmetry_group_info = self._get_symmetry_group_info(structure)
report["initial_structure_properties"] |= symmetry_group_info

report |= {
"basic_settings": {
Expand Down Expand Up @@ -298,6 +285,25 @@ def _generate_report_parameters(self):

return report

def _get_symmetry_group_info(self, structure):
from pymatgen.symmetry.analyzer import PointGroupAnalyzer, SpacegroupAnalyzer

pymatgen_structure = structure.get_pymatgen()
if any(structure.pbc):
analyzer = SpacegroupAnalyzer(structure=pymatgen_structure)
symbol = analyzer.get_space_group_symbol()
number = analyzer.get_space_group_number()
return {
"space_group": f"{symbol} ({number})",
"cell_lengths": "{:.3f} {:.3f} {:.3f}".format(*structure.cell_lengths),
"cell_angles": "{:.0f} {:.0f} {:.0f}".format(*structure.cell_angles),
}
else:
from pymatgen.symmetry.analyzer import PointGroupAnalyzer

analyzer = PointGroupAnalyzer(mol=pymatgen_structure)
return {"point_group": analyzer.get_pointgroup()}

@staticmethod
def _get_final_calcjob(node: orm.WorkChainNode) -> orm.CalcJobNode | None:
"""Get the final calculation job node called by a workchain node.
Expand Down

0 comments on commit 419f515

Please sign in to comment.