Skip to content

Commit

Permalink
Feature/degauss widget pdos tab (#833)
Browse files Browse the repository at this point in the history
* Degauss widget for Optional Gaussian Broadening for the PDOS plugin
  • Loading branch information
AndresOrtegaGuerrero authored Oct 2, 2024
1 parent 986c0d9 commit d91e8ac
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
43 changes: 43 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 @@ -22,6 +24,11 @@ def __init__(self, **kwargs):
"""<div style="padding-top: 0px; padding-bottom: 0px">
<h4>Settings</h4></div>"""
)
self.description = ipw.HTML(
"""<div style="line-height: 140%; padding-top: 0px; padding-bottom: 5px">
By default, the tetrahedron method is used for PDOS calculation. If required you can apply Gaussian broadening with a custom degauss value.
</div>"""
)
# nscf kpoints setting widget
self.nscf_kpoints_distance = ipw.BoundedFloatText(
min=0.001,
Expand All @@ -31,15 +38,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.00001,
step=0.001,
value=0.005,
description="PDOS degauss (Ry):",
disabled=True,
style={"description_width": "initial"},
)
self.pdos_degauss_eV = ipw.HTML(
value=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,
self.description,
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 +102,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.005)
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.005
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.005
use_pdos_degauss: false
workchain:
electronic_type: metal
properties:
Expand Down

0 comments on commit d91e8ac

Please sign in to comment.