Skip to content

Commit ae7d248

Browse files
authored
PwBandsWorkChain: Respect bands_kpoints in overrides (#1021)
The `bands_kpoints` wasn't be respected if specified in the overrides and passed to the `PwBandsWorkChain.get_builder_from_protocol`.
1 parent 5a6529f commit ae7d248

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/aiida_quantumespresso/workflows/pw/bands.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ def get_builder_from_protocol(cls, code, structure, protocol=None, overrides=Non
163163
builder.bands = bands
164164
builder.clean_workdir = orm.Bool(inputs['clean_workdir'])
165165
builder.nbands_factor = orm.Float(inputs['nbands_factor'])
166-
builder.bands_kpoints_distance = orm.Float(inputs['bands_kpoints_distance'])
166+
if 'bands_kpoints' in inputs:
167+
builder.bands_kpoints = inputs['bands_kpoints']
168+
else:
169+
builder.bands_kpoints_distance = orm.Float(inputs['bands_kpoints_distance'])
167170

168171
return builder
169172

tests/workflows/protocols/pw/test_bands.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ def test_relax_type(fixture_code, generate_structure):
7474
assert 'CELL' not in builder.relax['base']['pw']['parameters'].get_dict()
7575

7676

77+
def test_bands_kpoints_overrides(fixture_code, generate_structure, generate_kpoints_mesh):
78+
"""Test specifying bands kpoints ``overrides`` for the ``get_builder_from_protocol()`` method."""
79+
code = fixture_code('quantumespresso.pw')
80+
structure = generate_structure('silicon')
81+
82+
bands_kpoints = generate_kpoints_mesh(3)
83+
overrides = {'bands_kpoints': bands_kpoints}
84+
builder = PwBandsWorkChain.get_builder_from_protocol(code, structure, overrides=overrides)
85+
assert builder.bands_kpoints == bands_kpoints # pylint: disable=no-member
86+
assert 'bands_kpoints_distance' not in builder
87+
88+
7789
def test_options(fixture_code, generate_structure):
7890
"""Test specifying ``options`` for the ``get_builder_from_protocol()`` method."""
7991
code = fixture_code('quantumespresso.pw')

0 commit comments

Comments
 (0)