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

update nscf kpoints distance #446

Merged
merged 18 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/aiidalab_qe/app/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,28 @@ def __init__(self, **kwargs):
"workchain": self.workchain_settings,
"advanced": self.advanced_settings,
}

# list of trailets to link
# if new trailets are added to the settings, they need to be added here
trailets_list = ["input_structure", "protocol", "electronic_type", "spin_type"]

# then add plugin specific settings
entries = get_entry_items("aiidalab_qe.properties", "setting")
for identifier, entry_point in entries.items():
self.settings[identifier] = entry_point(parent=self)
self.settings[identifier].identifier = identifier
# link basic protocol to all plugin specific protocols
if hasattr(self.settings[identifier], "workchain_protocol"):
ipw.dlink(
(self.workchain_settings.workchain_protocol, "value"),
(self.settings[identifier].workchain_protocol, "value"),
)
if identifier in self.workchain_settings.properties:
self.workchain_settings.properties[identifier].run.observe(
self._update_panel, "value"
)
# link the trailets if they exist in the plugin specific settings
for trailet in trailets_list:
if hasattr(self.settings[identifier], trailet):
ipw.dlink(
(self.advanced_settings, trailet),
(self.settings[identifier], trailet),
)
Comment on lines +85 to +90
Copy link
Member

Choose a reason for hiding this comment

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

since the protocol is added here, please remove lines 79-84.


self._submission_blocker_messages = ipw.HTML()

Expand Down
2 changes: 2 additions & 0 deletions src/aiidalab_qe/plugins/pdos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aiidalab_qe.common.panel import OutlinePanel

from .result import Result
from .setting import Setting
from .workchain import workchain_and_builder


Expand All @@ -11,6 +12,7 @@ class PdosOutline(OutlinePanel):

pdos = {
"outline": PdosOutline,
"setting": Setting,
"result": Result,
"workchain": workchain_and_builder,
}
76 changes: 76 additions & 0 deletions src/aiidalab_qe/plugins/pdos/setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-
"""Panel for Pdos plugin."""
import ipywidgets as ipw
import traitlets as tl
from aiida import orm
from aiida_quantumespresso.calculations.functions.create_kpoints_from_distance import (
create_kpoints_from_distance,
)

from aiidalab_qe.common.panel import Panel

# nscf_kpoints_distance values from PdosWorkChain
NSCF_DISTANCE_MAP = {
"fast": 0.5,
"moderate": 0.1,
"precise": 0.05,
}


class Setting(Panel):
title = "Pdos Settings"
identifier = "pdos"
input_structure = tl.Instance(orm.StructureData, allow_none=True)
protocol = tl.Unicode(allow_none=True)

def __init__(self, **kwargs):
self.settings_title = ipw.HTML(
"""<div style="padding-top: 0px; padding-bottom: 0px">
<h4>Settings</h4></div>"""
)
# nscf kpoints setting widget
self.nscf_kpoints_distance = ipw.BoundedFloatText(
min=0.001,
step=0.01,
value=0.1,
description="NSCF K-points distance (1/Å):",
disabled=False,
style={"description_width": "initial"},
)
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]),
]
super().__init__(**kwargs)

@tl.observe("protocol")
def _procotol_changed(self, change):
self.nscf_kpoints_distance.value = NSCF_DISTANCE_MAP[change["new"]]
self._display_mesh()

@tl.observe("input_structure")
def _update_structure(self, _=None):
self._display_mesh()

def _display_mesh(self, _=None):
if self.input_structure is None:
return
mesh = create_kpoints_from_distance(
self.input_structure,
orm.Float(self.nscf_kpoints_distance.value),
orm.Bool(True),
)
self.mesh_grid.value = "Mesh " + str(mesh.get_kpoints_mesh()[0])

def get_panel_value(self):
"""Return a dictionary with the input parameters for the plugin."""
return {
"nscf_kpoints_distance": self.nscf_kpoints_distance.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)
9 changes: 5 additions & 4 deletions src/aiidalab_qe/plugins/pdos/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ def get_builder(codes, structure, parameters, **kwargs):
dos_code = codes.get("dos", None)
projwfc_code = codes.get("projwfc", None)
protocol = parameters["workchain"]["protocol"]
#

scf_overrides = deepcopy(parameters["advanced"])
nscf_overrides = deepcopy(parameters["advanced"])
nscf_overrides.pop("kpoints_distance", None)
nscf_overrides["pw"]["parameters"]["SYSTEM"].pop("smearing", None)
nscf_overrides["pw"]["parameters"]["SYSTEM"].pop("degauss", None)

# 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,
Expand Down