Skip to content

Commit

Permalink
Validate base input and fix meta_convergence bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mbercx committed Jan 13, 2021
1 parent 50713cc commit 6c2d5ed
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion aiida_quantumespresso/workflows/pw/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
PwBaseWorkChain = WorkflowFactory('quantumespresso.pw.base')


def validate_inputs(inputs, _):
"""Validate the top level namespace."""
parameters = inputs['base']['pw']['parameters'].get_dict()

if 'relaxation_scheme' not in inputs and 'calculation' not in parameters.get('CONTROL', {}):
return 'The parameters in `base.pw.parameters` do not specify the required key `CONTROL.calculation`.'


def validate_final_scf(value, _):
"""Validate the final scf input."""
if isinstance(value, orm.Bool) and value:
Expand Down Expand Up @@ -65,6 +73,7 @@ def define(cls, spec):
help='The volume difference threshold between two consecutive meta convergence iterations.')
spec.input('clean_workdir', valid_type=orm.Bool, default=lambda: orm.Bool(False),
help='If `True`, work directories of all called calculation will be cleaned at the end of execution.')
spec.inputs.validator = validate_inputs
spec.outline(
cls.setup,
while_(cls.should_run_relax)(
Expand Down Expand Up @@ -174,7 +183,7 @@ def setup(self):
self.ctx.meta_convergence = self.inputs.meta_convergence.value
volume_cannot_change = (
self.ctx.relax_inputs.pw.parameters['CONTROL']['calculation'] in ('scf', 'relax') or
self.ctx.relax_inputs.pw.parameters['CELL']['cell_dofree'] == 'shape'
self.ctx.relax_inputs.pw.parameters.get('CELL', {}).get('cell_dofree', None) == 'shape'
)
if self.ctx.meta_convergence and volume_cannot_change:
self.report(
Expand Down

0 comments on commit 6c2d5ed

Please sign in to comment.