Skip to content

Commit

Permalink
Fix parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
ladinesa committed Aug 22, 2024
1 parent 8561a8f commit dd9780e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions workflowparsers/aflow/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def init_quantities(self):
def parse(self, key=None):
super().parse(key)

if self.get('poscar') is not None and self._results.get('geometry') is None:
if self._results.get('poscar') is not None and self._results.get('geometry') is None:
try:
atoms = vasp.read_vasp(StringIO(self._results['poscar'][-1]))
self._results['cell'] = atoms.get_cell()
Expand Down Expand Up @@ -515,9 +515,10 @@ def parse(self, filepath, archive, logger):
for n, specie in enumerate(species):
atom_labels += [specie] * self.aflow_data['composition'][n]
sec_system.atoms.labels = atom_labels
sec_system.atoms.positions = (
self.aflow_data.get('positions_cartesian', []) * ureg.angstrom
)
if self.aflow_data.get('positions_cartesian') is not None:
sec_system.atoms.positions = (
self.aflow_data.get('positions_cartesian') * ureg.angstrom
)

# parse system metadata from aflow_data
system_quantities = [
Expand Down
7 changes: 6 additions & 1 deletion workflowparsers/elastic/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def deformation_dirs(self):
for d in self._dirs
if d.startswith(self._deform_dir_prefix)
]
self._deform_dirs.sort()

return self._deform_dirs

Expand Down Expand Up @@ -336,7 +337,11 @@ def get_strain_energy(self):
# the peculiarity of the x_elastic_strain_diagram_values metainfo that it does
# not have the energy unit
energies.append((data[1] * ureg.hartree).to('J').magnitude)
if len(np.shape(energies)) != 2:
try:
energies = np.array(energies)
if len(np.shape(energies)) != 2:
strains, energies = [], []
except Exception:
strains, energies = [], []
return strains, energies

Expand Down

0 comments on commit dd9780e

Please sign in to comment.