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 @@ Total Charge {{ tot_charge }} + + Van der Waals Correction + {{ vdw_corr }} + Initial Magnetic Moments {{ initial_magnetic_moments }} diff --git a/tests/conftest.py b/tests/conftest.py index 076ac04c8..a83ac32cf 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -336,6 +336,7 @@ def _submit_app_generator( smearing="methfessel-paxton", degauss=0.015, tot_charge=0.0, + vdw_corr="none", initial_magnetic_moments=0.0, ): configure_step = app.configure_step @@ -354,6 +355,7 @@ def _submit_app_generator( # Advanced settings configure_step.advanced_settings.override.value = True configure_step.advanced_settings.total_charge.value = tot_charge + configure_step.advanced_settings.van_der_waals.value = vdw_corr configure_step.advanced_settings.kpoints_distance.value = kpoints_distance configure_step.advanced_settings.magnetization._set_magnetization_values( initial_magnetic_moments diff --git a/tests/test_result/test_summary_report.yml b/tests/test_result/test_summary_report.yml index da8360942..734ec9e11 100644 --- a/tests/test_result/test_summary_report.yml +++ b/tests/test_result/test_summary_report.yml @@ -27,3 +27,4 @@ relaxed: positions_cell scf_kpoints_distance: 0.5 smearing: cold tot_charge: 0.0 +vdw_corr: none diff --git a/tests/test_submit_qe_workchain.py b/tests/test_submit_qe_workchain.py index 9f71ffb4d..5bde299c2 100644 --- a/tests/test_submit_qe_workchain.py +++ b/tests/test_submit_qe_workchain.py @@ -62,6 +62,7 @@ def test_create_builder_advanced_settings( electronic_type="metal", spin_type="collinear", tot_charge=1.0, + vdw_corr="dft-d3bj", initial_magnetic_moments=0.1, properties=["bands", "pdos"], ) @@ -80,6 +81,8 @@ def test_create_builder_advanced_settings( got["pdos"]["nscf"], ]: assert parameters["pw"]["parameters"]["SYSTEM"]["tot_charge"] == 1.0 + assert parameters["pw"]["parameters"]["SYSTEM"]["vdw_corr"] == "dft-d3" + assert parameters["pw"]["parameters"]["SYSTEM"]["dftd3_version"] == 4 # test initial_magnetic_moments set 'starting_magnetization' in pw.in assert ( diff --git a/tests/test_submit_qe_workchain/test_create_builder_default.yml b/tests/test_submit_qe_workchain/test_create_builder_default.yml index b2af426fc..868198e3b 100644 --- a/tests/test_submit_qe_workchain/test_create_builder_default.yml +++ b/tests/test_submit_qe_workchain/test_create_builder_default.yml @@ -26,6 +26,7 @@ bands: occupations: smearing smearing: cold tot_charge: 0.0 + vdw_corr: none pseudos: Si: Si.upf bands_kpoints_distance: 0.025 @@ -55,6 +56,7 @@ bands: occupations: smearing smearing: methfessel-paxton tot_charge: 0.0 + vdw_corr: none pseudos: Si: Si.upf clean_workdir: false @@ -87,6 +89,7 @@ pdos: nosym: true occupations: tetrahedra tot_charge: 0.0 + vdw_corr: none pseudos: Si: Si.upf projwfc: @@ -123,6 +126,7 @@ pdos: occupations: smearing smearing: methfessel-paxton tot_charge: 0.0 + vdw_corr: none pseudos: Si: Si.upf properties: @@ -158,6 +162,7 @@ relax: occupations: smearing smearing: methfessel-paxton tot_charge: 0.0 + vdw_corr: none pseudos: Si: Si.upf base_final_scf: