Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bands from protocol: fix bands_kpoints overrides #1021

Merged
merged 1 commit into from
Mar 27, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/aiida_quantumespresso/workflows/pw/bands.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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