Skip to content
Snippets Groups Projects
Commit 7919a4c8 authored by Pardini, Lorenzo (lopa)'s avatar Pardini, Lorenzo (lopa)
Browse files

code clean up

parent 7adbf67a
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 337 deletions
......@@ -35,7 +35,6 @@ class BandHandler(xml.sax.handler.ContentHandler):
def endDocument(self):
self.inBand = False
self.backend.closeSection("section_k_band",self.bandSectionGIndex)
# self.backend.closeSection("section_k_band_segment",self.normBandSectionGIndex)
self.bandSectionGIndex = -1
self.normBandSectionGIndex = -1
......@@ -43,7 +42,6 @@ class BandHandler(xml.sax.handler.ContentHandler):
if name == "bandstructure":
self.bandSectionGIndex = self.backend.openSection("section_k_band")
self.backend.addValue("band_structure_kind","electronic")
# self.normBandSectionGIndex = self.backend.openSection("section_k_band_segment")
self.inBand = True
elif name == "band":
self.energy.append([])
......
......
......@@ -22,7 +22,7 @@ from nomadcore.unit_conversion import unit_conversion
import os, sys, json, logging
################################################################
# This is the subparser for the exciting XS output
# This is the subparser for the epsilon tensor in the XS output
################################################################
def is_number(s):
......@@ -33,16 +33,12 @@ def is_number(s):
return False
class EPSParser(object):
"""context for wien2k In2 parser"""
def __init__(self):
pass
def startedParsing(self, path, parser):
"""called when parsing starts"""
self.parser = parser
# allows to reset values if the same superContext is used to parse different files
# self.initialize_values()
def parseEpsilon(self, epsFile, backend, epsEn, epsilon):
with open(epsFile) as g:
......
......
......@@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
######################################################
# this is the subparser for the groundstate input file
######################################################
import xml.sax
import logging
import numpy as np
......@@ -24,7 +28,7 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.backend = backend
def startElement(self, name, attrs):
if name == "libxc": #libXC
if name == "libxc":
correlation = attrs.getValue("correlation")[3:]
exchange = attrs.getValue("exchange")[3:]
xcName = [correlation, exchange]
......
......
......@@ -19,15 +19,13 @@ from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion import unit_conversion
import os, sys, json, logging, exciting_parser_input
import os, sys, json, logging, exciting_parser_gw_input
################################################################
# This is the subparser for the exciting GW output
################################################################
class GWParser(object):
"""context for wien2k In2 parser"""
def __init__(self):
self.spinTreat = None
......@@ -40,11 +38,8 @@ class GWParser(object):
def startedParsing(self, path, parser):
"""called when parsing starts"""
self.parser = parser
# allows to reset values if the same superContext is used to parse different files
# self.initialize_values()
def parseGW(self, gwFile, backend, dftMethodSectionGindex, dftSingleConfigurationGindex, xcName, unitCellVol,gmaxvr):
# logging.error("GW onClose_section_single_configuration_calculation")
self.gmaxvr = float(gmaxvr[0])
self.unitCellVol = float(unitCellVol[0])
backend.openNonOverlappingSection("section_single_configuration_calculation")
......@@ -62,8 +57,8 @@ class GWParser(object):
else:
pass
dosGWFile = os.path.join(dirPath, "TDOS-QP.OUT")
bandCarbGWFile = os.path.join(dirPath, "bandstructure-qp.dat")
bandBorGWFile = os.path.join(dirPath, "BAND-QP.OUT")
bandCarbGWFile = os.path.join(dirPath, "bandstructure-qp.dat") # carbon exciting
bandBorGWFile = os.path.join(dirPath, "BAND-QP.OUT") # boron exciting
vertexGWFile = os.path.join(dirPath, "BANDLINES.OUT")
vertexLabGWFile = os.path.join(dirPath, "bandstructure.xml")
selfCorGWFile = os.path.join(dirPath, "SELFC.DAT")
......@@ -93,7 +88,7 @@ class GWParser(object):
backend.addValue("method_to_method_kind", "starting_point")
backend.closeNonOverlappingSection("section_method_to_method_refs")
with open(inputgwFile) as f:
exciting_parser_input.parseInput(f, backend, self.gmaxvr)
exciting_parser_gw_input.parseInput(f, backend, self.gmaxvr)
backend.closeSection("section_method",selfGWSetGIndex)
if os.path.exists(vertexGWFile):
......@@ -341,47 +336,18 @@ class GWParser(object):
backend.closeSection("section_k_band",bandGWGIndex)
backend.closeNonOverlappingSection("section_single_configuration_calculation")
# logging.error("done GW onClose_section_single_configuration_calculation")
# def onOpen_section_method(self, backend, gIndex, section):
# fava = section["gw_frequency_number"]
# print("fava=",fava)
# def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
# if dftSingleConfigurationGindex is not None:
## if self.secSingleConfIndex is None:
## self.secSingleConfIndex = gIndex
## singleGIndex = backend.openSection("section_single_configuration_calculation")
# fermi = section["gw_fermi_energy"]
# fundamental = section["gw_fundamental_gap"]
# optical = section["gw_optical_gap"]
# backend.addValue("gw_fermi_energy", fermi)
# backend.addValue("gw_fundamental_gap", fundamental)
# backend.addValue("gw_optical_gap", optical)
## backend.closeSection("section_single_configuration_calculation",singleGIndex)
# else:
# singleGIndex = backend.openSection("section_single_configuration_calculation")
# fermi = section["gw_fermi_energy"]
# fundamental = section["gw_fundamental_gap"]
# optical = section["gw_optical_gap"]
# backend.addValue("gw_fermi_energy", fermi)
# backend.addValue("gw_fundamental_gap", fundamental)
# backend.addValue("gw_optical_gap", optical)
# backend.closeSection("section_single_configuration_calculation",singleGIndex)
def buildGWMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "\=\s*Main GW output file\s*\=",
# sections = ["section_run"],
subMatchers = [
SM(
startReStr = "\-\s*frequency grid\s*\-",
endReStr = "\-\s*Peak memory estimate \(Mb, per process\)\:\s*\-",
sections = ["section_method"],
subMatchers = [
# SM(r"\s*Type\:\s*\<\s*(?P<gw_dummy>[-a-zA-Z]+)\s*\>"),
SM(r"\s*(?P<gw_frequency_number>[0-9]+)\s*(?P<gw_frequency_values__hartree>[0-9]\.[0-9]*([E]?[-]?[-0-9]+))\s*(?P<gw_frequency_weights>[0-9]\.[0-9]*([E]?[-]?[-0-9]+))", repeats = True)
]),
SM(
......
......
......@@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#############################################
# this is the subparser for the GW input file
#############################################
import xml.sax
import logging
import numpy as np
......@@ -79,7 +83,6 @@ class InputHandler(xml.sax.handler.ContentHandler):
def startElement(self, name, attrs):
fromH = unit_conversion.convert_unit_function("hartree", "J")
if name == "gw":
# self.inputSectionGIndex = self.backend.openSection("section_system")
self.inGWInput = True
try:
self.coreflag = attrs.getValue('coreflag')
......
......
......@@ -21,22 +21,18 @@ from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion import unit_conversion
import os, sys, json, logging
################################################################
# This is the subparser for the exciting XS output
################################################################
###########################################################################
# This is the subparser for the excitons, oscillator strength etc of the XS
###########################################################################
class XSParser(object):
"""context for wien2k In2 parser"""
def __init__(self):
pass
def startedParsing(self, path, parser):
"""called when parsing starts"""
self.parser = parser
# allows to reset values if the same superContext is used to parse different files
# self.initialize_values()
def parseExciton(self, excFile, backend, excNum, excEn, excBindEn, osclStr, transCoeff):
with open(excFile) as g:
......
......
......@@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
######################################################
# this is the subparser for the XS output (BSE, TDDFT)
######################################################
import xml.sax
import logging
import numpy as np
......@@ -21,10 +25,8 @@ from nomadcore.unit_conversion import unit_conversion
class InputHandler(xml.sax.handler.ContentHandler):
def __init__(self, backend, rgkmax):
# self.xsType = None
self.rgkmax = rgkmax[0]
self.rgkmaxScr = rgkmax[0]
# print("self.rgkmax===",self.rgkmax)
self.backend = backend
self.inputSectionGIndex = -1
self.inXSInput = False
......@@ -46,14 +48,10 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.scissor = 0.0
self.vkloffXS = [0.0, 0.0, 0.0]
self.vkloffXSDum = [0.0, 0.0, 0.0]
# self.vkloffScr = [-1.0, -1.0, -1.0]
# self.vkloffScrDum = "-1.0 -1.0 -1.0"
self.screening = "none"
######### BELOW XS VARIABLES ###########
self.bse = False
# self.screentype = "full"
############ BSE variables################
self.aresbse = True
# self.bsetype = "singlet"
self.lmaxdielt = 14
self.nstlbse = [0, 0, 0, 0]
self.nstlbseDum = [0, 0, 0, 0]
......@@ -80,16 +78,7 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.tetra = False
self.tetradf = "false"
# self.xstype = "BSE"
def endDocument(self):
# pass
# if self.freqgrid == "none":
# self.backend.addValue("gw_max_frequency", self.freqmax)
# self.backend.addValue("gw_frequency_grid_type", self.fgrid)
# self.backend.addValue("gw_number_of_frequencies", self.nomeg)
# self.backend.addValue("gw_basis_set", "mixed")
# self.backend.addValue("gw_qp_equation_treatment", "linearization")
if self.tetradf == "true":
self.backend.addValue("x_exciting_xs_tetra", True)
......@@ -102,9 +91,6 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.ngridkXS[j] = int(self.ngridkXSDum[j])
self.vkloffXS[j] = float(self.vkloffXSDum[j])
self.ngridkScr[j] = int(self.ngridkScrDum[j])
# self.nstlbse[j] = int (self.nstlbseDum[j])
# self.nstlxas[j] = int (self.nstlxasDum[j])
# self.vkloffScr[j] = float(self.vkloffScrDum[j])
for j in range(0,4):
self.nstlbse[j] = int (self.nstlbseDum[j])
......@@ -122,14 +108,6 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.backend.addValue("x_exciting_xs_bse_xasedge", self.xasedge)
self.backend.addValue("x_exciting_xs_bse_xasspecies", self.xasspecies)
self.backend.addValue("x_exciting_xs_bse_xas_number_of_bands", self.nstlxas)
# self.backend.addValue("x_exciting_xs_bse_xas_number_of_bands", self.nstlxas)
# for j in range(0,4):
# self.nstlbse[j] = int (self.nstlbseDum[j])
# for j in range(0,2):
# self.nstlxas[j] = int (self.nstlxasDum[j])
# self.backend.addValue("x_exciting_xs_screeninig_vkloff", self.vkloffScr)
if self.rgkmaxXs == 0.0:
self.backend.addValue("x_exciting_xs_rgkmax", self.rgkmax)
......@@ -148,14 +126,14 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.backend.addValue("x_exciting_xs_bse_rgkmax", float(self.rgkmaxBse))
def startElement(self, name, attrs):
# xsType = None
if name == "xs":
# self.inputSectionGIndex = self.backend.openSection("section_system")
self.inXSInput = True
xstype = attrs.getValue('xstype')
# IMPORTANT: so far, there is no way to define an xs calculation type. I have introduced a
# code-specific metadata, i.e. x_exciting_xs_type, that will have to be changed in the future.
# BSE or TDDFT could go into "electronic_structure_method"
self.backend.addValue("x_exciting_xs_xstype", xstype)
self.backend.addValue('x_exciting_electronic_structure_method', xstype)
# print("xstyppe===",xstype)
try:
self.broad = attrs.getValue('broad')
......@@ -212,7 +190,6 @@ class InputHandler(xml.sax.handler.ContentHandler):
try:
dummy = attrs.getValue('ngridk')
self.ngridkScrDum = dummy.split()
# print("dummo===",self.ngridkScrDum)
except:
self.ngridkScrDum = [0, 0, 0]
try:
......@@ -225,25 +202,8 @@ class InputHandler(xml.sax.handler.ContentHandler):
except:
self.backend.addValue("x_exciting_xs_screening_type", self.screentype)
# self.aresbse = "true"
# self.bsetype = "singlet"
# self.lmaxdielt = 14
# self.nstlbse = [0, 0, 0, 0]
# self.nstlxas = [0, 0]
# self.rgkmaxBse = rgkmax[0]
# self.sciavbd = "true"
# self.sciavqbd = "false"
# self.sciavqhd = "false"
# self.sciavqwg = "false"
# self.sciavtype = "spherical"
# self.xas = "false"
# self.xasatom = 0
# self.xasedge = "K"
# self.xasspecies = 0
elif name == "BSE":
self.bse = True
# xsType = "BSE"
try:
self.aresbse = attrs.getValue('aresbse')
if self.aresbse == "true":
......@@ -259,10 +219,8 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.backend.addValue("x_exciting_xs_bse_angular_momentum_cutoff", self.lmaxdielt)
try:
self.rgkmaxBse = attrs.getValue('rgkmax')
# self.backend.addValue("x_exciting_xs_bse_rgkmax", float(self.rgkmax))
except:
pass
# self.backend.addValue("x_exciting_xs_bse_rgkmax", self.rgkmax)
try:
self.sciavbd = attrs.getValue('sciavbd')
if self.sciavqbd == "true":
......@@ -303,33 +261,23 @@ class InputHandler(xml.sax.handler.ContentHandler):
try:
self.xas = attrs.getValue('xas')
if self.xas == "false":
# print("xas===",self.xas)
self.backend.addValue("x_exciting_xs_bse_xas", False)
else:
# print("xas===",self.xas)
self.backend.addValue("x_exciting_xs_bse_xas", True)
except:
# print("xasdefault===",self.xas)
self.backend.addValue("x_exciting_xs_bse_xas", self.xas)
try:
self.xasatom = int(attrs.getValue('xasatom'))
# self.backend.addValue("x_exciting_xs_bse_xasatom", self.xasatom)
except:
pass
# self.backend.addValue("x_exciting_xs_bse_xasatom", self.xasatom)
try:
self.xasedge = attrs.getValue('xasedge')
# self.backend.addValue("x_exciting_xs_bse_xasedge", self.xasedge)
except:
pass
# self.backend.addValue("x_exciting_xs_bse_xasedge", self.xasedge)
try:
self.xasspecies = int(attrs.getValue('xasspecies'))
# self.backend.addValue("x_exciting_xs_bse_xasspecies", self.xasspecies)
except:
pass
# self.backend.addValue("x_exciting_xs_bse_xasspecies", self.xasspecies)
# if self.xas == False:
try:
dummy = attrs.getValue('nstlbse')
self.nstlbseDum = dummy.split()
......@@ -434,13 +382,8 @@ class InputHandler(xml.sax.handler.ContentHandler):
self.tetra = True
try:
self.tetradf = attrs.getValue('tetradf')
# if self.tetradf == "true":
# selfbackend.addValue("x_exciting_xs_tetra", True)
# else:
# self.backend.addValue("x_exciting_xs_tetra", False)
except:
self.tetradf == "false"
# self.backend.addValue("x_exciting_xs_tetra", False)
def endElement(self, name):
pass
......
......
This diff is collapsed.
......@@ -47,9 +47,9 @@ object ExcitingParser extends SimpleExternalParserGenerator(
"parser-exciting/exciting_parser_dos.py",
"parser-exciting/exciting_parser_bandstructure.py",
"parser-exciting/exciting_parser_gw.py",
"parser-exciting/exciting_parser_input.py",
"parser-exciting/exciting_parser_GS_input.py",
"parser-exciting/exciting_parser_XS_input.py",
"parser-exciting/exciting_parser_gw_input.py",
"parser-exciting/exciting_parser_gs_input.py",
"parser-exciting/exciting_parser_xs_input.py",
"parser-exciting/exciting_parser_xs.py",
"parser-exciting/exciting_parser_eps.py",
"parser-exciting/setup_paths.py",
......
......
......@@ -21,11 +21,11 @@ import eu.nomad_lab.DefaultPythonInterpreter
import org.{ json4s => jn }
import scala.collection.breakOut
object ExcitingParserHelium extends SimpleExternalParserGenerator(
name = "ExcitingParserHelium",
object ExcitingParserLithium extends SimpleExternalParserGenerator(
name = "ExcitingParserLithium",
parserInfo = jn.JObject(
("name" -> jn.JString("ExcitingParserHelium")) ::
("parserId" -> jn.JString("ExcitingParserHelium" + lab.ExcitingVersionInfo.version)) ::
("name" -> jn.JString("ExcitingParserLithium")) ::
("parserId" -> jn.JString("ExcitingParserLithium" + lab.ExcitingVersionInfo.version)) ::
("versionInfo" -> jn.JObject(
("nomadCoreVersion" -> jn.JObject(lab.NomadCoreVersionInfo.toMap.map {
case (k, v) => k -> jn.JString(v.toString)
......@@ -40,11 +40,11 @@ object ExcitingParserHelium extends SimpleExternalParserGenerator(
mainFileRe = """\s*\+-----------------------------------+\+\s*
\s*\|\s*EXCITING\s(?<version>Lithium\s*\S*) started\s*\|\s*
(?:\s*\|\sversion hash id:\s*(?<hashId>\S+)\s*\|)?""".r,
cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/parsers/exciting/parser/parser-exciting/parser_exciting_helium.py",
cmd = Seq(DefaultPythonInterpreter.pythonExe(), "${envDir}/parsers/exciting/parser/parser-exciting/parser_exciting_lithium.py",
"--uri", "${mainFileUri}", "${mainFilePath}"),
mainFileMatchPriority = 5,
resList = Seq(
"parser-exciting/parser_exciting_helium.py",
"parser-exciting/parser_exciting_lithium.py",
"parser-exciting/exciting_parser_dos.py",
"parser-exciting/exciting_parser_bandstructure.py",
"parser-exciting/exciting_parser_input.py",
......
......
......@@ -29,14 +29,14 @@ object ExcitingParserSpec extends Specification {
ParserRun.parse(ExcitingParser, "parsers/exciting/test/examples/Ag/INFO.OUT", "json") must_== ParseResult.ParseSuccess
}
"ExcitingParserHeliumTest" >> {
"ExcitingParserLithiumTest" >> {
"test with json-events" >> {
ParserRun.parse(ExcitingParserHelium, "parsers/exciting/test/examples/lithium/INFO.OUT", "json-events") must_== ParseResult.ParseSuccess
ParserRun.parse(ExcitingParserLithium, "parsers/exciting/test/examples/lithium/INFO.OUT", "json-events") must_== ParseResult.ParseSuccess
}
}
"test with json" >> {
ParserRun.parse(ExcitingParserHelium, "parsers/exciting/test/examples/lithium/INFO.OUT", "json") must_== ParseResult.ParseSuccess
ParserRun.parse(ExcitingParserLithium, "parsers/exciting/test/examples/lithium/INFO.OUT", "json") must_== ParseResult.ParseSuccess
}
"ExcitingParserTestiGW" >> {
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment