From f64607c601f0f468902050e167b5617d415a37db Mon Sep 17 00:00:00 2001 From: AndresOrtegaGuerrero <34098967+AndresOrtegaGuerrero@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:25:41 +0100 Subject: [PATCH] Adding Van del Waals Correction widget (Adv Setting) (#620) --- src/aiidalab_qe/app/configuration/advanced.py | 50 +++++++++++++++++++ src/aiidalab_qe/app/parameters/qeapp.yaml | 1 + src/aiidalab_qe/app/result/summary_viewer.py | 13 +++++ .../app/static/workflow_summary.jinja | 4 ++ tests/conftest.py | 2 + tests/test_result/test_summary_report.yml | 1 + tests/test_submit_qe_workchain.py | 3 ++ .../test_create_builder_default.yml | 5 ++ 8 files changed, 79 insertions(+) diff --git a/src/aiidalab_qe/app/configuration/advanced.py b/src/aiidalab_qe/app/configuration/advanced.py index df75c76d9..99becc4fd 100644 --- a/src/aiidalab_qe/app/configuration/advanced.py +++ b/src/aiidalab_qe/app/configuration/advanced.py @@ -38,6 +38,12 @@ class AdvancedSettings(Panel): Tick the box to override the default, smaller is more accurate and costly. """ ) + dftd3_version = { + "dft-d3": 3, + "dft-d3bj": 4, + "dft-d3m": 5, + "dft-d3mbj": 6, + } # protocol interface protocol = tl.Unicode(allow_none=True) input_structure = tl.Instance(orm.StructureData, allow_none=True) @@ -121,6 +127,28 @@ def __init__(self, default_protocol=None, **kwargs): ) self.total_charge.observe(self._callback_value_set, "value") + # Van der Waals setting widget + self.van_der_waals = ipw.Dropdown( + options=[ + ("None", "none"), + ("Grimme-D3", "dft-d3"), + ("Grimme-D3BJ", "dft-d3bj"), + ("Grimme-D3M", "dft-d3m"), + ("Grimme-D3MBJ", "dft-d3mbj"), + ("Tkatchenko-Scheffler", "ts-vdw"), + ], + description="Van der Waals correction:", + value="none", + disabled=False, + style={"description_width": "initial"}, + ) + + ipw.dlink( + (self.override, "value"), + (self.van_der_waals, "disabled"), + lambda override: not override, + ) + self.magnetization = MagnetizationSettings() ipw.dlink( (self.override, "value"), @@ -146,6 +174,8 @@ def __init__(self, default_protocol=None, **kwargs): ), # total charge setting widget self.total_charge, + # van der waals setting widget + self.van_der_waals, # magnetization setting widget self.magnetization, # smearing setting widget @@ -245,6 +275,17 @@ def get_panel_value(self): ] = self.pseudo_setter.ecutrho # if override is not ticked, use the default value parameters["pw"]["parameters"]["SYSTEM"]["tot_charge"] = self.total_charge.value + + if self.van_der_waals.value in ["none", "ts-vdw"]: + parameters["pw"]["parameters"]["SYSTEM"][ + "vdw_corr" + ] = self.van_der_waals.value + else: + parameters["pw"]["parameters"]["SYSTEM"]["vdw_corr"] = "dft-d3" + parameters["pw"]["parameters"]["SYSTEM"][ + "dftd3_version" + ] = self.dftd3_version[self.van_der_waals.value] + # there are two choose, use link or parent if self.spin_type == "collinear": parameters[ @@ -290,6 +331,12 @@ def set_panel_value(self, parameters): self.total_charge.value = parameters["pw"]["parameters"]["SYSTEM"].get( "tot_charge", 0 ) + # van der waals correction + self.van_der_waals.value = self.dftd3_version.get( + system.get("dftd3_version"), + parameters["pw"]["parameters"]["SYSTEM"].get("vdw_corr", "none"), + ) + if parameters.get("initial_magnetic_moments"): self.magnetization._set_magnetization_values( parameters.get("initial_magnetic_moments") @@ -308,6 +355,9 @@ def reset(self): # reset total charge self.total_charge.value = DEFAULT_PARAMETERS["advanced"]["tot_charge"] + # reset the van der waals correction + self.van_der_waals.value = DEFAULT_PARAMETERS["advanced"]["vdw_corr"] + # reset the override checkbox self.override.value = False self.smearing.reset() diff --git a/src/aiidalab_qe/app/parameters/qeapp.yaml b/src/aiidalab_qe/app/parameters/qeapp.yaml index 024e1ec6c..616f4286c 100644 --- a/src/aiidalab_qe/app/parameters/qeapp.yaml +++ b/src/aiidalab_qe/app/parameters/qeapp.yaml @@ -21,6 +21,7 @@ advanced: functional: PBEsol accuracy: efficiency tot_charge: 0 + vdw_corr: none ## Codes codes: diff --git a/src/aiidalab_qe/app/result/summary_viewer.py b/src/aiidalab_qe/app/result/summary_viewer.py index 45880cbc8..1340eefcd 100644 --- a/src/aiidalab_qe/app/result/summary_viewer.py +++ b/src/aiidalab_qe/app/result/summary_viewer.py @@ -24,6 +24,15 @@ (True, False, False): "x", } +VDW_CORRECTION_VERSION = { + 3: "Grimme-D3", + 4: "Grimme-D3BJ", + 5: "Grimme-D3M", + 6: "Grimme-D3MBJ", + "ts-vdw": "Tkatchenko-Scheffler", + "none": "None", +} + def generate_report_parameters(qeapp_wc): """Generate the report parameters from the ui parameters and workchain's input. @@ -107,6 +116,10 @@ def generate_report_parameters(qeapp_wc): report["degauss"] = pw_parameters["SYSTEM"]["degauss"] report["smearing"] = pw_parameters["SYSTEM"]["smearing"] report["tot_charge"] = pw_parameters["SYSTEM"].get("tot_charge", 0.0) + report["vdw_corr"] = VDW_CORRECTION_VERSION.get( + pw_parameters["SYSTEM"].get("dftd3_version"), + pw_parameters["SYSTEM"].get("vdw_corr", "none"), + ) report["periodicity"] = PERIODICITY_MAPPING.get( qeapp_wc.inputs.structure.pbc, "xyz" ) diff --git a/src/aiidalab_qe/app/static/workflow_summary.jinja b/src/aiidalab_qe/app/static/workflow_summary.jinja index 5ff5d32d8..33630127d 100644 --- a/src/aiidalab_qe/app/static/workflow_summary.jinja +++ b/src/aiidalab_qe/app/static/workflow_summary.jinja @@ -100,6 +100,10 @@