diff --git a/src/aiidalab_qe/app/configuration/__init__.py b/src/aiidalab_qe/app/configuration/__init__.py index 06f2bd687..f0f09747b 100644 --- a/src/aiidalab_qe/app/configuration/__init__.py +++ b/src/aiidalab_qe/app/configuration/__init__.py @@ -10,7 +10,6 @@ from aiida import orm from aiidalab_widgets_base import WizardAppWidgetStep -from aiidalab_qe.app.parameters import DEFAULT_PARAMETERS from aiidalab_qe.app.utils import get_entry_items from .advanced import AdvancedSettings @@ -27,7 +26,6 @@ class ConfigureQeAppWorkChainStep(ipw.VBox, WizardAppWidgetStep): def __init__(self, **kwargs): self.workchain_settings = WorkChainSettings() - self.workchain_settings.relax_type.observe(self._update_state, "value") self.advanced_settings = AdvancedSettings() ipw.dlink( @@ -141,7 +139,7 @@ def _update_state(self, _=None): else: self.confirm_button.disabled = True self.state = self.State.INIT - self.set_configuration_parameters(DEFAULT_PARAMETERS) + self.reset() def confirm(self, _=None): self.configuration_parameters = self.get_configuration_parameters() @@ -153,8 +151,11 @@ def _default_state(self): return self.State.INIT def reset(self): + """Reset the widgets in all settings to their initial states.""" with self.hold_trait_notifications(): - self.set_configuration_parameters(DEFAULT_PARAMETERS) + self.input_structure = None + for _, settings in self.settings.items(): + settings.reset() def _update_panel(self, _=None): """Dynamic add/remove the panel based on the selected properties.""" diff --git a/src/aiidalab_qe/app/configuration/advanced.py b/src/aiidalab_qe/app/configuration/advanced.py index 50c07995d..4a8ec6879 100644 --- a/src/aiidalab_qe/app/configuration/advanced.py +++ b/src/aiidalab_qe/app/configuration/advanced.py @@ -47,7 +47,9 @@ class AdvancedSettings(Panel): value = tl.Dict() def __init__(self, default_protocol=None, **kwargs): - self._default_protocol = default_protocol or DEFAULT_PARAMETERS["protocol"] + self._default_protocol = ( + default_protocol or DEFAULT_PARAMETERS["workchain"]["protocol"] + ) # clean-up workchain settings self.clean_workdir = ipw.Checkbox( @@ -291,11 +293,19 @@ def reset(self): with self.hold_trait_notifications(): # Reset protocol dependent settings self._update_settings_from_protocol(self.protocol) + self.pseudo_family_selector.set_from_pseudo_family( + DEFAULT_PARAMETERS["advanced"]["pseudo_family"] + ) # reset total charge - self.total_charge.value = DEFAULT_PARAMETERS["tot_charge"] - + self.total_charge.value = DEFAULT_PARAMETERS["advanced"]["tot_charge"] # reset the override checkbox self.override.value = False + self.smearing.reset() + # reset the pseudo setter + self.pseudo_setter.structure = None + self.pseudo_setter._reset() + # reset the magnetization + self.magnetization.reset() def _display_mesh(self, _=None): if self.input_structure is None: @@ -357,9 +367,11 @@ def _disabled_changed(self, _): def reset(self): self.disabled = True - if hasattr(self.kinds, "children") and self.kinds.children: - for i in range(len(self.kinds.children)): - self.kinds.children[i].value = 0.0 + self.kinds = None + self.description.value = "Define magnetization: Input structure not confirmed" + with self.kinds_widget_out: + clear_output() + display(self.kinds) def create_kinds_widget(self): if self.input_structure_labels: @@ -434,7 +446,9 @@ class SmearingSettings(ipw.VBox): disabled = tl.Bool() def __init__(self, default_protocol=None, **kwargs): - self._default_protocol = default_protocol or DEFAULT_PARAMETERS["protocol"] + self._default_protocol = ( + default_protocol or DEFAULT_PARAMETERS["workchain"]["protocol"] + ) self.smearing = ipw.Dropdown( options=["cold", "gaussian", "fermi-dirac", "methfessel-paxton"], @@ -512,4 +526,4 @@ def reset(self): with self.hold_trait_notifications(): self._update_settings_from_protocol(self.protocol) - self.disabled = False + self.disabled = True diff --git a/src/aiidalab_qe/app/configuration/pseudos.py b/src/aiidalab_qe/app/configuration/pseudos.py index 12d3cf397..2d53c5cef 100644 --- a/src/aiidalab_qe/app/configuration/pseudos.py +++ b/src/aiidalab_qe/app/configuration/pseudos.py @@ -64,12 +64,12 @@ class PseudoFamilySelector(ipw.VBox): disabled = tl.Bool() value = tl.Unicode( - default_value=DEFAULT_PARAMETERS["pseudo_family"], + default_value=DEFAULT_PARAMETERS["advanced"]["pseudo_family"], ) def __init__(self, **kwargs): # Enable manual setting of the pseudopotential family - self._default_protocol = DEFAULT_PARAMETERS["protocol"] + self._default_protocol = DEFAULT_PARAMETERS["workchain"]["protocol"] self.set_pseudo_family_prompt = ipw.HTML(" Override ") self.override_protocol_pseudo_family = ipw.Checkbox( description="", @@ -89,15 +89,17 @@ def __init__(self, **kwargs): # Choose the DFT functional self.dft_functional = ipw.Dropdown( options=["PBE", "PBEsol"], - value=DEFAULT_PARAMETERS["pseudo_family"].split("/")[2], + value=DEFAULT_PARAMETERS["advanced"]["pseudo_family"].split("/")[2], style={"description_width": "initial"}, ) self.dft_functional.observe(self.set_value_trait, "value") # - pseudo_family_type = DEFAULT_PARAMETERS["pseudo_family"].split("/")[0] + pseudo_family_type = DEFAULT_PARAMETERS["advanced"]["pseudo_family"].split("/")[ + 0 + ] if pseudo_family_type.upper() == "SSSP": pseudo_family_type += ( - " " + DEFAULT_PARAMETERS["pseudo_family"].split("/")[-1] + " " + DEFAULT_PARAMETERS["advanced"]["pseudo_family"].split("/")[-1] ) elif pseudo_family_type.upper() == "PSEUDODOJO": pseudo_family_type = "PseudoDojo " + pseudo_family_type.split("_")[-2] @@ -195,6 +197,7 @@ def _update_settings_from_protocol(self, protocol): self.set_from_pseudo_family(pseudo_family) def set_from_pseudo_family(self, pseudo_family): + """Set the widget values from the given pseudo family.""" family, _, functional, accuracy = pseudo_family.split("/") protocol_selection = f"{family} {accuracy}" self.protocol_selection.value = protocol_selection @@ -212,7 +215,10 @@ class PseudoSetter(ipw.VBox): ecutwfc = tl.Float() ecutrho = tl.Float() - _pseudo_setter_helper_text = """