Skip to content

Commit

Permalink
Handle space/point group correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Jan 5, 2025
1 parent d176956 commit 62f83a1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
46 changes: 31 additions & 15 deletions src/aiidalab_qe/app/result/components/summary/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def _generate_report_parameters(self):
Return a dictionary of the parameters.
"""
import spglib

from aiida.orm.utils.serialize import deserialize_unsafe
from aiidalab_widgets_base.utils import ase2spglib

qeapp_wc = self.fetch_process_node()

Expand All @@ -161,7 +164,7 @@ def _generate_report_parameters(self):
if "workchain" not in ui_parameters:
return {}

initial_structure = qeapp_wc.inputs.structure
structure = qeapp_wc.inputs.structure
basic = ui_parameters["workchain"]
advanced = ui_parameters["advanced"]
ctime = qeapp_wc.ctime
Expand All @@ -176,21 +179,34 @@ def _generate_report_parameters(self):
"creation_time": f"{format_time(ctime)} ({relative_time(ctime)})",
"modification_time": f"{format_time(mtime)} ({relative_time(mtime)})",
},
}

report |= {
"initial_structure_properties": {
"structure_pk": initial_structure.pk,
"structure_uuid": initial_structure.uuid,
"formula": initial_structure.get_formula(),
"num_atoms": len(initial_structure.sites),
"space_group": "{} ({})".format(
*initial_structure.get_pymatgen().get_space_group_info()
),
"cell_lengths": "{:.3f} {:.3f} {:.3f}".format(
*initial_structure.cell_lengths
),
"cell_angles": "{:.0f} {:.0f} {:.0f}".format(
*initial_structure.cell_angles
),
},
"structure_pk": structure.pk,
"structure_uuid": structure.uuid,
"formula": structure.get_formula(),
"num_atoms": len(structure.sites),
}
}

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"],
}

report |= {
"basic_settings": {
"relaxed": "off"
if basic["relax_type"] == "none"
Expand Down
5 changes: 5 additions & 0 deletions src/aiidalab_qe/app/result/components/summary/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
"type": "text",
"description": "The space group of the structure"
},
"point_group": {
"title": "Point group",
"type": "text",
"description": "The point group of the molecule"
},
"cell_lengths": {
"title": "Cell lengths in Å",
"type": "text",
Expand Down

0 comments on commit 62f83a1

Please sign in to comment.