Skip to content

Commit

Permalink
PwParser: Fix case when settings are not provided
Browse files Browse the repository at this point in the history
The `is_ionically_converged` check in the `PwParser` considers the
`FIXED_COORDS` setting when making sure the structure is ionically converged,
but did not consider the case when the `settings` are not provided as an input.
This would cause the parsing to fail in this case.

Here we use the typical approach to set the `settings` variable to an empty
dictionary in case the `settings` input is not provided.

The tests are also updated to not set the `settings` input by default in the
`generate_inputs` fixture for the `pw.x` parser tests.

Co-authored-by: Aliaksandr Yakutovich <yakutovicha@gmail.com>
Co-authored-by: Marnik Bercx <mbercx@gmail.com>
  • Loading branch information
3 people authored Jul 20, 2023
1 parent 0859d0a commit 5d4a7d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/aiida_quantumespresso/parsers/pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ def is_ionically_converged(self, trajectory, except_final_scf=False):

if 'settings' in self.node.inputs:
settings = _uppercase_dict(self.node.inputs.settings.get_dict(), dict_name='settings')
else:
settings = {}

fixed_coords = settings.get('FIXED_COORDS', None)

Expand Down
9 changes: 6 additions & 3 deletions tests/parsers/test_pw.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ def _generate_inputs(calculation_type='scf', parameters=None, settings=None, met
kpoints.set_cell_from_structure(structure)
kpoints.set_kpoints_mesh_from_density(0.15)

return AttributeDict({
inputs = {
'structure': generate_structure(),
'kpoints': kpoints,
'parameters': orm.Dict(parameters),
'settings': orm.Dict(settings),
'metadata': metadata or {}
})
}
if settings:
inputs['settings'] = orm.Dict(settings)

return AttributeDict(inputs)

return _generate_inputs

Expand Down

0 comments on commit 5d4a7d9

Please sign in to comment.