Skip to content

Commit

Permalink
Simplify reporting messages.
Browse files Browse the repository at this point in the history
Co-authored-by: Lorenzo <[email protected]>
  • Loading branch information
t-reents and bastonero authored Feb 13, 2024
1 parent f7030f5 commit 214f499
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def get_pseudos(self) -> dict:

return results

def relabel_onsite_hubbard(self, workchain):
def relabel_hubbard_structure(self, workchain) -> None:
"""Relabel the Hubbard structure if new types have been detected."""
from aiida_quantumespresso.utils.hubbard import is_intersite_hubbard

Expand All @@ -436,13 +436,8 @@ def relabel_onsite_hubbard(self, workchain):
self.ctx.current_hubbard_structure = result['hubbard_structure']
if self.ctx.current_magnetic_moments is not None:
self.ctx.current_magnetic_moments = result['starting_magnetization']
relabeling_message = 'new types have been detected: relabeling the structure.'
break

if relabeling_message and self.inputs.meta_convergence:
relabeling_message = relabeling_message[:-1] + ' and starting new iteration.'
return relabeling_message

self.report('new types have been detected: relabeling the structure.')
return
def run_relax(self):
"""Run the PwRelaxWorkChain to run a relax PwCalculation."""
inputs = self.get_inputs(PwRelaxWorkChain, 'relax')
Expand Down Expand Up @@ -600,15 +595,12 @@ def inspect_hp(self):

if not self.should_check_convergence():
self.ctx.current_hubbard_structure = workchain.outputs.hubbard_structure
relabeling_message = self.relabel_onsite_hubbard(workchain)
self.relabel_onsite_hubbard(workchain)

if not self.inputs.meta_convergence:
self.report('meta convergence is switched off, so not checking convergence of Hubbard parameters.')
self.ctx.is_converged = True

if relabeling_message:
self.report(relabeling_message)

def check_convergence(self):
"""Check the convergence of the Hubbard parameters."""
workchain = self.ctx.workchains_hp[-1]
Expand All @@ -626,9 +618,7 @@ def check_convergence(self):

# We check if new types were created, in which case we relabel the `HubbardStructureData`
self.ctx.current_hubbard_structure = workchain.outputs.hubbard_structure
relabeling_message = self.relabel_onsite_hubbard(workchain)
if relabeling_message:
self.report(relabeling_message)
self.relabel_onsite_hubbard(workchain)

if not len(ref_params) == len(new_params):
self.report('The new and old Hubbard parameters have different lenghts. Assuming to be at the first cycle.')
Expand Down

0 comments on commit 214f499

Please sign in to comment.