Skip to content

Commit

Permalink
fix for "Excepted" error in phonons calculations (Issue 71)
Browse files Browse the repository at this point in the history
  • Loading branch information
akvatol committed Jul 29, 2024
1 parent bcda194 commit 86a8b85
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions aiida_crystal_dft/parsers/cry_pycrystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def parse(self, **kwargs):
except out.CRYSTOUT_Error as ex:
if 'Inadequate elastic calculation' in ex.msg:
return self.exit_codes.ERROR_REOPTIMIZATION_NEEDED

# TODO: refactor this later
# Check for error file contents
scf_failed = False
if 'fort.87' in folder.list_object_names():
Expand Down Expand Up @@ -157,11 +157,22 @@ def parse_out_wavefunction(self, f):
return None
return DataFactory('singlefile')(file=f)

def parse_out_trajectory(self, _):
def parse_out_trajectory(self, _):
try:
ase_structs = self.stdout_parser.get_trajectory()
if not ase_structs:
return None
structs = [DataFactory('structure')(ase=struct) for struct in ase_structs]
traj = DataFactory('array.trajectory')()
traj.set_structurelist(structs)
return traj
except ValueError as e:
# Fix for calculation with SCELPHO keyword;
# Scince supercell have more atoms than regular cell;
# traj.set_structurelist(structs) will throw an error https://github.com/aiidateam/aiida-core/blob/71422eb872040a9ba23047d2ec031f6deaa6a7cc/src/aiida/orm/nodes/data/array/trajectory.py#L202
# There are no reason for tracking trajectory in phonon calculation, so it will return None
if "Phonon" in self._node.label:
self._logger.warning(f"Caught ValueError for node with label '{self._node.label}': {e}")
return None
else:
raise e

0 comments on commit 86a8b85

Please sign in to comment.