Skip to content

Commit

Permalink
PwBandsWorkChain: Respect bands_kpoints in overrides (#1021)
Browse files Browse the repository at this point in the history
The `bands_kpoints` wasn't be respected if specified in the overrides and
passed to the `PwBandsWorkChain.get_builder_from_protocol`.
  • Loading branch information
bastonero committed Mar 27, 2024
1 parent 5a6529f commit ae7d248
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/aiida_quantumespresso/workflows/pw/bands.py
Expand Up @@ -163,7 +163,10 @@ def get_builder_from_protocol(cls, code, structure, protocol=None, overrides=Non
builder.bands = bands
builder.clean_workdir = orm.Bool(inputs['clean_workdir'])
builder.nbands_factor = orm.Float(inputs['nbands_factor'])
builder.bands_kpoints_distance = orm.Float(inputs['bands_kpoints_distance'])
if 'bands_kpoints' in inputs:
builder.bands_kpoints = inputs['bands_kpoints']
else:
builder.bands_kpoints_distance = orm.Float(inputs['bands_kpoints_distance'])

return builder

Expand Down
12 changes: 12 additions & 0 deletions tests/workflows/protocols/pw/test_bands.py
Expand Up @@ -74,6 +74,18 @@ def test_relax_type(fixture_code, generate_structure):
assert 'CELL' not in builder.relax['base']['pw']['parameters'].get_dict()


def test_bands_kpoints_overrides(fixture_code, generate_structure, generate_kpoints_mesh):
"""Test specifying bands kpoints ``overrides`` for the ``get_builder_from_protocol()`` method."""
code = fixture_code('quantumespresso.pw')
structure = generate_structure('silicon')

bands_kpoints = generate_kpoints_mesh(3)
overrides = {'bands_kpoints': bands_kpoints}
builder = PwBandsWorkChain.get_builder_from_protocol(code, structure, overrides=overrides)
assert builder.bands_kpoints == bands_kpoints # pylint: disable=no-member
assert 'bands_kpoints_distance' not in builder


def test_options(fixture_code, generate_structure):
"""Test specifying ``options`` for the ``get_builder_from_protocol()`` method."""
code = fixture_code('quantumespresso.pw')
Expand Down

0 comments on commit ae7d248

Please sign in to comment.