Skip to content

Commit

Permalink
FIX: Reporting when only PDOS is calculated (#207)
Browse files Browse the repository at this point in the history
Fix two issues when calculating only the PDOS:

* Show the correct energy cutoffs and k-points distance for the SCF.
* Properly show the "Electronic Structure" output, which currently isn't
shown because the `_update_view` method only checks for the
`band_structure` output.
  • Loading branch information
mbercx authored Feb 25, 2022
1 parent 44893f0 commit 498aee7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 10 additions & 9 deletions aiidalab_qe/node_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ def export_bands_data(work_chain_node):
)[0]
)
data["fermi_level"] = work_chain_node.outputs.band_parameters["fermi_energy"]
return jsanitize(data)
return [
jsanitize(data),
]


def export_pdos_data(work_chain_node):
if "dos" in work_chain_node.outputs:
fermi_energy = work_chain_node.outputs.band_parameters["fermi_energy"]
fermi_energy = work_chain_node.outputs.nscf_parameters["fermi_energy"]
x_label, energy_dos, energy_units = work_chain_node.outputs.dos.get_x()
tdos_values = {
f"{n} | {u}": v for n, v, u in work_chain_node.outputs.dos.get_y()
Expand Down Expand Up @@ -483,12 +485,11 @@ def _update_view(self):
self._show_structure()
self._results_shown.add("structure")

if (
"band_structure" not in self._results_shown
and "band_structure" in self.node.outputs
if "electronic_structure" not in self._results_shown and (
"band_structure" in self.node.outputs or "dos" in self.node.outputs
):
self._show_band_structure()
self._results_shown.add("band_structure")
self._show_electronic_structure()
self._results_shown.add("electronic_structure")

def _show_structure(self):
self._structure_view = StructureDataViewer(
Expand All @@ -497,12 +498,12 @@ def _show_structure(self):
self.result_tabs.children[1].children = [self._structure_view]
self.result_tabs.set_title(1, "Final Geometry")

def _show_band_structure(self):
def _show_electronic_structure(self):
data = export_data(self.node)
bands_data = data.get("bands", None)
dos_data = data.get("dos", None)
self._bands_plot_view = BandsPlotWidget(
bands=[bands_data], dos=dos_data, plot_fermilevel=True
bands=bands_data, dos=dos_data, plot_fermilevel=True
)
self.result_tabs.children[2].children = [self._bands_plot_view]
self.result_tabs.set_title(2, "Electronic Structure")
Expand Down
6 changes: 6 additions & 0 deletions aiidalab_qe/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def _generate_report_dict(qeapp_wc):
scf_kpoints_distance = qeapp_wc.inputs.bands.scf.kpoints_distance.value
bands_kpoints_distance = qeapp_wc.inputs.bands.bands_kpoints_distance.value
if run_pdos:
scf_kpoints_distance = (
scf_kpoints_distance or qeapp_wc.inputs.pdos.scf.kpoints_distance.value
)
pw_parameters = (
pw_parameters or qeapp_wc.inputs.pdos.scf.pw.parameters.get_dict()
)
nscf_kpoints_distance = qeapp_wc.inputs.pdos.nscf.kpoints_distance.value

if pw_parameters:
Expand Down

0 comments on commit 498aee7

Please sign in to comment.