Commits (2)
......@@ -445,8 +445,12 @@ class VASPXml(Parser):
if not eigenvalues:
return
try:
eigenvalues = np.array([e.text.split() for e in eigenvalues], dtype=float)
eigenvalues = np.reshape(eigenvalues, (self.ispin, n_kpts, self.n_bands, 2))
except Exception:
self.parser.logger.error('Error reading eigenvalues')
return
return eigenvalues
......@@ -456,9 +460,12 @@ class VASPXml(Parser):
dos = self._calculation_parsers[n_calc].root.findall('dos/total/array/set//r')
if not dos:
return dos_energies, dos_values, dos_integrated, e_fermi
try:
dos = np.array([e.text.split() for e in dos], dtype=float)
dos = np.reshape(dos, (self.ispin, self.n_dos, 3))
except Exception:
self.parser.logger.error('Error reading total dos.')
return dos_energies, dos_values, dos_integrated, e_fermi
dos = np.transpose(dos)
dos_energies = dos[0].T[0]
......@@ -482,8 +489,12 @@ class VASPXml(Parser):
# TODO use atomprojecteddos section
fields = self._calculation_parsers[n_calc].get('dos/partial/array/field')
try:
dos = np.array([e.text.split() for e in dos], dtype=float)
dos = np.reshape(dos, (n_atoms, self.ispin, self.n_dos, len(fields)))
except Exception:
self.parser.logger.error('Error reading partial dos.')
return None, None
fields = [field for field in fields if field != 'energy']
dos = np.transpose(dos)[1:]
......@@ -941,12 +952,17 @@ class VASPParser(FairdiParser):
occs = eigenvalues[1].T
# get valence(conduction) and maximum(minimum)
valence_max = [max([eigs[i, o[0], o[1]] for o in np.argwhere(
occs[i] >= 0.5)]) for i in range(len(eigs))]
conduction_min = [min([eigs[i, o[0], o[1]] for o in np.argwhere(
occs[i] < 0.5)]) for i in range(len(eigs))]
# we have a case where no band is occupied, i.e. valence_max should be below
# min(eigs)
valence_max, conduction_min = [], []
for i in range(len(eigs)):
occupied = [eigs[i, o[0], o[1]] for o in np.argwhere(occs[i] >= 0.5)]
valence_max.append(np.amin(eigs[i]) - 1.0 if not occupied else max(occupied))
unoccupied = [eigs[i, o[0], o[1]] for o in np.argwhere(occs[i] < 0.5)]
conduction_min.append(np.amin(eigs[i]) - 1.0 if not unoccupied else min(unoccupied))
sec_scc.energy_reference_highest_occupied = pint.Quantity(valence_max, 'eV')
sec_scc.energy_reference_lowest_unoccupied = pint.Quantity(conduction_min, 'eV')
if self.parser.kpoints_info.get('x_vasp_k_points_generation_method', None) == 'listgenerated':
# I removed normalization since it imho it should be done by normalizer
sec_k_band = sec_scc.m_create(KBand)
......@@ -1008,10 +1024,16 @@ class VASPParser(FairdiParser):
# forces and stress
forces, stress = self.parser.get_forces_stress(n)
if forces is not None:
try:
sec_scc.atom_forces = pint.Quantity(forces, 'eV/angstrom')
except Exception:
self.logger.error('Error parsing forces.')
if stress is not None:
try:
# TODO verify if stress unit in xml is also kbar
sec_scc.stress_tensor = pint.Quantity(stress, 'kbar')
except Exception:
self.logger.error('Error parsing stress.')
# structure
sec_system = parse_system(n)
......