Commits (9)
This diff is collapsed.
......@@ -32,6 +32,7 @@ import excitingparser.exciting_parser_eps as exciting_parser_eps
from ase import Atoms
import logging
logger = logging.getLogger("nomad.ExcitingParser")
def is_number(s):
try:
......@@ -275,8 +276,10 @@ class ExcitingParserContext(object):
try: # tmk:
with open(inputXSFile) as f:
exciting_parser_XS_input.parseInput(f, backend, self.rgkmax)
except IOError:
logging.error("File not found: %s" % (inputXSFile))
except FileNotFoundError:
logger.warning("File not found: {}" .format(inputXSFile))
except Exception as err:
logger.error("Exception file.py: ", exc_info=err)
# xstype = section["x_exciting_xs_type"]
# print("xstype===",xstype)
# print("xsType===",exciting_parser_XS_input.InputHandler.self.xsType)
......@@ -368,18 +371,38 @@ class ExcitingParserContext(object):
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,
# - - - - -
try:
with open(outputXSFile) as g:
xsParser = exciting_parser_xs.XSParser()
xsParser.parseExciton(outputXSFile, backend, excNum, excEn, excBindEn, osclStr, transCoeff) #, dftMethodSectionGindex = self.secMethodIndex,
except FileNotFoundError:
logger.warning("File not found: {}" .format(outputXSFile))
except Exception as err:
logger.error("Exception on Exciting subparser", exc_info=err)
# - - - - -
try:
with open(outputEpsFile) as g:
epsParser = exciting_parser_eps.EPSParser()
epsParser.parseEpsilon(outputEpsFile, backend, epsEn, epsilon) #, dftMethodSectionGindex = self.secMethodIndex,
except FileNotFoundError:
logger.warning("File not found: {}" .format(outputEpsFile))
except Exception as err:
logger.error("Exception on Exciting subparser", exc_info=err)
# - - - - -
try:
with open(outputSigmaFile) as g:
sigmaParser = exciting_parser_eps.EPSParser()
sigmaParser.parseEpsilon(outputSigmaFile, backend, sigmaEn, sigma) #, dftMethodSectionGindex = self.secMethodIndex,
except FileNotFoundError:
logger.warning("File not found: {}" .format(outputSigmaFile))
except Exception as err:
logger.error("Exception on Exciting subparser", exc_info=err)
# 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))
......@@ -471,11 +494,10 @@ class ExcitingParserContext(object):
# self.xstype = "BSE"
# dummyBse = files[11:13]
# self.tensorComp = files[-6:-4]
# WARNING: the following entries don't exist in Exciting Metainfo!!
#backend.addValue("x_exciting_xs_tddft_number_of_optical_components",len(tensorComp))
#backend.addValue("x_exciting_xs_tddft_optical_component",tensorComp)
#backend.addValue("x_exciting_xs_tddft_number_of_q_points",qpointNumber)
#backend.addValue("s",qpointNumber)
for i in range(qpointNumber):
dielTensSym.append([[],[]])
......@@ -563,7 +585,7 @@ class ExcitingParserContext(object):
backend.addValue("x_exciting_xs_tddft_epsilon_energies",dielFunctEne[0][0])
backend.addValue("x_exciting_xs_tddft_dielectric_function_local_field",dielFunctLoc)
except IOError:
logging.error("File not processable: %s" % (epsilonLocalField))
logger.error("File not processable: %s" % (epsilonLocalField))
#########
try:
......@@ -596,7 +618,7 @@ class ExcitingParserContext(object):
lossFunctionLoc[-1][-1].append(loss)
backend.addValue("x_exciting_xs_tddft_loss_function_local_field",lossFunctionLoc)
except IOError:
logging.error("File not processable: %s" % (lossFunctionLocalFieldFile))
logger.error("File not processable: %s" % (lossFunctionLocalFieldFile))
#########
try:
......@@ -613,7 +635,7 @@ class ExcitingParserContext(object):
lossFunctionNoLoc[-1][-1].append(loss)
backend.addValue("x_exciting_xs_tddft_loss_function_no_local_field",lossFunctionNoLoc)
except IOError:
logging.error("File not processable: %s" % (lossFunctionNoLocalFieldFile))
logger.error("File not processable: %s" % (lossFunctionNoLocalFieldFile))
#########
sigmaLocalFieldFile = os.path.join(dirPath, 'SIGMA_' + ext + 'FXC' + self.tddftKernel[0] + '_OC' + tensorComp[j] + qExt00 + '.OUT')
......@@ -630,7 +652,7 @@ class ExcitingParserContext(object):
sigmaLoc[1][-1][-1].append(sigmaIm)
backend.addValue("x_exciting_xs_tddft_sigma_local_field",sigmaLoc)
except IOError:
logging.error("File not processable: %s" % (sigmaLocalFieldFile))
logger.error("File not processable: %s" % (sigmaLocalFieldFile))
#
#########
sigmaNoLocalFieldFile = os.path.join(dirPath, 'SIGMA_' + ext + 'NLF_' + 'FXC' + self.tddftKernel[0] + '_OC' + tensorComp[j] + qExt00 + '.OUT')
......@@ -647,7 +669,7 @@ class ExcitingParserContext(object):
sigmaNoLoc[1][-1][-1].append(sigmaIm)
backend.addValue("x_exciting_xs_tddft_sigma_no_local_field",sigmaNoLoc)
except IOError:
logging.error("File not processable: %s" % (sigmaLocalFieldFile))
logger.error("File not processable: %s" % (sigmaLocalFieldFile))
# dielFunctEne[-1][-1].append(ene)
# if s and is_number(s[0]):
......@@ -660,7 +682,8 @@ class ExcitingParserContext(object):
# qPlusGLattice[i].append([float(s[1]),float(s[2]),float(s[3])])
# qPlusGCartesian[i].append([float(s[4]),float(s[5]),float(s[6])])
#WARNING: the following entries don't exist in the Excitinv Metainfo!!
#WARNING: the following entries don't exist in the Exciting Metainfo!!
#backend.addValue("x_exciting_xs_tddft_dielectric_tensor_sym",dielTensSym)
#backend.addValue("x_exciting_xs_tddft_dielectric_tensor_no_sym",dielTensNoSym)
......@@ -743,7 +766,7 @@ class ExcitingParserContext(object):
backend.closeSection("section_XC_functionals", gi)
def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
# logging.error("BASE onClose_section_single_configuration_calculation")
# logger.error("BASE onClose_section_single_configuration_calculation")
backend.addValue('single_configuration_to_calculation_method_ref', self.secMethodIndex)
backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemIndex)
# print("self.samplingMethod=",self.samplingMethod)
......@@ -770,11 +793,18 @@ class ExcitingParserContext(object):
####################VOLUME TEST END############################
# NOMAD-FAIRD Edit, we see that the suscript on
# section["x_exciting_geometry_optimization_threshold_force"] is
# giving an error saying this object is not suscribtable.
if self.samplingMethod == "geometry_optimization":
self.geometryForceThreshold = section["x_exciting_geometry_optimization_threshold_force"][0]
ivalue = section["x_exciting_geometry_optimization_threshold_force"]
if ivalue is None:
# then use default value
self.geometryForceThreshold = self.geometryForceThreshold
logger.warning("Found suspicious value for geometry optimization "
"threshold force. Hint: inspect INFO.OUT, is it complete?")
else:
try:
self.geometryForceThreshold = ivalue[0]
except:
raise
forceX = section["x_exciting_geometry_atom_forces_x"]
if forceX:
forceY = section["x_exciting_geometry_atom_forces_y"]
......@@ -846,7 +876,7 @@ class ExcitingParserContext(object):
bandFile = os.path.join(dirPath, "bandstructure.xml")
fermiSurfFile = os.path.join(dirPath, "FERMISURF.bxsf")
eigvalFile = os.path.join(dirPath, "EIGVAL.OUT")
# logging.error("done BASE onClose_section_single_configuration_calculation")
# logger.error("done BASE onClose_section_single_configuration_calculation")
if os.path.exists(dosFile):
with open(dosFile) as f:
......@@ -874,17 +904,44 @@ class ExcitingParserContext(object):
elif "nkpt" in s.split():
nkpt = int(s.split()[0])
continue
elif len(s) > 50:
eigvalVal.append([])
eigvalOcc.append([])
eigvalKpoint.append([float(x) for x in s.split()[1:4]])
elif len(s) > 50 and ('k-point,' in s.split()):
try:
int(s[0]) # assert this line is not a header string
except ValueError:
continue
else:
eigvalVal.append([])
eigvalOcc.append([])
eigvalKpoint.append([float(x) for x in s.split()[1:4]])
else:
try: int(s[0])
try:
int(s[0])
except ValueError:
# ignore headers by neglecting lines that
# don't start with an integer
continue
else:
n, e, occ = s.split()
eigvalVal[-1].append(fromH(float(e)))
# FIXME: EIG files with 'partial chg density' have 7 columns
# FIXME: and we need to process them
n, e, occ = s.split()[0:3]
#---------
try: # eigenvalues 'e' could be wrongly formatted
enew = float(e)
except Exception as ex:
if 'E' not in e.upper():
pieces = e.split('-')
if (len(pieces) != 2):
raise ex
try:
pieces = [ float(ii) for ii in pieces ]
except:
raise ex
mantissa, exponent = pieces
enew = mantissa * 10**(-1 * exponent)
logger.warning("In-house conversion '{}' -> {}" .format(e, enew))
#---------
eigvalVal[-1].append(fromH(enew))
eigvalOcc[-1].append(float(occ))
if not self.spinTreat:
for i in range(0,nkpt):
......@@ -976,6 +1033,9 @@ class ExcitingParserContext(object):
self.rgkmax = section["x_exciting_rgkmax"]
backend.addArrayValues('configuration_periodic_dimensions', np.asarray([True, True, True]))
# next line fixes normalizer error "no lattice vectors but pbc"
backend.addArrayValues("lattice_vectors", self.sim_cell)
self.secSystemDescriptionIndex = gIndex
if self.atom_pos and self.cell_format[0] == 'cartesian':
......@@ -1399,5 +1459,5 @@ class ExcitingParser():
cachingLevelForMetaName = cachingLevelForMetaName,
superContext=ExcitingParserContext(),
superBackend=backend)
#print("#"*50 + "\nPARSING ENDED. NORMALIZER FOLLOWS..."+"\n"*5)# tmk:
return backend