Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Markus Scheidgen
parser-exciting
Commits
fe893445
Commit
fe893445
authored
Jan 17, 2017
by
Pardini, Lorenzo (lopa)
Browse files
fixed bandstructure and added spin treatment
parent
238f0b82
Changes
2
Hide whitespace changes
Inline
Side-by-side
parser/parser-exciting/exciting_parser_bandstructure.py
View file @
fe893445
import
xml.sax
import
logging
import
numpy
as
np
class
BandHandler
(
xml
.
sax
.
handler
.
ContentHandler
):
def
__init__
(
self
,
backend
):
def
__init__
(
self
,
backend
,
spinTreat
):
self
.
backend
=
backend
self
.
bandSectionGIndex
=
-
1
self
.
inBand
=
False
self
.
energy
=
[]
self
.
energySpin
=
[[],[]]
self
.
distance
=
[]
self
.
vertexCoord
=
[]
self
.
vertexLabels
=
[]
self
.
vertexDist
=
[]
self
.
spinTreat
=
spinTreat
def
endDocument
(
self
):
pass
self
.
inBand
=
False
self
.
backend
.
closeSection
(
"x_exciting_section_bandstructure"
,
self
.
bandSectionGIndex
)
self
.
bandSectionGIndex
=
-
1
def
startElement
(
self
,
name
,
attrs
):
if
name
==
"bandstructure"
:
self
.
bandSectionGIndex
=
self
.
backend
.
openSection
(
"x_exciting_section_bandstructure"
)
self
.
inBand
=
True
# elif name == "point" and self.inBand:
# self.backend.addValue("x_exciting_band_value",float(attrs.getValue('eval')))
# self.backend.addValue("x_exciting_band_k",float(attrs.getValue('distance')))
# attrDict={}
# for name in attrs.getNames():
# attrDict[name] = attrs.getValue(name)
# logging.error("start element %s attr %s", name, attrDict)
elif
name
==
"band"
:
self
.
energy
.
append
([])
self
.
distance
.
append
([])
elif
name
==
"point"
and
self
.
inBand
:
self
.
energy
[
-
1
].
append
(
float
(
attrs
.
getValue
(
'eval'
)))
self
.
distance
[
-
1
].
append
(
float
(
attrs
.
getValue
(
'distance'
)))
elif
name
==
"vertex"
and
self
.
inBand
:
self
.
vertexCoord
.
append
(
attrs
.
getValue
(
"coord"
))
self
.
vertexLabels
.
append
(
attrs
.
getValue
(
"label"
))
self
.
vertexDist
.
append
(
attrs
.
getValue
(
"distance"
))
def
endElement
(
self
,
name
):
if
name
==
'bandstructure'
:
self
.
inBand
=
False
self
.
backend
.
closeSection
(
"x_exciting_section_bandstructure"
,
self
.
bandSectionGIndex
)
self
.
bandSectionGIndex
=
-
1
# logging.error("end element %s", name)
vertexDummy
=
[]
vertexNum
=
len
(
self
.
vertexLabels
)
kmesh
=
len
(
self
.
energy
[
-
1
])
bands
=
len
(
self
.
energy
)
bands2
=
int
(
bands
/
2
)
for
i
in
range
(
0
,
vertexNum
):
self
.
vertexCoord
[
i
]
=
self
.
vertexCoord
[
i
].
split
()
for
j
in
range
(
0
,
3
):
self
.
vertexCoord
[
i
][
j
]
=
float
(
self
.
vertexCoord
[
i
][
j
])
self
.
backend
.
addValue
(
"x_exciting_band_number_of_kpoints"
,
kmesh
)
self
.
backend
.
addValue
(
"x_exciting_band_number_of_vertices"
,
vertexNum
)
self
.
backend
.
addValue
(
"x_exciting_band_vertex_labels"
,
self
.
vertexLabels
)
self
.
backend
.
addValue
(
"x_exciting_band_vertex_coordinates"
,
self
.
vertexCoord
)
self
.
backend
.
addValue
(
"x_exciting_band_k_points"
,
self
.
distance
[
-
1
])
if
not
self
.
spinTreat
:
self
.
backend
.
addValue
(
"x_exciting_band_number_of_eigenvalues"
,
bands
)
self
.
backend
.
addArrayValues
(
"x_exciting_band_energies"
,
np
.
asarray
([
self
.
energy
]))
else
:
self
.
energySpin
[
0
]
=
self
.
energy
[
0
:
bands2
]
self
.
energySpin
[
1
]
=
self
.
energy
[
bands2
:
bands
]
self
.
backend
.
addValue
(
"x_exciting_band_number_of_eigenvalues"
,
bands2
)
self
.
backend
.
addArrayValues
(
"x_exciting_band_energies"
,
np
.
asarray
(
self
.
energy
))
def
startElementNS
(
self
,
name
,
qname
,
attrs
):
attrDict
=
{}
...
...
@@ -41,8 +72,8 @@ class BandHandler(xml.sax.handler.ContentHandler):
def
characters
(
self
,
content
):
pass
def
parseBand
(
inF
,
backend
):
handler
=
BandHandler
(
backend
)
def
parseBand
(
inF
,
backend
,
spinTreat
):
handler
=
BandHandler
(
backend
,
spinTreat
)
logging
.
error
(
"will parse"
)
xml
.
sax
.
parse
(
inF
,
handler
)
logging
.
error
(
"did parse"
)
parser/parser-exciting/parser_exciting.py
View file @
fe893445
...
...
@@ -7,9 +7,27 @@ from nomadcore.caching_backend import CachingLevel
from
nomadcore.unit_conversion
import
unit_conversion
import
os
,
sys
,
json
,
exciting_parser_dos
,
exciting_parser_bandstructure
#, exciting_parser_input
#def elasticCheck(path):
# print("path=", path)
# pat = path.split("/")
# if pat[-1] == "INFO.OUT":
# print("NO", pat)
# else:
# print("YES", pat)
#
#elasticCheck(self.path)
# continue
class
ExcitingParserContext
(
object
):
def
startedParsing
(
self
,
path
,
parser
):
# print("path=", path)
# pat = path.split("/")
# print("pat=", pat)
# if pat[-1] == "INFO.OUT":
# pass
# else:
# pass
self
.
parser
=
parser
self
.
atom_pos
=
[]
self
.
atom_labels
=
[]
...
...
@@ -80,7 +98,7 @@ class ExcitingParserContext(object):
exciting_parser_dos
.
parseDos
(
f
,
backend
)
if
os
.
path
.
exists
(
bandFile
):
with
open
(
bandFile
)
as
g
:
exciting_parser_bandstructure
.
parseBand
(
g
,
backend
)
exciting_parser_bandstructure
.
parseBand
(
g
,
backend
,
self
.
spinTreat
)
if
os
.
path
.
exists
(
gwFile
):
backend
.
addValue
(
'electronic_structure_method'
,
"G0W0"
)
else
:
...
...
@@ -285,8 +303,10 @@ mainFileDescription = \
SM
(
r
"\s*Total number of local-orbitals\s*:\s*(?P<x_exciting_lo>[-0-9.]+)"
),
SM
(
startReStr
=
r
"\s*Exchange-correlation type\s*:\s*(?P<x_exciting_xc_functional>[-0-9.]+)"
,
sections
=
[
'x_exciting_section_xc'
]),
SM
(
r
"\s*Smearing scheme\s*:\s*(?P<x_exciting_smearing_type>[-a-zA-Z0-9]+)"
),
SM
(
r
"\s*Smearing width\s*:\s*(?P<x_exciting_smearing_width__hartree>[-0-9.]+)"
),
# SM(r"\s*Smearing scheme\s*:\s*(?P<x_exciting_smearing_type>[-a-zA-Z0-9]+)"),
# SM(r"\s*Smearing width\s*:\s*(?P<x_exciting_smearing_width__hartree>[-0-9.]+)"),
SM
(
r
"\s*Smearing scheme\s*:\s*(?P<smearing_kind>[-a-zA-Z0-9]+)"
),
SM
(
r
"\s*Smearing width\s*:\s*(?P<smearing_width__hartree>[-0-9.]+)"
),
SM
(
r
"\s*Using\s*(?P<x_exciting_potential_mixing>[-a-zA-Z\s*]+)\s*potential mixing"
)
]),
SM
(
name
=
"single configuration iteration"
,
...
...
@@ -400,6 +420,5 @@ cachingLevelForMetaName = {
"x_exciting_geometry_reciprocal_lattice_vector_z"
:
CachingLevel
.
Cache
,
"x_exciting_section_reciprocal_lattice_vectors"
:
CachingLevel
.
Ignore
}
if
__name__
==
"__main__"
:
mainFunction
(
mainFileDescription
,
metaInfoEnv
,
parserInfo
,
cachingLevelForMetaName
=
cachingLevelForMetaName
,
superContext
=
ExcitingParserContext
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment