Skip to content

Commit a3957d5

Browse files
committed
New feature
I added an additional `EpwBaseWorkChain` subprocess in EpwPrepWorkChain that do a subsequent `epw.x` interpolation of electron and phonon bands after bloch to wannier transformation. The related part in protocol yaml file is also modified accordingly.
1 parent 8edbe89 commit a3957d5

File tree

2 files changed

+83
-6
lines changed

2 files changed

+83
-6
lines changed

src/aiida_epw/workflows/prep.py

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from aiida import orm
66
from aiida.common import AttributeDict
77

8-
from aiida.engine import WorkChain, ToContext
8+
from aiida.engine import WorkChain, ToContext, if_
99
from aiida_quantumespresso.workflows.ph.base import PhBaseWorkChain
1010
from aiida_quantumespresso.workflows.protocols.utils import ProtocolMixin
1111

@@ -101,7 +101,22 @@ def define(cls, spec):
101101
),
102102
namespace_options={"help": "Inputs for the `EpwBaseWorkChain`."},
103103
)
104-
104+
spec.expose_inputs(
105+
EpwBaseWorkChain,
106+
namespace="epw_bands",
107+
exclude=(
108+
"structure",
109+
"clean_workdir",
110+
"kpoints",
111+
"qpoints",
112+
"kfpoints",
113+
"qfpoints",
114+
"qfpoints_distance",
115+
"kfpoints_factor",
116+
"parent_folder_epw",
117+
),
118+
namespace_options={"help": "Inputs namespace for `EpwBaseWorkChain` that runs the `epw.x` calculation in interpolation mode, i.e. the interpolated electron and phonon band structures."},
119+
)
105120
spec.output("retrieved", valid_type=orm.FolderData)
106121
spec.output("epw_folder", valid_type=orm.RemoteStashFolderData)
107122

@@ -113,6 +128,10 @@ def define(cls, spec):
113128
cls.inspect_ph,
114129
cls.run_epw,
115130
cls.inspect_epw,
131+
if_(cls.should_run_epw_bands)(
132+
cls.run_epw_bands,
133+
cls.inspect_epw_bands,
134+
),
116135
cls.results,
117136
)
118137
spec.exit_code(
@@ -130,7 +149,11 @@ def define(cls, spec):
130149
"ERROR_SUB_PROCESS_FAILED_EPW",
131150
message="The `EpwWorkChain` sub process failed",
132151
)
133-
152+
spec.exit_code(
153+
406,
154+
"ERROR_SUB_PROCESS_FAILED_EPW_BANDS",
155+
message="The `EpwBaseWorkChain` sub process failed",
156+
)
134157
@classmethod
135158
def get_protocol_filepath(cls):
136159
"""Return ``pathlib.Path`` to the ``.yaml`` file that defines the protocols."""
@@ -212,9 +235,7 @@ def get_builder_from_protocol(
212235
builder.ph_base = ph_base
213236

214237
# TODO: Here I have a loop for the epw builders for future extension of another epw bands interpolation
215-
for namespace in [
216-
"epw_base",
217-
]:
238+
for namespace in ["epw_base", "epw_bands"]:
218239
epw_inputs = inputs.get(namespace, None)
219240
if namespace == "epw_base":
220241
if "target_base" not in epw_inputs["metadata"]["options"]["stash"]:
@@ -402,6 +423,48 @@ def inspect_epw(self):
402423
f"EpwBaseWorkChain<{workchain.pk}> failed with exit status {workchain.exit_status}"
403424
)
404425
return self.exit_codes.ERROR_SUB_PROCESS_FAILED_EPW
426+
427+
def should_run_epw_bands(self):
428+
"""Check if the `EpwBaseWorkChain` should be run in bands mode."""
429+
return "epw_bands" in self.inputs
430+
431+
def run_epw_bands(self):
432+
"""Run the `EpwBaseWorkChain` in bands mode."""
433+
inputs = AttributeDict(
434+
self.exposed_inputs(EpwBaseWorkChain, namespace="epw_bands")
435+
)
436+
if "bands_kpoints" in self.ctx.workchain_w90_bands.inputs:
437+
bands_kpoints = self.ctx.workchain_w90_bands.inputs.bands_kpoints
438+
else:
439+
bands_kpoints = (
440+
self.ctx.workchain_w90_bands.base.links.get_outgoing(
441+
link_label_filter="seekpath_structure_analysis"
442+
)
443+
.first()
444+
.node.outputs.explicit_kpoints
445+
)
446+
447+
inputs.kpoints = self.ctx.kpoints_nscf
448+
inputs.qpoints = self.ctx.qpoints
449+
inputs.qfpoints = bands_kpoints
450+
inputs.kfpoints = bands_kpoints
451+
inputs.parent_folder_epw = self.ctx.workchain_epw.outputs.remote_folder
452+
inputs.metadata.call_link_label = "epw_bands"
453+
workchain_node = self.submit(EpwBaseWorkChain, **inputs)
454+
self.report(
455+
f"launching EpwBaseWorkChain<{workchain_node.pk}> in bands interpolation mode"
456+
)
457+
458+
return {"workchain_epw_bands": workchain_node}
459+
460+
def inspect_epw_bands(self):
461+
"""Verify that the `EpwBaseWorkChain` finished successfully."""
462+
workchain = self.ctx.workchain_epw_bands
463+
if not workchain.is_finished_ok:
464+
self.report(
465+
f"EpwBaseWorkChain<{workchain.pk}> failed with exit status {workchain.exit_status}"
466+
)
467+
return self.exit_codes.ERROR_SUB_PROCESS_FAILED_EPW_BANDS
405468

406469
def results(self):
407470
"""Add the most important results to the outputs of the work chain."""

src/aiida_epw/workflows/protocols/prep.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ default_inputs:
5858
temps: 300
5959
vme: 'dipole'
6060
wannierize: False
61+
epw_bands:
62+
options:
63+
resources:
64+
num_machines: 1
65+
withmpi: True
66+
parameters:
67+
INPUTEPW:
68+
band_plot: True
69+
elph: True
70+
epbread: False
71+
epbwrite: False
72+
epwread: True
73+
epwwrite: False
74+
wannierize: False
6175
default_protocol: moderate
6276
protocols:
6377
moderate:

0 commit comments

Comments
 (0)