Skip to content

Commit

Permalink
Fix maximum number of iterations reached
Browse files Browse the repository at this point in the history
In the current implementation of the `PwRelaxWorkChain`, an error is raised if the maximum number
of iterations is reached. This check is located in the `should_run_relax` method. In case this error is raised,
it is ignored as the method is called in a `while_` loop which expects a
boolean argument
(https://github.com/aiidateam/plumpy/blob/master/src/plumpy/workchains.py#L395-L399).
Therefore, the statement is moved to the `inspect_relax` method.
  • Loading branch information
t-reents committed Jun 7, 2024
1 parent 05eea67 commit fd6e792
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/aiida_quantumespresso/workflows/pw/relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ def should_run_relax(self):
self.report('Meta-convergence disabled: workchain completed after a single iteration.')
return False

# Stop if the maximum number of meta iterations has been reached
if self.ctx.iteration == self.inputs.max_meta_convergence_iterations.value:
self.report('Maximum number of meta convergence iterations reached.')
return self.exit_codes.ERROR_MAX_ITERATIONS_EXCEEDED

base_relax_workchain = self.ctx.base_relax_workchains[-1]

# If the last work chain still found Pulay stresses in the final SCF, continue
Expand Down Expand Up @@ -343,6 +338,12 @@ def inspect_relax(self):
# Set relaxed structure as input structure for next iteration
self.ctx.current_structure = structure
self.ctx.current_number_of_bands = workchain.outputs.output_parameters.get_dict()['number_of_bands']

# Stop if the maximum number of meta iterations has been reached
if self.ctx.meta_convergence and self.ctx.iteration == self.inputs.max_meta_convergence_iterations.value:
self.report('Maximum number of meta convergence iterations reached.')
return self.exit_codes.ERROR_MAX_ITERATIONS_EXCEEDED


def results(self):
"""Attach the output parameters and structure of the last workchain to the outputs."""
Expand Down

0 comments on commit fd6e792

Please sign in to comment.