Skip to content

Commit

Permalink
adding a widget to control DeltaE in PDOS plugin (#966)
Browse files Browse the repository at this point in the history
* adding a widget to control DeltaE in PDOS plugin
  • Loading branch information
AndresOrtegaGuerrero authored Dec 3, 2024
1 parent 329e198 commit 2463cb5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/aiidalab_qe/plugins/pdos/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class PdosConfigurationSettingsModel(ConfigurationSettingsModel, HasInputStructu
mesh_grid = tl.Unicode("")
use_pdos_degauss = tl.Bool(False)
pdos_degauss = tl.Float(0.005)
energy_grid_step = tl.Float(0.01)

def update(self, specific=""):
with self.hold_trait_notifications():
Expand All @@ -35,6 +36,7 @@ def get_model_state(self):
"nscf_kpoints_distance": self.kpoints_distance,
"use_pdos_degauss": self.use_pdos_degauss,
"pdos_degauss": self.pdos_degauss,
"energy_grid_step": self.energy_grid_step,
}

def set_model_state(self, parameters: dict):
Expand All @@ -44,12 +46,14 @@ def set_model_state(self, parameters: dict):
)
self.use_pdos_degauss = parameters.get("use_pdos_degauss", False)
self.pdos_degauss = parameters.get("pdos_degauss", 0.005)
self.energy_grid_step = parameters.get("energy_grid_step", 0.01)

def reset(self):
with self.hold_trait_notifications():
self.kpoints_distance = self._get_default("kpoints_distance")
self.use_pdos_degauss = self._get_default("use_pdos_degauss")
self.pdos_degauss = self._get_default("pdos_degauss")
self.energy_grid_step = self._get_default("energy_grid_step")

def _get_default(self, trait):
return self._defaults.get(trait, self.traits()[trait].default_value)
Expand Down
25 changes: 20 additions & 5 deletions src/aiidalab_qe/plugins/pdos/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,17 @@ def render(self):
lambda degauss: f"({degauss * RYDBERG_TO_EV:.4f} eV)",
)

self.energy_grid_step = ipw.BoundedFloatText(
min=0.001,
step=0.001,
description="Energy grid step (eV):",
style={"description_width": "initial"},
)
ipw.link(
(self._model, "energy_grid_step"),
(self.energy_grid_step, "value"),
)

self.children = [
ipw.HTML("""
<div style="padding-top: 0px; padding-bottom: 0px">
Expand All @@ -103,12 +114,15 @@ def render(self):
"""),
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.
By default, the <b>tetrahedron method</b> is used for partial density of states (PDOS) calculation.
However, if you need more control over the broadening, you can apply <b>Gaussian broadening</b>
by specifying a custom <b>degauss</b> value.
<br>
<b>Recommendation for Molecules and Localized Orbitals:</b>
<br>
For molecules and systems with localized orbitals, it is
recommended to use a custom degauss value.
For systems involving molecules or localized orbitals, it is recommended to use a
<b>custom degauss value</b>. This will provide a more accurate representation of the PDOS,
especially when the electronic states are localized.
</div>
"""),
ipw.HBox(
Expand All @@ -117,6 +131,7 @@ def render(self):
self.mesh_grid,
]
),
self.energy_grid_step,
self.use_pdos_degauss,
ipw.HBox(
children=[
Expand Down
16 changes: 14 additions & 2 deletions src/aiidalab_qe/plugins/pdos/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,20 @@ def get_builder(codes, structure, parameters, **kwargs):
nscf_overrides = deepcopy(parameters["advanced"])

# Dos Projwfc overrides
dos_overrides = {"parameters": {"DOS": {}}}
projwfc_overrides = {"parameters": {"PROJWFC": {}}}
dos_overrides = {
"parameters": {
"DOS": {
"DeltaE": parameters["pdos"]["energy_grid_step"],
}
}
}
projwfc_overrides = {
"parameters": {
"PROJWFC": {
"DeltaE": parameters["pdos"]["energy_grid_step"],
}
}
}

if parameters["pdos"]["use_pdos_degauss"]:
dos_overrides["parameters"]["DOS"] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ codes:
parallelization: {}
override: false
pdos:
energy_grid_step: 0.01
nscf_kpoints_distance: 0.1
pdos_degauss: 0.005
use_pdos_degauss: false
Expand Down

0 comments on commit 2463cb5

Please sign in to comment.