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
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
Markus Scheidgen
parser-exciting
Commits
bfef8408
Commit
bfef8408
authored
Feb 23, 2016
by
Mohamed, Fawzi Roberto (fawzi)
Browse files
adding initial version of xml parser for dos
parent
619e602c
Changes
3
Hide whitespace changes
Inline
Side-by-side
parser/parser-exciting/exciting_parser_dos.py
0 → 100644
View file @
bfef8408
import
xml.sax
import
logging
class
DosHandler
(
xml
.
sax
.
handler
.
ContentHandler
):
def
__init__
(
self
,
backend
):
self
.
backend
=
backend
self
.
dosSectionGIndex
=
-
1
self
.
inDos
=
False
def
endDocument
(
self
):
pass
def
startElement
(
self
,
name
,
attrs
):
if
name
==
"dos"
:
self
.
dosSectionGIndex
=
self
.
backend
.
openSection
(
"exciting_section_dos"
)
self
.
inDos
=
True
elif
name
==
"point"
and
self
.
inDos
:
self
.
backend
.
addValue
(
"exciting_dos_value"
,
float
(
attrs
.
getValue
(
'dos'
)))
self
.
backend
.
addValue
(
"exciting_dos_energy"
,
float
(
attrs
.
getValue
(
'e'
)))
# attrDict={}
# for name in attrs.getNames():
# attrDict[name] = attrs.getValue(name)
# logging.error("start element %s attr %s", name, attrDict)
def
endElement
(
self
,
name
):
if
name
==
'dos'
:
self
.
inDos
=
False
self
.
backend
.
closeSection
(
"exciting_section_dos"
,
self
.
dosSectionGIndex
)
self
.
dosSectionGIndex
=
-
1
# logging.error("end element %s", name)
def
startElementNS
(
self
,
name
,
qname
,
attrs
):
attrDict
=
{}
for
name
in
attrs
.
getNames
():
attrDict
[
name
]
=
attrs
.
getValue
(
name
)
logging
.
error
(
"start element %s ns %s attr %s"
,
name
,
qname
,
attrDict
)
def
endElementNS
(
self
,
name
,
qname
):
logging
.
error
(
"end element %s ns %s"
,
name
,
qname
)
def
characters
(
self
,
content
):
pass
def
parseDos
(
inF
,
backend
):
print
(
"pippo"
)
handler
=
DosHandler
(
backend
)
logging
.
error
(
"will parse"
)
xml
.
sax
.
parse
(
inF
,
handler
)
logging
.
error
(
"did parse"
)
parser/parser-exciting/parser_exciting.py
View file @
bfef8408
...
...
@@ -3,7 +3,7 @@ import numpy as np
from
nomadcore.simple_parser
import
SimpleMatcher
as
SM
,
mainFunction
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.caching_backend
import
CachingLevel
import
os
,
sys
,
json
import
os
,
sys
,
json
,
exciting_parser_dos
class
ExcitingParserContext
(
object
):
...
...
@@ -14,18 +14,20 @@ class ExcitingParserContext(object):
latticeX
=
section
[
"exciting_geometry_lattice_vector_x"
]
latticeY
=
section
[
"exciting_geometry_lattice_vector_y"
]
latticeZ
=
section
[
"exciting_geometry_lattice_vector_z"
]
# print "section", section.simpleValues
# print "latticeX",latticeX
# print "latticeY",latticeY
# print "latticeZ",latticeZ
cell
=
[[
latticeX
[
0
],
latticeY
[
0
],
latticeZ
[
0
]],
[
latticeX
[
1
],
latticeY
[
1
],
latticeZ
[
1
]],
[
latticeX
[
2
],
latticeY
[
2
],
latticeZ
[
2
]]]
backend
.
addValue
(
"simulation_cell"
,
cell
)
# description of the input
def
onClose_section_single_configuration_calculation
(
self
,
backend
,
gIndex
,
section
):
dirPath
=
os
.
path
.
dirname
(
self
.
parser
.
fIn
.
name
)
dosFile
=
os
.
path
.
join
(
dirPath
,
"dos.xml"
)
if
os
.
path
.
exists
(
dosFile
):
with
open
(
dosFile
)
as
f
:
exciting_parser_dos
.
parseDos
(
f
,
backend
)
# description of the input
mainFileDescription
=
\
...
...
@@ -49,8 +51,8 @@ mainFileDescription = \
SM
(
startReStr
=
r
"\s*(?P<exciting_geometry_lattice_vector_x__bohr>[-+0-9.]+)\s+(?P<exciting_geometry_lattice_vector_y__bohr>[-+0-9.]+)\s+(?P<exciting_geometry_lattice_vector_z__bohr>[-+0-9.]+)"
,
repeats
=
True
)
]),
SM
(
r
"\s*Unit cell volume\s*:\s*(?P<exciting_unit_cell_volume__bohr>[-0-9.]+)"
),
SM
(
r
"\s*Brillouin zone volume\s*:\s*(?P<exciting_brillouin_zone_volume__bohr>[-0-9.]+)"
)
SM
(
r
"\s*Unit cell volume\s*:\s*(?P<exciting_unit_cell_volume__bohr
3
>[-0-9.]+)"
),
SM
(
r
"\s*Brillouin zone volume\s*:\s*(?P<exciting_brillouin_zone_volume__bohr
_3
>[-0-9.]+)"
)
]),
SM
(
name
=
"single configuration iteration"
,
startReStr
=
r
"\|\s*Self-consistent loop started\s*\+"
,
...
...
src/main/scala/eu/nomad_lab/parsers/ExcitingParser.scala
View file @
bfef8408
...
...
@@ -15,6 +15,7 @@ object ExcitingParser extends SimpleExternalParserGenerator(
"--uri"
,
"${mainFileUri}"
,
"${mainFilePath}"
),
resList
=
Seq
(
"parser-exciting/parser_exciting.py"
,
"parser-exciting/exciting_parser_dos.py"
,
"parser-exciting/setup_paths.py"
,
"nomad_meta_info/common.nomadmetainfo.json"
,
"nomad_meta_info/meta_types.nomadmetainfo.json"
,
...
...
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