Skip to content

Commit

Permalink
Merge branch 'fix/relabel/degenerate-spins' of https://github.com/aii…
Browse files Browse the repository at this point in the history
  • Loading branch information
bastonero committed Apr 19, 2024
2 parents 392a772 + 2c51276 commit 6ced0df
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def structure_relabel_kinds(
new_magnetization[kind_name] = old_magnetization[site['kind']]

site = sites[index]
relabeled.append_atom(position=site.position, symbols=symbol, name=kind_name)
try:
relabeled.append_atom(position=site.position, symbols=symbol, name=kind_name)
except ValueError as exc:
raise ValueError('cannot distinguish kinds with the given Hubbard input configuration') from exc

# Now add the non-Hubbard sites
for site in sites[len(relabeled.sites):]:
Expand Down
13 changes: 10 additions & 3 deletions src/aiida_quantumespresso_hp/workflows/hubbard.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ def define(cls, spec):

spec.exit_code(330, 'ERROR_FAILED_TO_DETERMINE_PSEUDO_POTENTIAL',
message='Failed to determine the correct pseudo potential after the structure changed its kind names.')
spec.exit_code(340, 'ERROR_RELABELLING_KINDS',
message='Failed to determine the kind names during the relabelling.')

spec.exit_code(401, 'ERROR_SUB_PROCESS_FAILED_RECON',
message='The reconnaissance PwBaseWorkChain sub process failed')
spec.exit_code(402, 'ERROR_SUB_PROCESS_FAILED_RELAX',
Expand Down Expand Up @@ -431,9 +434,13 @@ def relabel_hubbard_structure(self, workchain) -> None:
if not is_intersite_hubbard(workchain.outputs.hubbard_structure.hubbard):
for site in workchain.outputs.hubbard.dict.sites:
if not site['type'] == site['new_type']:
result = structure_relabel_kinds(
self.ctx.current_hubbard_structure, workchain.outputs.hubbard, self.ctx.current_magnetic_moments
)
try:
result = structure_relabel_kinds(
self.ctx.current_hubbard_structure, workchain.outputs.hubbard,
self.ctx.current_magnetic_moments
)
except ValueError:
return self.exit_codes.ERROR_RELABELLING_KINDS
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']
Expand Down

0 comments on commit 6ced0df

Please sign in to comment.