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

support for BSE

parent b6fab8c3
# Copyright 2017-2018 Lorenzo Pardini
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from builtins import object
import setup_paths
import xml.sax
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
################################################################
# This is the subparser for the exciting XS output
################################################################
def is_number(s):
try:
float(s)
return True
except ValueError:
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:
while 1:
s = g.readline()
if not s: break
s = s.strip()
s = s.split()
if len(s) == 0:
break
else:
epsEn[-1].append(float(s[0]))
epsilon[-1][0].append(float(s[1]))
epsilon[-1][1].append(float(s[2]))
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
cachingLevelForMetaName = {}
return cachingLevelForMetaName
......@@ -22,7 +22,7 @@ from nomadcore.unit_conversion import unit_conversion
import os, sys, json, logging
################################################################
# This is the subparser for the exciting GW output
# This is the subparser for the exciting XS output
################################################################
......@@ -31,11 +31,6 @@ class XSParser(object):
def __init__(self):
pass
# self.excitonEnergys = []
# self.vertexLabels = []
# self.vertexNum = 0
# self.parser = None
# self.secSingleConfIndex = None
def startedParsing(self, path, parser):
"""called when parsing starts"""
......@@ -44,12 +39,6 @@ class XSParser(object):
# self.initialize_values()
def parseExciton(self, excFile, backend, excNum, excEn, excBindEn, osclStr, transCoeff):
# if dftSingleConfigurationGindex is not None:
# backend.openNonOverlappingSection("section_calculation_to_calculation_refs")
# backend.addValue("calculation_to_calculation_ref", dftSingleConfigurationGindex)
# backend.addValue("calculation_to_calculation_kind", "starting_point")
# backend.closeNonOverlappingSection("section_calculation_to_calculation_refs")
# logging.error("GW onClose_section_single_configuration_calculation")
with open(excFile) as g:
while 1:
s = g.readline()
......@@ -64,44 +53,7 @@ class XSParser(object):
transCoeff[-1][0].append(float(s[4]))
transCoeff[-1][1].append(float(s[5]))
# print("s===",excNum)
# if len(st) == 3:
# if len(s) >= 40:
# print("vaaa")
# self.gmaxvr = float(gmaxvr[0])
# self.unitCellVol = float(unitCellVol[0])
# backend.openNonOverlappingSection("section_single_configuration_calculation")
# if dftSingleConfigurationGindex is not None:
# backend.openNonOverlappingSection("section_calculation_to_calculation_refs")
# backend.addValue("calculation_to_calculation_ref", dftSingleConfigurationGindex)
# backend.addValue("calculation_to_calculation_kind", "starting_point")
# backend.closeNonOverlappingSection("section_calculation_to_calculation_refs")
#
# dirPath = os.path.dirname(gwFile)
# if os.access(os.path.join(dirPath, "EVALQP.DAT"), os.F_OK):
# eigvalGWFile = os.path.join(dirPath, "EVALQP.DAT")
# elif os.access(os.path.join(dirPath, "EVALQP.TXT"), os.F_OK):
# eigvalGWFile = os.path.join(dirPath, "EVALQP.TXT")
# 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")
# vertexGWFile = os.path.join(dirPath, "BANDLINES.OUT")
# vertexLabGWFile = os.path.join(dirPath, "bandstructure.xml")
# selfCorGWFile = os.path.join(dirPath, "SELFC.DAT")
# inputFile = os.path.join(dirPath, "input.xml")
# inputgw1File = os.path.join(dirPath, "input-gw.xml")
# inputgw2File = os.path.join(dirPath, "input_gw.xml")
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
cachingLevelForMetaName = {}
# 'section_single_configuration_calculation': CachingLvl
# }
# cachingLevelForMetaName["gw_fundamental_gap"] = CachingLevel.Cache
# cachingLevelForMetaName["gw_optical_gap"] = CachingLevel.Cache
# cachingLevelForMetaName["gw_fermi_energy"] = CachingLevel.Cache
return cachingLevelForMetaName
This diff is collapsed.
......@@ -23,7 +23,7 @@ from nomadcore.caching_backend import CachingLevel
from nomadcore.unit_conversion import unit_conversion
from nomadcore.unit_conversion.unit_conversion import convert_unit_function
import os, sys, json, exciting_parser_dos,exciting_parser_bandstructure, exciting_parser_gw, exciting_parser_GS_input
import exciting_parser_XS_input, exciting_parser_xs
import exciting_parser_XS_input, exciting_parser_xs, exciting_parser_eps
from ase import Atoms
import logging
......@@ -236,6 +236,13 @@ class ExcitingParserContext(object):
excBindEn = []
osclStr = []
transCoeff = []
epsEn = []
sigmaEn = []
epsilon = []
sigma = []
lossEn = []
loss = []
lossDummy = []
# print("BSE!!!")
# if os.path.exists(inputgwFile):
inputXSFile = os.path.join(dirPath, "input.xml")
......@@ -264,6 +271,7 @@ class ExcitingParserContext(object):
elif dummyBse == 'IP':
self.bsetype = 'IP'
name = "EXCITON_BSE" + self.bsetype + '_SCR'
# nameEps = "EPSILON_BSE" + self.bsetype + '_SCR'
if files[len(name):len(name)+4] == 'full':
self.screentype = 'full'
elif files[len(name):len(name)+4] == 'diag':
......@@ -291,18 +299,49 @@ class ExcitingParserContext(object):
for i in range(numberOfComponents):
excNum.append([])
excEn.append([])
epsEn.append([])
sigmaEn.append([])
excBindEn.append([])
osclStr.append([])
transCoeff.append([[],[]])
epsilon.append([[],[]])
sigma.append([[],[]])
lossEn.append([])
loss.append([[],[]])
# lossDummy.append([])
outputXSFile = os.path.join(dirPath, "EXCITON_BSE" + self.bsetype + '_SCR' + self.screentype + "_OC" + self.tensorComp[i] + ".OUT")
outputEpsFile = os.path.join(dirPath, "EPSILON_BSE" + self.bsetype + '_SCR' + self.screentype + "_OC" + self.tensorComp[i] + ".OUT")
outputSigmaFile = os.path.join(dirPath, "SIGMA_BSE" + self.bsetype + '_SCR' + self.screentype + "_OC" + self.tensorComp[i] + ".OUT")
outputLossFile = os.path.join(dirPath, "LOSS_BSE" + self.bsetype + '_SCR' + self.screentype + "_OC" + self.tensorComp[i] + ".OUT")
with open(outputXSFile) as g:
xsParser = exciting_parser_xs.XSParser()
xsParser.parseExciton(outputXSFile, backend, excNum, excEn, excBindEn, osclStr, transCoeff) #, dftMethodSectionGindex = self.secMethodIndex,
with open(outputEpsFile) as g:
epsParser = exciting_parser_eps.EPSParser()
epsParser.parseEpsilon(outputEpsFile, backend, epsEn, epsilon) #, dftMethodSectionGindex = self.secMethodIndex,
with open(outputSigmaFile) as g:
sigmaParser = exciting_parser_eps.EPSParser()
sigmaParser.parseEpsilon(outputSigmaFile, backend, sigmaEn, sigma) #, dftMethodSectionGindex = self.secMethodIndex,
with open(outputLossFile) as g:
lossParser = exciting_parser_eps.EPSParser()
lossParser.parseEpsilon(outputLossFile, backend, lossEn, loss) #, dftMethodSectionGindex = self.secMethodIndex,
# dftSingleConfigurationGindex = self.secSingleConfIndex)
# backend.addvalue("x_exciting_xs_bse_number_of_components",numberOfComponents)
# backend.addvalue("x_exciting_xs_bse_number_of_excitons",len(excNum))
backend.addValue("x_exciting_xs_bse_number_of_components",numberOfComponents)
backend.addValue("x_exciting_xs_bse_number_of_excitons",len(excNum))
backend.addValue("x_exciting_xs_bse_exciton_energies",excEn)
# print("===",excBindEn)
backend.addValue("x_exciting_xs_bse_exciton_binding_energies",excBindEn)
backend.addValue("x_exciting_xs_bse_exciton_oscillator_strength",osclStr)
backend.addValue("x_exciting_xs_bse_exciton_amplitude_re",transCoeff[0])
backend.addValue("x_exciting_xs_bse_exciton_amplitude_im",transCoeff[1])
backend.addValue("x_exciting_xs_bse_epsilon_energies",epsEn)
backend.addValue("x_exciting_xs_bse_epsilon_re",epsilon[0])
backend.addValue("x_exciting_xs_bse_epsilon_im",epsilon[1])
backend.addValue("x_exciting_xs_bse_sigma_energies",sigmaEn)
backend.addValue("x_exciting_xs_bse_sigma_re",sigma[0])
backend.addValue("x_exciting_xs_bse_sigma_im",sigma[1])
backend.addValue("x_exciting_xs_bse_loss_energies",lossEn)
backend.addValue("x_exciting_xs_bse_loss",loss[0])
backend.closeNonOverlappingSection("section_single_configuration_calculation")
......
......@@ -50,6 +50,7 @@ object ExcitingParser extends SimpleExternalParserGenerator(
"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",
"nomad_meta_info/public.nomadmetainfo.json",
"nomad_meta_info/common.nomadmetainfo.json",
......
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