From 498aee71c894deebc44906618d99aa379ef5fee2 Mon Sep 17 00:00:00 2001 From: Marnik Bercx Date: Fri, 25 Feb 2022 11:27:08 +0100 Subject: [PATCH] FIX: Reporting when only PDOS is calculated (#207) 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. --- aiidalab_qe/node_view.py | 19 ++++++++++--------- aiidalab_qe/report.py | 6 ++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/aiidalab_qe/node_view.py b/aiidalab_qe/node_view.py index ccb0bc54a..07b58535d 100644 --- a/aiidalab_qe/node_view.py +++ b/aiidalab_qe/node_view.py @@ -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() @@ -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( @@ -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") diff --git a/aiidalab_qe/report.py b/aiidalab_qe/report.py index 8d586a6fe..d5f0e55b6 100644 --- a/aiidalab_qe/report.py +++ b/aiidalab_qe/report.py @@ -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: