Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-vasp
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-vasp
Commits
fcdf9691
Commit
fcdf9691
authored
9 years ago
by
Mohamed, Fawzi Roberto (fawzi)
Browse files
Options
Downloads
Patches
Plain Diff
python3: futurize stage2
parent
6db405cd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
parser/parser-vasp/parser_vasp.py
+1
-0
1 addition, 0 deletions
parser/parser-vasp/parser_vasp.py
parser/parser-vasp/parser_vasprun.py
+12
-8
12 additions, 8 deletions
parser/parser-vasp/parser_vasprun.py
with
13 additions
and
8 deletions
parser/parser-vasp/parser_vasp.py
+
1
−
0
View file @
fcdf9691
from
builtins
import
object
import
setup_paths
import
setup_paths
from
nomadcore.simple_parser
import
mainFunction
,
SimpleMatcher
as
SM
from
nomadcore.simple_parser
import
mainFunction
,
SimpleMatcher
as
SM
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
...
...
This diff is collapsed.
Click to expand it.
parser/parser-vasp/parser_vasprun.py
+
12
−
8
View file @
fcdf9691
from
__future__
import
division
from
builtins
import
map
from
builtins
import
range
from
builtins
import
object
import
xml.etree.ElementTree
import
xml.etree.ElementTree
import
logging
,
sys
import
logging
,
sys
import
setup_paths
import
setup_paths
...
@@ -60,7 +64,7 @@ class MyXMLParser(ET.XMLParser):
...
@@ -60,7 +64,7 @@ class MyXMLParser(ET.XMLParser):
def
getVector
(
el
,
transform
=
float
,
field
=
"
v
"
):
def
getVector
(
el
,
transform
=
float
,
field
=
"
v
"
):
"""
returns the vasp style vector contained in the element el (using field v).
"""
returns the vasp style vector contained in the element el (using field v).
single elements are converted using the function convert
"""
single elements are converted using the function convert
"""
return
map
(
lambda
x
:
map
(
transform
,
re
.
split
(
r
"
\s+
"
,
x
.
text
.
strip
())
),
el
.
findall
(
field
)
)
return
[[
transform
(
y
)
for
y
in
re
.
split
(
r
"
\s+
"
,
x
.
text
.
strip
())
]
for
x
in
el
.
findall
(
field
)
]
class
VasprunContext
(
object
):
class
VasprunContext
(
object
):
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -135,7 +139,7 @@ class VasprunContext(object):
...
@@ -135,7 +139,7 @@ class VasprunContext(object):
backend
.
pwarn
(
"
could not find converter for dtypeStr %s when handling meta info %s
"
%
(
dtypeStr
,
))
backend
.
pwarn
(
"
could not find converter for dtypeStr %s when handling meta info %s
"
%
(
dtypeStr
,
))
elif
shape
:
elif
shape
:
vals
=
re
.
split
(
"
\s+
"
,
el
.
text
.
strip
())
vals
=
re
.
split
(
"
\s+
"
,
el
.
text
.
strip
())
backend
.
addValue
(
meta
[
"
name
"
],
map
(
converter
,
vals
)
)
backend
.
addValue
(
meta
[
"
name
"
],
[
converter
(
x
)
for
x
in
vals
]
)
else
:
else
:
backend
.
addValue
(
meta
[
"
name
"
],
converter
(
el
.
text
))
backend
.
addValue
(
meta
[
"
name
"
],
converter
(
el
.
text
))
if
name
==
'
GGA
'
:
if
name
==
'
GGA
'
:
...
@@ -197,7 +201,7 @@ class VasprunContext(object):
...
@@ -197,7 +201,7 @@ class VasprunContext(object):
def
onEnd_structure
(
self
,
parser
,
event
,
element
):
def
onEnd_structure
(
self
,
parser
,
event
,
element
):
backend
=
parser
.
backend
backend
=
parser
.
backend
gIndexes
=
parser
.
tagSections
[
"
/
"
.
join
(
map
(
lambda
x
:
x
.
tag
,
parser
.
path
[:]
)
)
+
"
/
"
+
element
.
tag
]
gIndexes
=
parser
.
tagSections
[
"
/
"
.
join
(
[
x
.
tag
for
x
in
parser
.
path
[:]
]
)
+
"
/
"
+
element
.
tag
]
self
.
lastSystemDescription
=
gIndexes
[
"
section_system
"
]
self
.
lastSystemDescription
=
gIndexes
[
"
section_system
"
]
for
el
in
element
:
for
el
in
element
:
if
(
el
.
tag
==
"
crystal
"
):
if
(
el
.
tag
==
"
crystal
"
):
...
@@ -266,11 +270,11 @@ class VasprunContext(object):
...
@@ -266,11 +270,11 @@ class VasprunContext(object):
else
:
else
:
backend
.
pwarn
(
"
unexpected tag %s in array of the eigenvalues
"
%
arrEl
.
tag
)
backend
.
pwarn
(
"
unexpected tag %s in array of the eigenvalues
"
%
arrEl
.
tag
)
if
eigenvalues
is
not
None
:
if
eigenvalues
is
not
None
:
ev
=
map
(
eConv
,
eigenvalues
)
ev
=
[
eConv
(
x
)
for
x
in
eigenvalues
]
if
self
.
bands
:
if
self
.
bands
:
divisions
=
int
(
self
.
bands
[
'
divisions
'
])
divisions
=
int
(
self
.
bands
[
'
divisions
'
])
backend
.
openNonOverlappingSection
(
"
section_k_band
"
)
backend
.
openNonOverlappingSection
(
"
section_k_band
"
)
nsegments
=
self
.
kpoints
.
shape
[
0
]
/
divisions
nsegments
=
self
.
kpoints
.
shape
[
0
]
//
divisions
kpt
=
np
.
reshape
(
self
.
kpoints
,
(
nsegments
,
divisions
,
3
))
kpt
=
np
.
reshape
(
self
.
kpoints
,
(
nsegments
,
divisions
,
3
))
energies
=
np
.
reshape
(
ev
,
(
self
.
ispin
,
nsegments
,
divisions
,
bands
.
shape
[
0
]))
energies
=
np
.
reshape
(
ev
,
(
self
.
ispin
,
nsegments
,
divisions
,
bands
.
shape
[
0
]))
occ
=
np
.
reshape
(
occupation
,
(
self
.
ispin
,
nsegments
,
divisions
,
bands
.
shape
[
0
]))
occ
=
np
.
reshape
(
occupation
,
(
self
.
ispin
,
nsegments
,
divisions
,
bands
.
shape
[
0
]))
...
@@ -421,7 +425,7 @@ class VasprunContext(object):
...
@@ -421,7 +425,7 @@ class VasprunContext(object):
backend
.
pwarn
(
"
could not find converter for dtypeStr %s when handling meta info %s
"
%
(
dtypeStr
,
))
backend
.
pwarn
(
"
could not find converter for dtypeStr %s when handling meta info %s
"
%
(
dtypeStr
,
))
elif
shape
:
elif
shape
:
vals
=
re
.
split
(
"
\s+
"
,
el
.
text
.
strip
())
vals
=
re
.
split
(
"
\s+
"
,
el
.
text
.
strip
())
backend
.
addValue
(
meta
[
"
name
"
],
map
(
converter
,
vals
)
)
backend
.
addValue
(
meta
[
"
name
"
],
[
converter
(
x
)
for
x
in
vals
]
)
else
:
else
:
backend
.
addValue
(
meta
[
"
name
"
],
converter
(
el
.
text
))
backend
.
addValue
(
meta
[
"
name
"
],
converter
(
el
.
text
))
if
name
==
'
GGA
'
:
if
name
==
'
GGA
'
:
...
@@ -513,7 +517,7 @@ class XmlParser(object):
...
@@ -513,7 +517,7 @@ class XmlParser(object):
if
event
==
'
start
'
:
if
event
==
'
start
'
:
sectionsToOpen
=
self
.
sectionMap
.
get
(
el
.
tag
,
None
)
sectionsToOpen
=
self
.
sectionMap
.
get
(
el
.
tag
,
None
)
if
sectionsToOpen
:
if
sectionsToOpen
:
pathStr
=
"
/
"
.
join
(
map
(
lambda
x
:
x
.
tag
,
self
.
path
)
)
+
"
/
"
+
el
.
tag
pathStr
=
"
/
"
.
join
(
[
x
.
tag
for
x
in
self
.
path
]
)
+
"
/
"
+
el
.
tag
gIndexes
=
{}
gIndexes
=
{}
for
sect
in
sectionsToOpen
:
for
sect
in
sectionsToOpen
:
gIndexes
[
sect
]
=
backend
.
openSection
(
sect
)
gIndexes
[
sect
]
=
backend
.
openSection
(
sect
)
...
@@ -539,7 +543,7 @@ class XmlParser(object):
...
@@ -539,7 +543,7 @@ class XmlParser(object):
self
.
path
[
-
1
].
remove
(
el
)
self
.
path
[
-
1
].
remove
(
el
)
sectionsToClose
=
self
.
sectionMap
.
get
(
tag
,
None
)
sectionsToClose
=
self
.
sectionMap
.
get
(
tag
,
None
)
if
sectionsToClose
:
if
sectionsToClose
:
pathStr
=
"
/
"
.
join
(
map
(
lambda
x
:
x
.
tag
,
self
.
path
)
)
+
"
/
"
+
tag
pathStr
=
"
/
"
.
join
(
[
x
.
tag
for
x
in
self
.
path
]
)
+
"
/
"
+
tag
gIndexes
=
self
.
tagSections
[
pathStr
]
gIndexes
=
self
.
tagSections
[
pathStr
]
del
self
.
tagSections
[
pathStr
]
del
self
.
tagSections
[
pathStr
]
for
sect
in
reversed
(
sectionsToClose
):
for
sect
in
reversed
(
sectionsToClose
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment