Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OutcarCollectError and catch it in Vasp.collect #1394

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pyiron_atomistics/vasp/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
dict_group_to_hdf,
)
from pyiron_base import state, GenericParameters, deprecate
from pyiron_atomistics.vasp.parser.outcar import Outcar
from pyiron_atomistics.vasp.parser.outcar import Outcar, OutcarCollectError
from pyiron_atomistics.vasp.parser.oszicar import Oszicar
from pyiron_atomistics.vasp.procar import Procar
from pyiron_atomistics.vasp.structure import read_atoms, write_poscar, vasp_sorter
Expand Down Expand Up @@ -2003,8 +2003,12 @@ def collect(self, directory=os.getcwd(), sorted_indices=None):
if "OSZICAR" in files_present:
self.oszicar.from_file(filename=posixpath.join(directory, "OSZICAR"))
if "OUTCAR" in files_present:
self.outcar.from_file(filename=posixpath.join(directory, "OUTCAR"))
outcar_working = True
try:
self.outcar.from_file(filename=posixpath.join(directory, "OUTCAR"))
outcar_working = True
except OutcarCollectError as e:
state.logger.warning(f"OUTCAR present, but could not be parsed: {e}!")
outcar_working = False
if "vasprun.xml" in files_present:
try:
with warnings.catch_warnings(record=True) as w:
Expand Down
5 changes: 4 additions & 1 deletion pyiron_atomistics/vasp/parser/outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
scipy.constants.physical_constants["joule-electron volt relationship"][0] / 1e22
)

# derives from ValueError, because that was the exception previously raised
class OutcarCollectError(ValueError):
pass

class Outcar(object):
"""
Expand Down Expand Up @@ -934,7 +937,7 @@ def get_number_of_atoms(filename="OUTCAR", lines=None):
if len(trigger_indices) != 0:
return int(lines[trigger_indices[0]].split(ions_trigger)[-1])
else:
raise ValueError()
raise OutcarCollectError("Failed to read number of atoms, can't find NIONS!")

@staticmethod
def get_band_properties(filename="OUTCAR", lines=None):
Expand Down
Loading