From 69a9bf5b4dc47c2f557edbc0d0b17612d2ab57f3 Mon Sep 17 00:00:00 2001 From: ymzhang0 Date: Tue, 18 Aug 2026 13:17:30 +0200 Subject: [PATCH 1/3] fix(protocols): preserve direct Wannierization semantics --- src/aiida_epw/workflows/supercon.py | 25 ++++++++- tests/workflows/test_supercon.py | 83 +++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) diff --git a/src/aiida_epw/workflows/supercon.py b/src/aiida_epw/workflows/supercon.py index b8a3e720..6cd7edde 100644 --- a/src/aiida_epw/workflows/supercon.py +++ b/src/aiida_epw/workflows/supercon.py @@ -276,13 +276,36 @@ def get_builder_from_protocol( pass for epw_namespace in ("epw_interp", "epw_final_iso", "epw_final_aniso"): - epw_inputs = inputs.get(epw_namespace, None) + epw_inputs = inputs.get(epw_namespace, None) or {} + + # Hardcode momentum_dependence: True for final anisotropic run, False otherwise + momentum_dependence = True if epw_namespace == "epw_final_aniso" else False + + # Pop other flags directly from overrides / protocol dictionary + full_bandwidth = epw_inputs.pop("full_bandwidth", False) + real_axis = epw_inputs.pop("real_axis", False) + analytical_continuation = epw_inputs.pop("analytical_continuation", None) + epw_inputs.pop("calculation_type", None) + epw_inputs.pop("restart_type", None) + + # Check which input ports are supported by EpwBaseWorkChain dynamically for cross-branch compatibility + base_inputs = EpwBaseWorkChain.spec().inputs + kwargs = {} + if "momentum_dependence" in base_inputs: + kwargs["momentum_dependence"] = momentum_dependence + if "full_bandwidth" in base_inputs: + kwargs["full_bandwidth"] = full_bandwidth + if "real_axis" in base_inputs: + kwargs["real_axis"] = real_axis + if "analytical_continuation" in base_inputs: + kwargs["analytical_continuation"] = analytical_continuation epw_builder = EpwBaseWorkChain.get_builder_from_protocol( code=epw_code, structure=structure, protocol=protocol, overrides=epw_inputs, + **kwargs, ) if epw_namespace == "epw_interp" and scon_epw_code is not None: diff --git a/tests/workflows/test_supercon.py b/tests/workflows/test_supercon.py index b7d3cce6..f060409c 100644 --- a/tests/workflows/test_supercon.py +++ b/tests/workflows/test_supercon.py @@ -225,3 +225,86 @@ def test_epw_base_restart_types(fixture_code, generate_structure): # We should be able to set and access restart_type on the builder builder.restart_type = RestartType.EPHWRITE assert builder.restart_type == RestartType.EPHWRITE + + +def test_supercon_get_builder_from_protocol_default( + fixture_code, + generate_structure, + generate_remote_data, + fixture_localhost, + monkeypatch, +): + """Test get_builder_from_protocol default values.""" + from aiida_epw.workflows.supercon import SuperConWorkChain + from plumpy.ports import Port, PortNamespace + + monkeypatch.setattr(Port, "validate", lambda *a, **k: None) + monkeypatch.setattr(PortNamespace, "validate", lambda *a, **k: None) + + epw_code = fixture_code("epw.epw") + structure = generate_structure() + remote_stash = generate_remote_data(fixture_localhost, "/tmp/remote_stash") + + parent_epw = MagicMock() + parent_epw.process_label = "EpwBaseWorkChain" + parent_epw.inputs = MagicMock() + parent_epw.inputs.structure = structure + parent_epw.inputs.code = epw_code + parent_epw.inputs.kpoints = orm.KpointsData() + parent_epw.inputs.qpoints = orm.KpointsData() + parent_epw.outputs = MagicMock() + parent_epw.outputs.remote_stash = remote_stash + + builder = SuperConWorkChain.get_builder_from_protocol( + epw_code=epw_code, + parent_epw=parent_epw, + protocol="fast", + ) + + # Verify that the builders are configured according to the protocol + assert "code" in builder.epw_interp + assert "code" in builder.epw_final_iso + assert "code" in builder.epw_final_aniso + + # epw_interp check + if "restart_type" in builder.epw_interp: + from aiida_epw.common import RestartType + + assert builder.epw_interp.restart_type == RestartType.EPHWRITE + + # epw_final_iso check + if "momentum_dependence" in builder.epw_final_iso: + assert not builder.epw_final_iso.momentum_dependence.value + assert not builder.epw_final_iso.real_axis.value + if "calculation_type" in builder.epw_final_iso: + from aiida_epw.common.types import CalculationTypes + + assert ( + builder.epw_final_iso.calculation_type.get_member() + == CalculationTypes.ELIASHBERG + ) + if "restart_type" in builder.epw_final_iso: + from aiida_epw.common import RestartType + + assert builder.epw_final_iso.restart_type == RestartType.EPHREAD + assert ( + builder.epw_final_iso.parameters.get_dict()["INPUTEPW"].get("tc_linear", False) + is True + ) + + # epw_final_aniso check + if "momentum_dependence" in builder.epw_final_aniso: + assert builder.epw_final_aniso.momentum_dependence.value + assert not builder.epw_final_aniso.full_bandwidth.value + assert not builder.epw_final_aniso.real_axis.value + if "calculation_type" in builder.epw_final_aniso: + from aiida_epw.common.types import CalculationTypes + + assert ( + builder.epw_final_aniso.calculation_type.get_member() + == CalculationTypes.ELIASHBERG + ) + if "restart_type" in builder.epw_final_aniso: + from aiida_epw.common import RestartType + + assert builder.epw_final_aniso.restart_type == RestartType.EPHREAD From c2f9103447b284ab4fc03177f7567f9c20a4e6ee Mon Sep 17 00:00:00 2001 From: ymzhang0 Date: Wed, 19 Aug 2026 11:38:02 +0200 Subject: [PATCH 2/3] fix protocol --- src/aiida_epw/workflows/protocols/base.yaml | 13 ++++++------- src/aiida_epw/workflows/protocols/base_sc.yaml | 13 ++++++------- src/aiida_epw/workflows/protocols/prep_sc.yaml | 5 +---- src/aiida_epw/workflows/protocols/supercon.yaml | 15 +++------------ 4 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/aiida_epw/workflows/protocols/base.yaml b/src/aiida_epw/workflows/protocols/base.yaml index 789d0e53..63405482 100644 --- a/src/aiida_epw/workflows/protocols/base.yaml +++ b/src/aiida_epw/workflows/protocols/base.yaml @@ -1,16 +1,15 @@ default_inputs: clean_workdir: True max_iterations: 5 - qfpoints_distance: 0.1 - kfpoints_factor: 2 + qfpoints_distance: 0.08 + kfpoints_factor: 1 options: withmpi: True parameters: INPUTEPW: - degaussw: 0.04 + degaussw: 0.025 # eV + degaussq: 0.05 # meV eps_acoustic: 0.1 - muc: 0.13 - temps: 300 vme: 'dipole' use_ws: True @@ -20,9 +19,9 @@ protocols: description: 'Protocol to perform a electron-phonon calculation at normal precision at moderate computational cost.' precise: description: 'Protocol to perform a electron-phonon calculation at high precision at higher computational cost.' - qfpoints_distance: 0.06 + qfpoints_distance: 0.05 kfpoints_factor: 2 fast: description: 'Protocol to perform a electron-phonon calculation at low precision at minimal computational cost for testing purposes.' - qfpoints_distance: 0.2 + qfpoints_distance: 0.1 kfpoints_factor: 1 \ No newline at end of file diff --git a/src/aiida_epw/workflows/protocols/base_sc.yaml b/src/aiida_epw/workflows/protocols/base_sc.yaml index 27f7e700..cf990bc0 100644 --- a/src/aiida_epw/workflows/protocols/base_sc.yaml +++ b/src/aiida_epw/workflows/protocols/base_sc.yaml @@ -1,16 +1,15 @@ default_inputs: clean_workdir: True max_iterations: 5 - qfpoints_distance: 0.1 - kfpoints_factor: 2 + qfpoints_distance: 0.08 + kfpoints_factor: 1 options: withmpi: True parameters: INPUTEPW: - degaussw: 0.04 + degaussw: 0.025 # eV + degaussq: 0.05 # meV eps_acoustic: 0.1 - muc: 0.13 - temps: 300 vme: 'dipole' use_ws: True @@ -20,9 +19,9 @@ protocols: description: 'Protocol to perform a electron-phonon calculation at normal precision at moderate computational cost.' precise: description: 'Protocol to perform a electron-phonon calculation at high precision at higher computational cost.' - qfpoints_distance: 0.06 + qfpoints_distance: 0.05 kfpoints_factor: 2 fast: description: 'Protocol to perform a electron-phonon calculation at low precision at minimal computational cost for testing purposes.' - qfpoints_distance: 0.2 + qfpoints_distance: 0.1 kfpoints_factor: 1 diff --git a/src/aiida_epw/workflows/protocols/prep_sc.yaml b/src/aiida_epw/workflows/protocols/prep_sc.yaml index bfe7d7e4..0eb5c444 100644 --- a/src/aiida_epw/workflows/protocols/prep_sc.yaml +++ b/src/aiida_epw/workflows/protocols/prep_sc.yaml @@ -53,13 +53,10 @@ default_inputs: parameters: INPUTEPW: a2f: False - degaussq: 0.05 - degaussw: 0.2 elph: True fsthick: 100 phonselfen: False temps: 300 - vme: 'dipole' restart_type: wannierize epw_bands: options: @@ -79,4 +76,4 @@ protocols: qpoints_distance: 0.3 fast: description: 'Protocol to perform a electron-phonon calculation at low precision at minimal computational cost for testing purposes.' - qpoints_distance: 1.1 + qpoints_distance: 1 diff --git a/src/aiida_epw/workflows/protocols/supercon.yaml b/src/aiida_epw/workflows/protocols/supercon.yaml index 72ce5eec..f230a8a4 100644 --- a/src/aiida_epw/workflows/protocols/supercon.yaml +++ b/src/aiida_epw/workflows/protocols/supercon.yaml @@ -28,9 +28,6 @@ default_inputs: ep_coupling: True broyden_beta: 0.4 conv_thr_iaxis: 0.01 - degaussq: 0.5 - degaussw: 0.1 - eps_acoustic: 1 etf_mem: 1 fsthick: 0.8 mp_mesh_k: True @@ -56,10 +53,7 @@ default_inputs: elph: True ep_coupling: True conv_thr_iaxis: 0.01 - degaussq: 0.5 - degaussw: 0.1 elecselfen: False - eps_acoustic: 0.1 # cm^{-1} etf_mem: 1 fsthick: 0.8 mp_mesh_k: True @@ -68,8 +62,6 @@ default_inputs: nsiter: 500 nstemp: 40 selecqread: False - tc_linear: True - tc_linear_solver: 'power' temps: 1 40 vme: 'dipole' wscut: 0.5 @@ -87,10 +79,7 @@ default_inputs: elph: True ep_coupling: True conv_thr_iaxis: 0.01 - degaussq: 0.5 - degaussw: 0.1 elecselfen: False - eps_acoustic: 0.1 # cm^{-1} etf_mem: 1 fsthick: 0.8 # mp_mesh_k: True @@ -110,6 +99,8 @@ protocols: precise: description: 'Protocol to perform a electron-phonon calculation at high precision at higher computational cost.' interpolation_distance: 0.05 + convergence_threshold: 0.02 fast: description: 'Protocol to perform a electron-phonon calculation at low precision at minimal computational cost for testing purposes.' - interpolation_distance: 0.5 + interpolation_distance: 0.1 + convergence_threshold: 0.1 \ No newline at end of file From dc4d558e547861402652f170ff7c7f17507b31c0 Mon Sep 17 00:00:00 2001 From: ymzhang0 Date: Wed, 19 Aug 2026 11:43:32 +0200 Subject: [PATCH 3/3] test: update test_supercon_get_builder_from_protocol_default for removed tc_linear --- tests/workflows/test_supercon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/workflows/test_supercon.py b/tests/workflows/test_supercon.py index f060409c..c9b1f3df 100644 --- a/tests/workflows/test_supercon.py +++ b/tests/workflows/test_supercon.py @@ -289,7 +289,7 @@ def test_supercon_get_builder_from_protocol_default( assert builder.epw_final_iso.restart_type == RestartType.EPHREAD assert ( builder.epw_final_iso.parameters.get_dict()["INPUTEPW"].get("tc_linear", False) - is True + is False ) # epw_final_aniso check