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

added conversion for eigenvalues

parent 5bc13711
......@@ -4,6 +4,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
from nomadcore.unit_conversion import unit_conversion
import os, sys, json, exciting_parser_dos,exciting_parser_bandstructure
class ExcitingParserContext(object):
......@@ -53,12 +54,44 @@ class ExcitingParserContext(object):
dirPath = os.path.dirname(self.parser.fIn.name)
dosFile = os.path.join(dirPath, "dos.xml")
bandFile = os.path.join(dirPath, "bandstructure.xml")
eigvalFile = os.path.join(dirPath, "EIGVAL.OUT")
if os.path.exists(dosFile):
with open(dosFile) as f:
exciting_parser_dos.parseDos(f, backend)
if os.path.exists(bandFile):
with open(bandFile) as g:
exciting_parser_bandstructure.parseBand(g, backend)
if os.path.exists(eigvalFile):
eigvalGIndex = backend.openSection("section_eigenvalues")
with open(eigvalFile) as g:
eigvalKpoint=[]
eigvalVal=[[],[]]
eigvalOcc=[]
fromH = unit_conversion.convert_unit_function("hartree", "J")
while 1:
s = g.readline()
if not s: break
s = s.strip()
# print ("s= ", s)
# print ("len(s)= ", len(s))
if len(s) < 20:
continue
elif len(s) > 50:
eigvalVal[0].append([])
eigvalVal[1].append([])
eigvalKpoint.append(list(map(float, s.split()[1:4])))
# print ("eigvalKpoint= ", eigvalKpoint)
else:
try: int(s[0])
except ValueError:
continue
else:
n, e, occ = s.split()
eigvalVal[0][-1].append(int(n))
eigvalVal[1][-1].append(fromH(float(e)))
# print ("eigvalVal= ", eigvalVal)
backend.addArrayValues("eigenvalues_kpoints", np.asarray(eigvalKpoint))
backend.addArrayValues("eigenvalues_values", np.asarray(eigvalVal))
def onClose_section_system(self, backend, gIndex, section):
backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
......
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