Skip to content
Snippets Groups Projects
Commit d58ac9b6 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added exception handling.

parent 4719cca1
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ import wien2kparser.wien2k_parser_in1c as wien2k_parser_in1c ...@@ -14,7 +14,7 @@ import wien2kparser.wien2k_parser_in1c as wien2k_parser_in1c
import wien2kparser.wien2k_parser_in2c as wien2k_parser_in2c import wien2kparser.wien2k_parser_in2c as wien2k_parser_in2c
import wien2kparser.wien2k_parser_in1 as wien2k_parser_in1 import wien2kparser.wien2k_parser_in1 as wien2k_parser_in1
import wien2kparser.wien2k_parser_in2 as wien2k_parser_in2 import wien2kparser.wien2k_parser_in2 as wien2k_parser_in2
import logging as _logging import logging
from nomad.parsing.legacy import CoESimpleMatcherParser from nomad.parsing.legacy import CoESimpleMatcherParser
...@@ -190,15 +190,19 @@ class Wien2kContext(object): ...@@ -190,15 +190,19 @@ class Wien2kContext(object):
if os.path.exists(fName): if os.path.exists(fName):
# ASE does not support reading file object for WIEN2k structure files. # ASE does not support reading file object for WIEN2k structure files.
atoms = ase.io.read(fName, format="struct") try:
pos = atoms.get_positions() * 1E-10 atoms = ase.io.read(fName, format="struct")
symbols = atoms.get_chemical_symbols() except Exception:
cell = atoms.get_cell() * 1E-10 logging.error("Could not read/parse the WIEN2k structure file.")
pbc = atoms.get_pbc() else:
backend.addArrayValues('lattice_vectors', cell) pos = atoms.get_positions() * 1E-10
backend.addArrayValues("configuration_periodic_dimensions", pbc) symbols = atoms.get_chemical_symbols()
backend.addValue("atom_labels", symbols) cell = atoms.get_cell() * 1E-10
backend.addArrayValues('atom_positions', pos) pbc = atoms.get_pbc()
backend.addArrayValues('lattice_vectors', cell)
backend.addArrayValues("configuration_periodic_dimensions", pbc)
backend.addValue("atom_labels", symbols)
backend.addArrayValues('atom_positions', pos)
with open(fName, "r") as fin: with open(fName, "r") as fin:
structSuperContext = wien2k_parser_struct.Wien2kStructContext() structSuperContext = wien2k_parser_struct.Wien2kStructContext()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment