Commit d820a7fd authored by Pardini, Lorenzo (lopa)'s avatar Pardini, Lorenzo (lopa)
Browse files

dos + tests

parent 53870bbf
Pipeline #6710 passed with stage
in 5 minutes and 9 seconds
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("x_exciting_section_dos")
self.inDos = True
elif name == "point" and self.inDos:
self.backend.addValue("x_exciting_dos_value",float(attrs.getValue('dos')))
self.backend.addValue("x_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("x_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):
handler = DosHandler(backend)
logging.error("will parse")
xml.sax.parse(inF, handler)
logging.error("did parse")
This diff is collapsed.
......@@ -4,7 +4,8 @@ import numpy as np
from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json, elk_parser_dos
from nomadcore.unit_conversion import unit_conversion
import os, sys, json, logging
class ElkContext(object):
"""context for elk parser"""
......@@ -44,8 +45,23 @@ class ElkContext(object):
dirPath = os.path.dirname(self.parser.fIn.name)
dosFile = os.path.join(dirPath, "TDOS.OUT")
if os.path.exists(dosFile):
dosGIndex=backend.openSection("section_dos")
with open(dosFile) as f:
elk_parser_dos.parseDos(f, backend)
dosE=[]
dosV=[]
fromH = unit_conversion.convert_unit_function("hartree", "J")
while True:
line = f.readline()
if not line: break
nrs = list(map(float,line.split()))
if len(nrs) == 2:
dosV.append(nrs[1])
dosE.append(fromH(nrs[0]))
elif len(nrs) != 0:
raise Exception("Found more than two values in dos file %s" % dosFile)
backend.addArrayValues("dos_values", np.asarray(dosV))
backend.addArrayValues("dos_energies", np.asarray(dosE))
backend.closeSection("section_dos", dosGIndex)
def onClose_section_system(self, backend, gIndex, section):
backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
......
......@@ -4,11 +4,17 @@ import org.specs2.mutable.Specification
object ElkTests extends Specification {
"ElkParserTest" >> {
"test with json-events" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/ok/ok.scf", "json-events") must_== ParseResult.ParseSuccess
"test with json-events GaAs" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/GaAs/INFO.OUT", "json-events") must_== ParseResult.ParseSuccess
}
"test with json" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/ok/ok.scf", "json") must_== ParseResult.ParseSuccess
"test with json GaAs" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/GaAs/INFO.OUT", "json") must_== ParseResult.ParseSuccess
}
"test with json-events Al" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/Al/INFO.OUT", "json-events") must_== ParseResult.ParseSuccess
}
"test with json Al" >> {
ParserRun.parse(ElkParser, "parsers/elk/test/examples/Al/INFO.OUT", "json") must_== ParseResult.ParseSuccess
}
}
}
0.1198769544E-02
0.2799643479E-02
0.1175652643E-01
0.2392171444E-01
0.3584530053E-01
0.4335915746E-01
0.4394082265E-01
0.3804421405E-01
0.2847828394E-01
0.1859043836E-01
0.1066293543E-01
0.5410512229E-02
0.2441357323E-02
0.9817180543E-03
0.3518649715E-03
0.1126689946E-03
0.3257301847E-04
10 : nkpt
9 : nstsv
1 0.1250000000 0.1250000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122364679 2.000000000
2 -2.122259438 2.000000000
3 -2.122259438 2.000000000
4 -0.1286748619 2.000000000
5 0.5745589210 0.000000000
6 0.7051658566 0.000000000
7 0.7051658566 0.000000000
8 0.8151136384 0.000000000
9 0.8605767411 0.000000000
2 0.3750000000 0.1250000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122741574 2.000000000
2 -2.122411847 2.000000000
3 -2.122334851 2.000000000
4 -0.4678368645E-01 2.000000000
5 0.3448210862 0.000000000
6 0.5063335941 0.000000000
7 0.6997894076 0.000000000
8 0.7856802707 0.000000000
9 0.8006252452 0.000000000
3 0.6250000000 0.1250000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122993479 2.000000000
2 -2.122438302 2.000000000
3 -2.122380402 2.000000000
4 0.7353923216E-01 2.000000000
5 0.1525458423 2.000000000
6 0.5441924906 0.000000000
7 0.5896331272 0.000000000
8 0.6650293833 0.000000000
9 0.8356862943 0.000000000
4 0.8750000000 0.1250000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122581428 2.000000000
2 -2.122336125 2.000000000
3 -2.122330979 2.000000000
4 -0.8756585904E-01 2.000000000
5 0.4593570587 0.000000000
6 0.5896431645 0.000000000
7 0.6561578100 0.000000000
8 0.6997691538 0.000000000
9 0.7958323137 0.000000000
5 0.3750000000 0.3750000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122790135 2.000000000
2 -2.122463957 2.000000000
3 -2.122434744 2.000000000
4 -0.6380235792E-02 2.000000000
5 0.3817063939 0.000000000
6 0.4690786282 0.000000000
7 0.5148235813 0.000000000
8 0.5802200862 0.000000000
9 0.7261290494 0.000000000
6 0.6250000000 0.3750000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122869897 2.000000000
2 -2.122682147 2.000000000
3 -2.122510464 2.000000000
4 0.1507310056 2.000000000
5 0.2285441300 2.000000000
6 0.3154891470 0.2728059484E-20
7 0.3936611581 0.000000000
8 0.7117965260 0.000000000
9 0.8710552053 0.000000000
7 0.8750000000 0.3750000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122864752 2.000000000
2 -2.122537526 2.000000000
3 -2.122409389 2.000000000
4 0.3373996622E-01 2.000000000
5 0.2674457264 0.9997884984
6 0.4306935410 0.000000000
7 0.5070639965 0.000000000
8 0.7471363675 0.000000000
9 0.8351001601 0.000000000
8 0.6250000000 0.6250000000 0.1250000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122963098 2.000000000
2 -2.122576667 2.000000000
3 -2.122517646 2.000000000
4 0.1117263429 2.000000000
5 0.2759063707 0.4230028254E-03
6 0.3436488571 0.000000000
7 0.4781416554 0.000000000
8 0.5396484561 0.000000000
9 0.6904329374 0.000000000
9 0.3750000000 0.3750000000 0.3750000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122916936 2.000000000
2 -2.122351729 2.000000000
3 -2.122351729 2.000000000
4 -0.6328542043E-02 2.000000000
5 0.2305217279 2.000000000
6 0.6637824424 0.000000000
7 0.6637824424 0.000000000
8 0.7556756622 0.000000000
9 0.7556756622 0.000000000
10 0.6250000000 0.3750000000 0.3750000000 : k-point, vkl
(state, eigenvalue and occupancy below)
1 -2.122892972 2.000000000
2 -2.122646630 2.000000000
3 -2.122429945 2.000000000
4 0.1129446001 2.000000000
5 0.1900341612 2.000000000
6 0.3547527304 0.000000000
7 0.5520317928 0.000000000
8 0.6304422575 0.000000000
9 0.9658781777 0.000000000
Species : 1 (Al)
atom 1 is equivalent to atom(s)
1
Species : 1 (Al), atom : 1
n = 1, l = 0, k = 1 : -54.83607356
n = 2, l = 0, k = 1 : -3.511752279
93.79381046
93.79313701
93.79231979
93.79151253
93.79083328
93.79033045
93.78999830
93.78980281
93.78970213
93.78965849
93.78964396
93.78964136
93.78964213
93.78964311
93.78964363
93.78964384
93.78964390
93.78964393
93.78964393
0.367907732220E-01
0.368044960624E-01
0.368228800917E-01
0.368434558093E-01
0.368638235136E-01
0.368819830650E-01
0.368966956680E-01
0.369075704624E-01
0.369149057106E-01
0.369194078453E-01
0.369219071736E-01
0.369231504502E-01
0.369236975143E-01
0.369239069369E-01
0.369239752487E-01
0.369239937401E-01
0.369239977553E-01
0.369239984296E-01
0.369239985193E-01
scale
1.0
scale1
1.0
scale2
1.0
scale3
1.0
avec
3.826700000 3.826700000 0.000000000
3.826700000 0.000000000 3.826700000
0.000000000 3.826700000 3.826700000
atoms
1 : nspecies
'Al.in' : spfname
1 : natoms; atpos, bfcmt below
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
Distance between is = 1 (Al), ia = 1 and
is = 1 (Al), ia = 1 : 0.000000000
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment