Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-vasp
Compare Revisions
ac605067c6344be723af713736416096fde62f20...8d8f7e3a217a3b1737075013a3c15d920f2b46c2
Commits (2)
Added error handling in reading dos, eigenvalues
· 9c30e392
Alvin Noe Ladines
authored
Feb 16, 2021
9c30e392
Fix issue#500
· 8d8f7e3a
Alvin Noe Ladines
authored
Feb 18, 2021
8d8f7e3a
Hide whitespace changes
Inline
Side-by-side
vaspparser/vasp_parser.py
View file @
8d8f7e3a
...
...
@@ -445,8 +445,12 @@ class VASPXml(Parser):
if
not
eigenvalues
:
return
eigenvalues
=
np
.
array
([
e
.
text
.
split
()
for
e
in
eigenvalues
],
dtype
=
float
)
eigenvalues
=
np
.
reshape
(
eigenvalues
,
(
self
.
ispin
,
n_kpts
,
self
.
n_bands
,
2
))
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
dos
=
np
.
array
([
e
.
text
.
split
()
for
e
in
dos
],
dtype
=
float
)
dos
=
np
.
reshape
(
dos
,
(
self
.
ispin
,
self
.
n_dos
,
3
))
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'
)
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
)))
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
:
sec_scc
.
atom_forces
=
pint
.
Quantity
(
forces
,
'eV/angstrom'
)
try
:
sec_scc
.
atom_forces
=
pint
.
Quantity
(
forces
,
'eV/angstrom'
)
except
Exception
:
self
.
logger
.
error
(
'Error parsing forces.'
)
if
stress
is
not
None
:
# TODO verify if stress unit in xml is also kbar
sec_scc
.
stress_tensor
=
pint
.
Quantity
(
stress
,
'kbar'
)
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
)
...
...