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

fixed problem with atom_positions

parent 97315bd0
import xml.sax
import logging
class InputHandler(xml.sax.handler.ContentHandler):
def __init__(self, backend):
self.backend = backend
self.inputSectionGIndex = -1
self.inInput = False
def endDocument(self):
pass
def startElement(self, name, attrs):
if name == "structure":
self.inputSectionGIndex = self.backend.openSection("section_system")
self.inInput = True
elif name == "atom" and self.inInput:
g = attrs.getValue('coord')
print ("coord=", g)
# self.backend.addValue("atom_positions",float(attrs.getValue('coord')))
# 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 == 'structure':
self.inInput = False
self.backend.closeSection("section_system",self.inputSectionGIndex)
self.inputSectionGIndex = -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 parseInput(inF, backend):
handler = InputHandler(backend)
logging.error("will parse")
xml.sax.parse(inF, handler)
logging.error("did parse")
This diff is collapsed.
......@@ -5,7 +5,7 @@ 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
import os, sys, json, exciting_parser_dos,exciting_parser_bandstructure, exciting_parser_input
class ExcitingParserContext(object):
......@@ -56,6 +56,11 @@ class ExcitingParserContext(object):
bandFile = os.path.join(dirPath, "bandstructure.xml")
eigvalFile = os.path.join(dirPath, "EIGVAL.OUT")
fermiSurfFile = os.path.join(dirPath, "FERMISURF.bxsf")
inputFile = os.path.join(dirPath, "input.xml")
############# reading input file for atom positions##############
if os.path.exists(inputFile):
with open(inputFile) as f:
exciting_parser_input.parseInput(f, backend)
if os.path.exists(dosFile):
with open(dosFile) as f:
exciting_parser_dos.parseDos(f, backend)
......@@ -169,7 +174,14 @@ class ExcitingParserContext(object):
backend.addArrayValues("x_exciting_atom_forces",np.asarray(f_st))
def onClose_section_system(self, backend, gIndex, section):
# dirPath = os.path.dirname(self.parser.fIn.name)
backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
# inputFile = os.path.join(dirPath, "input.xml")
############# reading input file ##############
# if os.path.exists(inputFile):
# with open(inputFile) as f:
# exciting_parser_input.parseInput(f, backend)
mainFileDescription = \
SM(name = "root matcher",
......
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