Skip to content
Snippets Groups Projects
Commit f6687427 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Fixed some issues with formatting, the band tructure parser is currently...

Fixed some issues with formatting, the band tructure parser is currently disabled and the 'debug' mode is enabled in parser_exciting.py
parent 6b450222
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,9 @@ class BandHandler(xml.sax.handler.ContentHandler):
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')))
# 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)
......
......@@ -5,6 +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
from nomadcore.local_backend import LocalBackend
import os, sys, json, exciting_parser_dos,exciting_parser_bandstructure, exciting_parser_input
class ExcitingParserContext(object):
......@@ -18,19 +19,19 @@ class ExcitingParserContext(object):
latticeX = section["x_exciting_geometry_lattice_vector_x"]
latticeY = section["x_exciting_geometry_lattice_vector_y"]
latticeZ = section["x_exciting_geometry_lattice_vector_z"]
cell = [[latticeX[0],latticeY[0],latticeZ[0]],
cell = np.array([[latticeX[0],latticeY[0],latticeZ[0]],
[latticeX[1],latticeY[1],latticeZ[1]],
[latticeX[2],latticeY[2],latticeZ[2]]]
backend.addValue("simulation_cell", cell)
[latticeX[2],latticeY[2],latticeZ[2]]])
backend.addArrayValues("simulation_cell", cell)
def onClose_x_exciting_section_reciprocal_lattice_vectors(self, backend, gIndex, section):
recLatticeX = section["x_exciting_geometry_reciprocal_lattice_vector_x"]
recLatticeY = section["x_exciting_geometry_reciprocal_lattice_vector_y"]
recLatticeZ = section["x_exciting_geometry_reciprocal_lattice_vector_z"]
recCell = [[recLatticeX[0],recLatticeY[0],recLatticeZ[0]],
recCell = np.array([[recLatticeX[0],recLatticeY[0],recLatticeZ[0]],
[recLatticeX[1],recLatticeY[1],recLatticeZ[1]],
[recLatticeX[2],recLatticeY[2],recLatticeZ[2]]]
backend.addValue("x_exciting_simulation_reciprocal_cell", recCell)
[recLatticeX[2],recLatticeY[2],recLatticeZ[2]]])
backend.addArrayValues("x_exciting_simulation_reciprocal_cell", recCell)
def onClose_x_exciting_section_xc(self, backend, gIndex, section):
xcNr = section["x_exciting_xc_functional"][0]
......@@ -153,7 +154,7 @@ class ExcitingParserContext(object):
else:
values[-1].append(float(st[0]))
elif len(s) < 5 and len(st) == 1:
number_of_bands = st[0]
number_of_bands = st[0]
mesh_size = grid[0]*grid[1]*grid[2]
origin.append(all_vectors[0])
vectors.append(all_vectors[1:])
......@@ -179,7 +180,7 @@ class ExcitingParserContext(object):
atom_forces[1].append([])
for j in range (3,6):
atom_forces[1][-1].append(float(f_st[i][j]))
backend.addArrayValues("x_exciting_atom_forces",np.asarray(f_st))
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)
......@@ -195,9 +196,9 @@ class ExcitingParserContext(object):
backend.addArrayValues('atom_positions', np.asarray(self.atom_pos))
self.atom_pos = []
if self.atom_labels is not None:
backend.addArrayValues('atom_labels', np.asarray(self.atom_labels))
backend.addArrayValues('atom_labels', np.asarray(self.atom_labels, dtype=np.str))
self.atom_labels = []
def onClose_x_exciting_section_atoms_group(self, backend, gIndex, section):
pos = [section['x_exciting_geometry_atom_positions_' + i] for i in ['x', 'y', 'z']]
......@@ -360,7 +361,7 @@ mainFileDescription = \
# SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)"),
# SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)")
# SM(r"\s*(?P<x_exciting_store_total_forces>\s*\:+\s*[-\d\.]+\s*[-\d\.]+\s*[-\d\.]+\s*[A-Za-z]+\s*[A-Za-z]+)"),
# ]
# ]
# )
])
]
......@@ -393,4 +394,15 @@ cachingLevelForMetaName = {
if __name__ == "__main__":
# for name in metaInfoEnv.infoKinds:
# print 'nameo', name
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, cachingLevelForMetaName = cachingLevelForMetaName, superContext=ExcitingParserContext())
# Production
# mainFunction(mainFileDescription, metaInfoEnv, parserInfo, cachingLevelForMetaName = cachingLevelForMetaName, superContext=ExcitingParserContext())
# Debug
local_backend = LocalBackend(metaInfoEnv)
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, outF=local_backend.fileOut, cachingLevelForMetaName = cachingLevelForMetaName, superContext=ExcitingParserContext(), superBackend=local_backend)
results = local_backend.results
program_name = results["program_name"]
atom_labels = results["atom_labels"]
print(program_name)
print(atom_labels)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment