......@@ -279,6 +279,8 @@ class VasprunContext(object):
self.bands = None
self.kpoints = None
self.weights = None
self.tetrahedrons = None
self.tetrahedronVolume = None
self.ispin = None
self.ibrion = None
self.lastSystemDescription = None
......@@ -378,11 +380,14 @@ class VasprunContext(object):
else:
backend.addValue(meta["name"], converter(el.text))
if name == 'GGA':
# FIXME tmk: many options are not coded yet. See
# https://www.vasp.at/wiki/index.php/GGA
fMap = {
'91': ['GGA_X_PW91', 'GGA_C_PW91'],
'PE': ['GGA_X_PBE', 'GGA_C_PBE'],
'RP': ['GGA_X_RPBE', 'GGA_C_PBE'],
'PS': ['GGA_C_PBE_SOL', 'GGA_X_PBE_SOL']
'PS': ['GGA_C_PBE_SOL', 'GGA_X_PBE_SOL'],
'MK': ['GGA_X_OPTB86_VDW']
}
functs = fMap.get(el.text.strip(), None)
if not functs:
......@@ -451,11 +456,27 @@ class VasprunContext(object):
self.weights = np.asarray(getVector(el))
backend.addArrayValues(
"k_mesh_weights", self.weights.flatten())
elif name == "tetrahedronlist":
self.tetrahedrons = np.asarray(getVector(el), dtype=np.int)
backend.addArrayValues(
"x_vasp_tetrahedrons_list", self.tetrahedrons)
else:
backend.pwarn("Unknown array %s in kpoints" % name)
elif el.tag == "i":
name = el.attrib.get("name", None)
if name == "volumeweight":
ang2m = convert_unit_function("angstrom", "m")
# get volume and transform to meters^3
vol_cubic_angs = float(el.text.strip())
vol_cubic_meters = ang2m(ang2m(ang2m(vol_cubic_angs)))
backend.addArrayValues("x_vasp_tetrahedron_volume",
vol_cubic_meters)
else:
backend.pwarn("Unknown tag %s in kpoints" % el.tag)
def onEnd_structure(self, parser, event, element, pathStr):
backend = parser.backend
gIndexes = parser.tagSections[pathStr]
......@@ -493,12 +514,19 @@ class VasprunContext(object):
pos = getVector(el)
backend.addArrayValues(
"atom_positions", np.dot(np.asarray(pos), self.cell))
elif name == "selective":
atom_sel = getVector(el, transform=lambda item: item == 'T')
backend.addArrayValues(
"x_vasp_selective_dynamics", np.asarray(atom_sel, dtype=np.bool))
else:
backend.pwarn(
"Unexpected varray in structure %s" % el.attrib)
elif el.tag == "nose":
nose = getVector(el)
backend.addArrayValues("x_vasp_nose_thermostat", nose)
else:
backend.pwarn("Unexpected tag in structure %s %s %r" %
el.tag, el.attrib, el.text)
(el.tag, el.attrib, el.text))
if self.labels is not None:
backend.addArrayValues("atom_labels", self.labels)
......@@ -898,6 +926,7 @@ class VasprunContext(object):
'PE': ['GGA_X_PBE', 'GGA_C_PBE'],
'RP': ['GGA_X_RPBE', 'GGA_C_PBE'],
'PS': ['GGA_C_PBE_SOL', 'GGA_X_PBE_SOL'],
'MK': ['GGA_X_OPTB86_VDW'],
'--': ['GGA_X_PBE', 'GGA_C_PBE'] # should check potcar
}
functs = fMap.get(el.text.strip(), None)
......@@ -1187,6 +1216,8 @@ class XmlParser(object):
parserErrors=["exception: %s" % e]
)
except Exception as e:
import traceback
traceback.print_exc()
backend.finishedParsingSession(
parserStatus="ParseFailure",
parserErrors=["exception: %s" % e]
......