Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/degauss widget pdos tab #833

Merged
merged 9 commits into from
Oct 2, 2024
38 changes: 38 additions & 0 deletions src/aiidalab_qe/plugins/pdos/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from aiida_quantumespresso.workflows.pdos import PdosWorkChain
from aiidalab_qe.common.panel import Panel

RYDBERG_TO_EV = 13.605703976


class Setting(Panel):
title = "PDOS"
Expand All @@ -31,15 +33,45 @@ def __init__(self, **kwargs):
disabled=False,
style={"description_width": "initial"},
)
self.use_pdos_degauss = ipw.Checkbox(
value=False,
description="Use custom PDOS degauss",
style={"description_width": "initial"},
)
self.pdos_degauss = ipw.BoundedFloatText(
min=0.001,
step=0.001,
value=0.01,
AndresOrtegaGuerrero marked this conversation as resolved.
Show resolved Hide resolved
description="PDOS degauss (Ry):",
disabled=True,
style={"description_width": "initial"},
)
self.pdos_degauss_eV = ipw.HTML()
self.pdos_degauss_eV.value = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not

self.pdos_degauss_eV = ipw.HTML(
              value = f"({self.pdos_degauss.value * RYDBERG_TO_EV:.4f} eV)",
)

f"({self.pdos_degauss.value * RYDBERG_TO_EV:.4f} eV)"
)

self.use_pdos_degauss.observe(self._disable_pdos_degauss, "value")
self.pdos_degauss.observe(self._update_pdos_degauss_ev, "value")
self.mesh_grid = ipw.HTML()
self.nscf_kpoints_distance.observe(self._display_mesh, "value")
self.nscf_kpoints_distance.observe(self._procotol_changed, "change")
self.children = [
self.settings_title,
ipw.HBox([self.nscf_kpoints_distance, self.mesh_grid]),
self.use_pdos_degauss,
ipw.HBox([self.pdos_degauss, self.pdos_degauss_eV]),
]
super().__init__(**kwargs)

def _disable_pdos_degauss(self, change):
self.pdos_degauss.disabled = not change["new"]

def _update_pdos_degauss_ev(self, change):
new_value = change["new"] * RYDBERG_TO_EV
if self.pdos_degauss_eV.value != f"({new_value} eV)":
self.pdos_degauss_eV.value = f"({new_value:.4f} eV)"

@tl.observe("protocol")
def _procotol_changed(self, change):
self.nscf_kpoints_distance.value = PdosWorkChain.get_protocol_inputs(
Expand All @@ -65,12 +97,18 @@ def get_panel_value(self):
"""Return a dictionary with the input parameters for the plugin."""
return {
"nscf_kpoints_distance": self.nscf_kpoints_distance.value,
"pdos_degauss": self.pdos_degauss.value,
"use_pdos_degauss": self.use_pdos_degauss.value,
}

def set_panel_value(self, input_dict):
"""Load a dictionary with the input parameters for the plugin."""
self.nscf_kpoints_distance.value = input_dict.get("nscf_kpoints_distance", 0.1)
self.pdos_degauss.value = input_dict.get("pdos_degauss", 0.01)
self.use_pdos_degauss.value = input_dict.get("use_pdos_degauss", False)

def reset(self):
"""Reset the panel to its default values."""
self.nscf_kpoints_distance.value = 0.1
self.pdos_degauss.value = 0.01
self.use_pdos_degauss.value = False
14 changes: 14 additions & 0 deletions src/aiidalab_qe/plugins/pdos/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,26 @@ def get_builder(codes, structure, parameters, **kwargs):
scf_overrides = deepcopy(parameters["advanced"])
nscf_overrides = deepcopy(parameters["advanced"])

# Dos Projwfc overrides
dos_overrides = {"parameters": {"DOS": {}}}
projwfc_overrides = {"parameters": {"PROJWFC": {}}}

if parameters["pdos"]["use_pdos_degauss"]:
dos_overrides["parameters"]["DOS"] = {
"degauss": parameters["pdos"]["pdos_degauss"]
}
projwfc_overrides["parameters"]["PROJWFC"] = {
"degauss": parameters["pdos"]["pdos_degauss"]
}

# Update the nscf kpoints distance from the setting panel
nscf_overrides["kpoints_distance"] = parameters["pdos"]["nscf_kpoints_distance"]

overrides = {
"scf": scf_overrides,
"nscf": nscf_overrides,
"dos": dos_overrides,
"projwfc": projwfc_overrides,
}
if dos_code is not None and projwfc_code is not None:
pdos = PdosWorkChain.get_builder_from_protocol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ codes:
parallelization: {}
pdos:
nscf_kpoints_distance: 0.1
pdos_degauss: 0.01
use_pdos_degauss: false
workchain:
electronic_type: metal
properties:
Expand Down
Loading