Skip to content
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
13 changes: 6 additions & 7 deletions src/aiida_epw/workflows/protocols/base.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
13 changes: 6 additions & 7 deletions src/aiida_epw/workflows/protocols/base_sc.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
5 changes: 1 addition & 4 deletions src/aiida_epw/workflows/protocols/prep_sc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
15 changes: 3 additions & 12 deletions src/aiida_epw/workflows/protocols/supercon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
25 changes: 24 additions & 1 deletion src/aiida_epw/workflows/supercon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
83 changes: 83 additions & 0 deletions tests/workflows/test_supercon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 False
)

# 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
Loading