Commits (2)
from wien2kparser.wien2k_parser import Wien2kParser
\ No newline at end of file
# Copyright 2016-2018 Daria Tomecka, Fawzi Mohamed
#
# 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.
import sys, os, os.path
baseDir = os.path.dirname(os.path.abspath(__file__))
commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python"))
if not commonDir in sys.path:
sys.path.insert(0, commonDir)
from builtins import object
from wien2kparser import setup_paths
import numpy as np
from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json, logging
from wien2kparser import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2
################################################################
# This is the parser for the main output file (.scf) of WIEN2k.
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kContext(object):
"""context for wien2k parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
self.metaInfoEnv = self.parser.parserBuilder.metaInfoEnv
self.rootSecMethodIndex = None
self.secMethodIndex = None
self.secSystemIndex = None
self.scfIterNr = 0
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 onClose_x_wien2k_header(self, backend, gIndex, section):
version_check = section["x_wien2k_version"]
# riprova = section["x_wien2k_release_date"][0]
# print("prova=",prova," riprova=",riprova)
if version_check:
backend.addValue("program_version",
section["x_wien2k_version"][0] + " " +
section["x_wien2k_release_date"][0])
else:
backend.addValue("program_version", "Before_wien2k11")
def onOpen_section_system(self, backend, gIndex, section):
self.secSystemIndex = gIndex
def onOpen_section_method(self, backend, gIndex, section):
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in0"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in0.Wien2kIn0Context()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in0.buildIn0Matchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in0.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in1c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in1c.Wien2kIn1cContext()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in1c.buildIn1cMatchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in1c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in2c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in2c.Wien2kIn2cContext()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in2c.buildIn2cMatchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in2c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in1"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in1.Wien2kIn1Context()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in1.buildIn1Matchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in1.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in2"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in2.Wien2kIn2Context()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in2.buildIn2Matchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in2.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
#if self.secMethodIndex is None:
if self.rootSecMethodIndex is None:
self.rootSecMethodIndex = gIndex
self.secMethodIndex = gIndex
# self.secMethodIndex["single_configuration_to_calculation_method_ref"] = gIndex
def onClose_section_single_configuration_calculation(self, backend, gIndex, section):
# write number of SCF iterations
backend.addValue('number_of_scf_iterations', self.scfIterNr)
# write the references to section_method and section_system
backend.addValue('single_configuration_to_calculation_method_ref', self.secMethodIndex)
backend.addValue('single_configuration_calculation_to_system_ref', self.secSystemIndex)
def onClose_section_system(self, backend, gIndex, section):
#backend.addValue("smearing_kind", x_fleur_smearing_kind)
smearing_kind = section['x_wien2k_smearing_kind']
if smearing_kind is not None:
# value = ''
backend.addValue('x_wien2k_smearing_kind', value)
smearing_width = section['x_wien2k_smearing_width']
if smearing_width is not None:
# value = ''
backend.addValue('x_wien2k_smearing_width', value)
# atom labels
atom_labels = section['x_wien2k_atom_name']
if atom_labels is not None:
backend.addArrayValues('atom_labels', np.asarray(atom_labels))
# atom force
atom_force = []
for i in ['x', 'y', 'z']:
api = section['x_wien2k_for_' + i]
if api is not None:
atom_force.append(api)
if atom_force:
# need to transpose array since its shape is [number_of_atoms,3] in\the metadata
backend.addArrayValues('atom_forces', np.transpose(np.asarray(atom_force)))
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".struct"
if os.path.exists(fName):
structSuperContext = wien2k_parser_struct.Wien2kStructContext()
structParser = AncillaryParser(
fileDescription = wien2k_parser_struct.buildStructureMatchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_struct.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = structSuperContext)
with open(fName) as fIn:
structParser.parseFile(fIn)
def onClose_section_scf_iteration(self, backend, gIndex, section):
#Trigger called when section_scf_iteration is closed.
# count number of SCF iterations
self.scfIterNr += 1
# description of the input
mainFileDescription = SM(
name = 'root',
weak = True,
startReStr = "",
sections = ['section_run','x_wien2k_header'],
subMatchers = [
SM(r"\s*:LABEL[0-9]+: using WIEN2k_(?P<x_wien2k_version>[0-9.]+) \(Release (?P<x_wien2k_release_date>[0-9/.]+)\) in "),
SM(name = 'newRun',
# subMatchers=[
# SM(r"\s*:LABEL[0-9]+: using WIEN2k_(?P<x_wien2k_version>[0-9.]+) \(Release (?P<x_wien2k_release_date>[0-9/.]+)\) in ")
# ],
startReStr = r"\s*:ITE[0-9]+:\s*[0-9]+.\s*ITERATION",
repeats = True,
required = True,
forwardMatch = True,
sections = ['section_method', 'section_system', 'section_single_configuration_calculation'],
fixedStartValues={'program_name': 'WIEN2k', 'program_basis_set_type': '(L)APW+lo' }, #, 'program_version': 'Before WIEN2k_11'},
subMatchers = [
SM(
name = "scf iteration",
startReStr = r"\s*:ITE(?P<x_wien2k_iteration_number>[0-9]+):\s*[0-9]*. ITERATION",
sections=["section_scf_iteration"],
repeats = True,
subMatchers=[
SM(r":NATO\s*:\s*(?P<x_wien2k_nr_of_independent_atoms>[0-9]+)\s*INDEPENDENT AND\s*(?P<x_wien2k_total_atoms>[0-9]+)\s*TOTAL ATOMS IN UNITCELL"),
SM(r"\s*SUBSTANCE: (?P<x_wien2k_system_name>.*)"),
SM(r":POT\s*:\s*POTENTIAL OPTION\s*(?P<x_wien2k_potential_option>[0-9]+)"),
SM(r":LAT\s*:\s*LATTICE CONSTANTS=\s*(?P<x_wien2k_lattice_const_a>[0-9.]+)\s*(?P<x_wien2k_lattice_const_b>[0-9.]+)\s*(?P<x_wien2k_lattice_const_c>[0-9.]+)"),
SM(r":VOL\s*:\s*UNIT CELL VOLUME\s*=\s*(?P<x_wien2k_unit_cell_volume_bohr3>[0-9.]+)"),
SM(r":RKM : MATRIX SIZE (?P<x_wien2k_matrix_size>[0-9]+)\s*LOs:\s*(?P<x_wien2k_LOs>[0-9.]+)\s*RKM=\s*(?P<x_wien2k_rkm>[0-9.]+)\s*WEIGHT=\s*[0-9.]*\s*\w*:"),
SM(r":KPT\s*:\s*NUMBER\s*OF\s*K-POINTS:\s*(?P<x_wien2k_nr_kpts>[-+0-9.]+)"),
#SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*(?P<x_wien2k_cutoff>[0-9.]+)\s*Ry\*\*[0-9.]+"),
SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*(?P<x_wien2k_cutoff>[0-9.]+)\s*Ry\W\W[0-9.]+"),
SM(r":GAP\s*:\s*(?P<x_wien2k_ene_gap__rydberg>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*.*"),
SM(r":NOE\s*:\s*NUMBER\sOF\sELECTRONS\s*=\s*(?P<x_wien2k_noe>[0-9.]+)"),
SM(r":FER\s*:\s(\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene__rydberg>[-+0-9.]+)"),
SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*[0-9.]+\s*Ry\W\W[0-9.]+"),
SM(r":CHA(?P<x_wien2k_atom_nr>[-+0-9]+):\s*TOTAL\s*\w*\s*CHARGE INSIDE SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_val_charge_sphere>[0-9.]+)",repeats = True),
SM(r":CHA\s*:\s*TOTAL\s*\w*\s*CHARGE INSIDE\s*\w*\s*CELL\s=\s*(?P<x_wien2k_tot_val_charge_cell>[-+0-9.]+)"),
SM(r":MMTOT: TOTAL MAGNETIC MOMENT IN CELL =\s*(?P<x_wien2k_mmtot>[-+0-9.]+)"),
SM(r":MMINT: MAGNETIC MOMENT IN INTERSTITIAL =\s*(?P<x_wien2k_mmint>[-+0-9.]+)"),
SM(r":MMI001: MAGNETIC MOMENT IN SPHERE 1 =\s*(?P<x_wien2k_mmi001>[-+0-9.]+)"),
SM(r":RTO(?P<x_wien2k_atom_nr>[-+0-9]+)\s*:\s*[0-9]+\s*(?P<x_wien2k_density_at_nucleus_valence>[-+0-9.]+)\s*(?P<x_wien2k_density_at_nucleus_semicore>[-+0-9.]+)\s*(?P<x_wien2k_density_at_nucleus_core>[-+0-9.]+)\s*(?P<x_wien2k_density_at_nucleus_tot>[0-9.]+)",repeats = True),
SM(r":NTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge_nm>[-+0-9.]+)"),
SM(r":NTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere_nm>[-+0-9.]+)",repeats = True),
SM(r":DTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\sTOTAL\s*DIFFERENCE\s*CHARGE\W*\w*\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_diff_charge>[-+0-9.]+)", repeats = True),
SM(r":DIS\s*:\s*CHARGE\sDISTANCE\s*\W*[0-9.]+\sfor\satom\s*[0-9]*\sspin\s[0-9]*\W\s*(?P<x_wien2k_charge_distance>[0-9.]+)"),
SM(r":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+0-9.]+)"),
SM(r":CTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere>[-+0-9.]+)",repeats = True),
# SM(r":NEC(?P<x_wien2k_necnr>[-+0-9]+)\s*:\s*NUCLEAR AND ELECTRONIC CHARGE\s*(?P<x_wien2k_nuclear_charge>[-+0-9.]+)\s*(?P<x_wien2k_electronic_charge>[0-9.]+)",repeats = True),
SM(r":ENE\s*:\s*\W*\w*\W*\s*TOTAL\s*ENERGY\s*IN\s*Ry\s*=\s*(?P<x_wien2k_energy_total__rydberg>[-+0-9.]+)"),
SM(r":FOR[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_abs>[0-9.]+)\s*(?P<x_wien2k_for_x>[-++0-9.]+)\s*(?P<x_wien2k_for_y>[-+0-9.]+)\s*(?P<x_wien2k_for_z>[-+0-9.]+)\s*partial\sforces", repeats = True),
SM(r":FGL[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_x_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_y_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_z_gl>[-+0-9.]+)\s*partial\sforces", repeats = True)
]
)
]
)
])
# which values to cache or forward (mapping meta name -> CachingLevel)
cachingLevelForMetaName = {
"XC_functional_name": CachingLevel.ForwardAndCache,
"energy_total": CachingLevel.ForwardAndCache
}
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
parserInfo = {
"name": "Wien2k",
"version": "1.0"
}
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../../../nomad-meta-info/meta_info/nomad_meta_info/wien2k.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
class Wien2kParser:
""" A proper class envolop for running this parser from within python. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
logging.warn('something is wrong')
logger = logging.getLogger(__name__)
logger.warn(...)
def parse(self, mainfile):
from unittest.mock import patch
# _logging.getLogger('nomadcore').setLevel(_logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]):
mainFunction(
mainFileDescription,
metaInfoEnv,
parserInfo,
superContext=Wien2kContext(),
superBackend=backend)
return backend
def setup_logger(self, new_logger):
if hasattr(new_logger, 'bind'):
# tell tests about received logger
new_logger.debug('received logger')
if __name__ == "__main__":
superContext = Wien2kContext()
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext)
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json, logging
################################################################
# This is the subparser for the WIEN2k input file (.in0)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn0Context(object):
"""context for wien2k In0 parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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 onClose_x_wien2k_section_XC(self, backend, gIndex, section):
xc_index = section["x_wien2k_indxc"] #[0]
#logging.error("winsectxc: %s -> %s", section, xc_index)
if not xc_index:
xc_index = ["XC_PBE"]
xc_map_legend = {
'5': ['LDA_C_PW_RPA'],
'XC_LDA': ['LDA_X_2D'],
'13': ['GGA_X_PBE', 'GGA_C_PBE'],
'XC_PBE':['GGA_X_PBE', 'GGA_C_PBE'],
'19': ['GGA_X_PBE_SOL', 'GGA_C_PBE_SOL'],
'XC_PBESOL': ['GGA_X_PBE_SOL', 'GGA_C_PBE_SOL'],
'11': ['GGA_X_WC'],
'XC_WC': ['GGA_X_WC'],
'17': ['GGA_X_PW91'],
'EC_PW91': ['GGA_X_PW91'],
'VC_PW91': ['GGA_X_PW91'],
'28': ['MGGA_X_TB09'],
'XC_MBJ': ['MGGA_X_TB09'],
'29': ['MGGA_C_REVTPSS, GGA_C_REGTPSS'],
'XC_REVTPSS': ['MGGA_C_REVTPSS, GGA_C_REGTPSS'],
'24': ['GGA_X_B88', 'GGA_C_LYP'],
'EX_B88': ['GGA_X_B88'],
'VX_B88': ['GGA_X_B88'],
'EC_LYP': ['GGA_C_LYP'],
'VC_LYP': ['GGA_C_LYP'],
'18': ['HYB_GGA_XC_B3PW91'],
'XC_B3PW91': ['HYB_GGA_XC_B3PW91'],
'27': ['MGGA_X_TPSS','MGGA_C_TPSS'],
'XC_TPSS': ['MGGA_X_TPSS','MGGA_C_TPSS'],
'46':['GGA_X_HTBS'],
'XC_HTBS': ['GGA_X_HTBS'],
'47': ['HYB_GGA_XC_B3LYP'],
'XC_B3LYP': ['HYB_GGA_XC_B3LYP'],
# 51: ['-'],
# EX_SLDA:
# VX_SLDA:
# 52: ['-'],
# EX_SPBE:
# VX_SPBE:
# 53: ['-'],
# EX_SWC:
# VX_SWC:
# 54: ['-'],
# EX_SPBESOL:
# VX_SPBESOL:
# 55: ['-'],
# EX_SB88:
# VX_SB88:
'6': ['HF_X'],
'EX_LDA': ['HF_X'],
'VX_LDA': ['HF_X']
}
# Push the functional string into the backend
xc_map_legend = xc_map_legend.get(xc_index[0])
if not xc_map_legend:
raise Exception("Unhandled xc functional %s found" % xc_index)
for xc_name in xc_map_legend:
# for xc_name in xc_map_legend[xc_index]:
s = backend.openSection("section_XC_functionals")
backend.addValue("XC_functional_name", xc_name)
backend.closeSection("section_XC_functionals", s)
# description of the input
def buildIn0Matchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
# SM(name = 'systemName',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"(?P<x_wien2k_switch>\w*)\s*(?P<x_wien2k_indxc>\w*)\s*.*",sections = ['x_wien2k_section_XC']),
SM(r"\s*(?P<x_wien2k_ifft_x>[0-9]+)\s*(?P<x_wien2k_ifft_y>[0-9]+)\s*(?P<x_wien2k_ifft_z>[0-9]+)\s*(?P<x_wien2k_ifft_factor>[0-9.]+)\s*(?P<x_wien2k_iprint>[0-9]+).*")
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in1)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn1Context(object):
"""context for wien2k In1 parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn1Matchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
# SM(name = 'systemName',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\s*(?P<x_wien2k_wf_switch>[\w*]+)\s*EF=[-+.0-9]*\s*\W*WFFIL, WFPRI, ENFIL, SUPWF\W"),
SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*")
# SM(r"(?P<x_wien2k_calc_mode>.*)"),
# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"),
# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True,
# sections=["x_wien2k_section_equiv_atoms"],
# subMatchers=[
# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True
# ),
# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[0-9.]+)",)
# ]
# )
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in1c)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn1cContext(object):
"""context for wien2k In1c parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn1cMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
# SM(name = 'systemName',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\s*(?P<x_wien2k_wf_switch>[\w*]+)\s*EF=[-+.0-9]*\s*\W*WFFIL, WFPRI, ENFIL, SUPWF\W"),
SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*")
# SM(r"(?P<x_wien2k_calc_mode>.*)"),
# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"),
# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True,
# sections=["x_wien2k_section_equiv_atoms"],
# subMatchers=[
# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True
# ),
# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[0-9.]+)",)
# ]
# )
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in2)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn2Context(object):
"""context for wien2k In2 parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn2Matchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
# SM(name = 'systemName',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<x_wien2k_smearing_width__rydberg>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX")
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in2c)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn2cContext(object):
"""context for wien2k In2c parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn2cMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<x_wien2k_smearing_width__rydberg>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX")
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
from builtins import object
from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json, logging
import numpy as np
import ase.geometry
################################################################
# This is the subparser for the main WIEN2k input file (.struct)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kStructContext(object):
"""context for wien2k struct parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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 onClose_section_system(self, backend, gIndex, section):
# unit_cell
unit_cell_params = []
for i in ['a', 'b', 'c']:
uci = section['x_wien2k_unit_cell_param_' + i]
#if uci is not None:
unit_cell_params.append(uci[0])
for i in ['alfa', 'beta', 'gamma']:
uci = section['x_wien2k_angle_between_unit_axis_' + i]
# if uci is not None:
unit_cell_params.append(uci[0])
unit_cell = ase.geometry.cellpar_to_cell(unit_cell_params)
backend.addArrayValues('simulation_cell', unit_cell)
backend.addArrayValues("configuration_periodic_dimensions", np.ones(3, dtype=bool))
equiv_atoms = section["x_wien2k_section_equiv_atoms"]
#logging.error("section: %s", section)
labels = []
pos = []
for eqAtoms in equiv_atoms:
label = eqAtoms["x_wien2k_atom_name"][0]
x = eqAtoms["x_wien2k_atom_pos_x"]
y = eqAtoms["x_wien2k_atom_pos_y"]
z = eqAtoms["x_wien2k_atom_pos_z"]
#logging.error("equiv_atoms: %s x %s y %s z %s",eqAtoms, x, y, z)
if len(x) != len(y) or len(x) != len(z):
raise Exception("incorrect parsing, different number of x,y,z components")
groupPos = [[x[i],y[i],z[i]] for i in range(len(x))]
nAt = len(groupPos)
labels += [label for i in range(nAt)]
pos += groupPos
backend.addValue("atom_labels", labels)
#backend.addArrayValues("atom_positions", np.dot(pos,unit_cell))
#backend.addArrayValues('atom_positions', np.transpose(np.asarray(pos)))
backend.addArrayValues('atom_positions', np.asarray(pos))
# description of the input
def buildStructureMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_system"],
subMatchers = [
SM(name = 'systemName',
startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\w+\s*LATTICE,NONEQUIV\.ATOMS.\s*(?P<x_wien2k_nonequiv_atoms>[0-9]+)"),
SM(r"(?P<x_wien2k_calc_mode>.*)"),
# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<x_wien2k_unit_cell_param_b>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<x_wien2k_unit_cell_param_c>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+0-9.eEdD]{9})\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+0-9.eEdD]{9})\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)"),
SM(r"\s*(?P<x_wien2k_unit_cell_param_a__angstrom>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b__angstrom>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c__angstrom>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"),
SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
repeats=True,
sections=["x_wien2k_section_equiv_atoms"],
subMatchers=[
SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z__angstrom>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
repeats=True
),
# SM(r"\s*(?P<atom>.{10})\s*NPT=\s*(?P<NPT>[0-9]+)\s*R0=(?P<r0>[0-9.]+)\s*RMT=\s*(?P<rmt>[0-9.]+)\s*Z:\s*(?P<z>[0-9.]+)",)
SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[0-9.]+)",)
]
)
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_system': CachingLvl
}
cachingLevelForMetaName["x_wien2k_system_nameIn"] = CachingLevel.ForwardAndCache
cachingLevelForMetaName["x_wien2k_section_equiv_atoms"] = CachingLevel.ForwardAndCache
cachingLevelForMetaName["atom_labels"] = CachingLevel.ForwardAndCache
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
...@@ -687,54 +687,54 @@ class section_method(public.section_method): ...@@ -687,54 +687,54 @@ class section_method(public.section_method):
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_rkmax')) a_legacy=LegacyDefinition(name='x_wien2k_rkmax'))
x_wien2k_in2c_switch = Quantity( x_wien2k_in2_switch = Quantity(
type=str, type=str,
shape=[], shape=[],
description=''' description='''
switch, in in2c between (TOT,FOR,QTL,EFG,ALM,CLM,FERMI) switch, in in2 between (TOT,FOR,QTL,EFG,ALM,CLM,FERMI)
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_switch')) a_legacy=LegacyDefinition(name='x_wien2k_in2_switch'))
x_wien2k_in2c_emin = Quantity( x_wien2k_in2_emin = Quantity(
type=np.dtype(np.float64), type=np.dtype(np.float64),
shape=[], shape=[],
description=''' description='''
lower energy cut-off for defining the range of occupied states; in in2c lower energy cut-off for defining the range of occupied states; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_emin')) a_legacy=LegacyDefinition(name='x_wien2k_in2_emin'))
x_wien2k_in2c_ne = Quantity( x_wien2k_in2_ne = Quantity(
type=np.dtype(np.float64), type=np.dtype(np.float64),
shape=[], shape=[],
description=''' description='''
number of electrons (per unit cell) in given energy range in in2c number of electrons (per unit cell) in given energy range in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_ne')) a_legacy=LegacyDefinition(name='x_wien2k_in2_ne'))
x_wien2k_in2c_espermin = Quantity( x_wien2k_in2_espermin = Quantity(
type=np.dtype(np.float64), type=np.dtype(np.float64),
shape=[], shape=[],
description=''' description='''
LAPW2 tries to find the .mean. energies for each l channel, for both the valence LAPW2 tries to find the .mean. energies for each l channel, for both the valence
and the semicore states. To define .valence. and .semicore. it starts at (EF - and the semicore states. To define .valence. and .semicore. it starts at (EF -
.esepermin.) and searches for a .gap. with a width of at least .eseper0. and .esepermin.) and searches for a .gap. with a width of at least .eseper0. and
defines this as separation energy of valence and semicore; in in2c defines this as separation energy of valence and semicore; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_espermin')) a_legacy=LegacyDefinition(name='x_wien2k_in2_espermin'))
x_wien2k_in2c_esper0 = Quantity( x_wien2k_in2_esper0 = Quantity(
type=np.dtype(np.float64), type=np.dtype(np.float64),
shape=[], shape=[],
description=''' description='''
minimum gap width; in in2c minimum gap width; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_esper0')) a_legacy=LegacyDefinition(name='x_wien2k_in2_esper0'))
x_wien2k_smearing_kind = Quantity( x_wien2k_smearing_kind = Quantity(
type=str, type=str,
shape=[], shape=[],
description=''' description='''
determines how EF is determined; in in2c determines how EF is determined; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_smearing_kind')) a_legacy=LegacyDefinition(name='x_wien2k_smearing_kind'))
...@@ -744,17 +744,17 @@ class section_method(public.section_method): ...@@ -744,17 +744,17 @@ class section_method(public.section_method):
unit='joule', unit='joule',
description=''' description='''
specifies the width of the broadening, if efmod is set to ALL, eval specifies the specifies the width of the broadening, if efmod is set to ALL, eval specifies the
upper limit of the energy window; in in2c upper limit of the energy window; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_smearing_width')) a_legacy=LegacyDefinition(name='x_wien2k_smearing_width'))
x_wien2k_in2c_gmax = Quantity( x_wien2k_in2_gmax = Quantity(
type=np.dtype(np.float64), type=np.dtype(np.float64),
shape=[], shape=[],
description=''' description='''
max. G (magnitude of largest vector) in charge density Fourier expansion; in in2c max. G (magnitude of largest vector) in charge density Fourier expansion; in in2
''', ''',
a_legacy=LegacyDefinition(name='x_wien2k_in2c_gmax')) a_legacy=LegacyDefinition(name='x_wien2k_in2_gmax'))
x_wien2k_section_XC = SubSection( x_wien2k_section_XC = SubSection(
sub_section=SectionProxy('x_wien2k_section_XC'), sub_section=SectionProxy('x_wien2k_section_XC'),
......
...@@ -10,8 +10,6 @@ from nomadcore.simple_parser import SimpleMatcher as SM ...@@ -10,8 +10,6 @@ from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import wien2kparser.wien2k_parser_struct as wien2k_parser_struct import wien2kparser.wien2k_parser_struct as wien2k_parser_struct
import wien2kparser.wien2k_parser_in0 as wien2k_parser_in0 import wien2kparser.wien2k_parser_in0 as wien2k_parser_in0
import wien2kparser.wien2k_parser_in1c as wien2k_parser_in1c
import wien2kparser.wien2k_parser_in2c as wien2k_parser_in2c
import wien2kparser.wien2k_parser_in1 as wien2k_parser_in1 import wien2kparser.wien2k_parser_in1 as wien2k_parser_in1
import wien2kparser.wien2k_parser_in2 as wien2k_parser_in2 import wien2kparser.wien2k_parser_in2 as wien2k_parser_in2
import logging import logging
...@@ -91,32 +89,10 @@ class Wien2kContext(object): ...@@ -91,32 +89,10 @@ class Wien2kContext(object):
subParser.parseFile(fIn) subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in1c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in1c.Wien2kIn1cContext()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in1c.buildIn1cMatchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in1c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in2c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in2c.Wien2kIn2cContext()
subParser = AncillaryParser(
fileDescription = wien2k_parser_in2c.buildIn2cMatchers(),
parser = self.parser,
cachingLevelForMetaName = wien2k_parser_in2c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore),
superContext = subSuperContext)
with open(fName) as fIn:
subParser.parseFile(fIn)
mainFile = self.parser.fIn.fIn.name mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in1" fName = mainFile[:-4] + ".in1"
if not os.path.exists(fName):
fName = mainFile[:-4] + ".in1c"
if os.path.exists(fName): if os.path.exists(fName):
subSuperContext = wien2k_parser_in1.Wien2kIn1Context() subSuperContext = wien2k_parser_in1.Wien2kIn1Context()
subParser = AncillaryParser( subParser = AncillaryParser(
...@@ -130,6 +106,8 @@ class Wien2kContext(object): ...@@ -130,6 +106,8 @@ class Wien2kContext(object):
mainFile = self.parser.fIn.fIn.name mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in2" fName = mainFile[:-4] + ".in2"
if not os.path.exists(fName):
fName = mainFile[:-4] + ".in2c"
if os.path.exists(fName): if os.path.exists(fName):
subSuperContext = wien2k_parser_in2.Wien2kIn2Context() subSuperContext = wien2k_parser_in2.Wien2kIn2Context()
subParser = AncillaryParser( subParser = AncillaryParser(
...@@ -255,10 +233,11 @@ mainFileDescription = SM( ...@@ -255,10 +233,11 @@ mainFileDescription = SM(
SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*(?P<x_wien2k_cutoff>[0-9.]+)\s*Ry\W\W[0-9.]+"), SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*(?P<x_wien2k_cutoff>[0-9.]+)\s*Ry\W\W[0-9.]+"),
SM(r":GAP\s*:\s*(?P<x_wien2k_ene_gap__rydberg>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*.*"), SM(r":GAP\s*:\s*(?P<x_wien2k_ene_gap__rydberg>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*.*"),
SM(r":NOE\s*:\s*NUMBER\sOF\sELECTRONS\s*=\s*(?P<x_wien2k_noe>[0-9.]+)"), SM(r":NOE\s*:\s*NUMBER\sOF\sELECTRONS\s*=\s*(?P<x_wien2k_noe>[0-9.]+)"),
SM(r":FER\s*:\s(\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene__rydberg>[-+0-9.]+)"), SM(r":FER\s*:\sF E R M I -\s\w*\W\w*\WM\W*=\s*(?P<energy_reference_fermi_iteration__rydberg>[-+0-9.]+)"),
SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*[0-9.]+\s*Ry\W\W[0-9.]+"), SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*[0-9.]+\s*Ry\W\W[0-9.]+"),
SM(r":CHA(?P<x_wien2k_atom_nr>[-+0-9]+):\s*TOTAL\s*\w*\s*CHARGE INSIDE SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_val_charge_sphere>[0-9.]+)",repeats = True), SM(r":CHA(?P<x_wien2k_atom_nr>[-+0-9]+):\s*TOTAL\s*\w*\s*CHARGE INSIDE SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_val_charge_sphere>[0-9.]+)",repeats = True),
SM(r":CHA\s*:\s*TOTAL\s*\w*\s*CHARGE INSIDE\s*\w*\s*CELL\s=\s*(?P<x_wien2k_tot_val_charge_cell>[-+0-9.]+)"), SM(r":CHA\s*:\s*TOTAL\s*\w*\s*CHARGE INSIDE\s*\w*\s*CELL\s=\s*(?P<x_wien2k_tot_val_charge_cell>[-+0-9.]+)"),
SM(r":SUM\s*:\s*SUM OF EIGENVALUES\s*=\s*(?P<energy_sum_eigenvalues_scf_iteration__rydberg>[-+0-9.]+)"),
SM(r":MMTOT: TOTAL MAGNETIC MOMENT IN CELL =\s*(?P<x_wien2k_mmtot>[-+0-9.]+)"), SM(r":MMTOT: TOTAL MAGNETIC MOMENT IN CELL =\s*(?P<x_wien2k_mmtot>[-+0-9.]+)"),
SM(r":MMINT: MAGNETIC MOMENT IN INTERSTITIAL =\s*(?P<x_wien2k_mmint>[-+0-9.]+)"), SM(r":MMINT: MAGNETIC MOMENT IN INTERSTITIAL =\s*(?P<x_wien2k_mmint>[-+0-9.]+)"),
SM(r":MMI001: MAGNETIC MOMENT IN SPHERE 1 =\s*(?P<x_wien2k_mmi001>[-+0-9.]+)"), SM(r":MMI001: MAGNETIC MOMENT IN SPHERE 1 =\s*(?P<x_wien2k_mmi001>[-+0-9.]+)"),
...@@ -270,7 +249,7 @@ mainFileDescription = SM( ...@@ -270,7 +249,7 @@ mainFileDescription = SM(
SM(r":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+0-9.]+)"), SM(r":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+0-9.]+)"),
SM(r":CTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere>[-+0-9.]+)",repeats = True), SM(r":CTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere>[-+0-9.]+)",repeats = True),
# SM(r":NEC(?P<x_wien2k_necnr>[-+0-9]+)\s*:\s*NUCLEAR AND ELECTRONIC CHARGE\s*(?P<x_wien2k_nuclear_charge>[-+0-9.]+)\s*(?P<x_wien2k_electronic_charge>[0-9.]+)",repeats = True), # SM(r":NEC(?P<x_wien2k_necnr>[-+0-9]+)\s*:\s*NUCLEAR AND ELECTRONIC CHARGE\s*(?P<x_wien2k_nuclear_charge>[-+0-9.]+)\s*(?P<x_wien2k_electronic_charge>[0-9.]+)",repeats = True),
SM(r":ENE\s*:\s*\W*\w*\W*\s*TOTAL\s*ENERGY\s*IN\s*Ry\s*=\s*(?P<x_wien2k_energy_total__rydberg>[-+0-9.]+)"), SM(r":ENE\s*:\s*\W*\w*\W*\s*TOTAL\s*ENERGY\s*IN\s*Ry\s*=\s*(?P<energy_total_scf_iteration__rydberg>[-+0-9.]+)"),
SM(r":FOR[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_abs>[0-9.]+)\s*(?P<x_wien2k_for_x>[-++0-9.]+)\s*(?P<x_wien2k_for_y>[-+0-9.]+)\s*(?P<x_wien2k_for_z>[-+0-9.]+)\s*partial\sforces", repeats = True), SM(r":FOR[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_abs>[0-9.]+)\s*(?P<x_wien2k_for_x>[-++0-9.]+)\s*(?P<x_wien2k_for_y>[-+0-9.]+)\s*(?P<x_wien2k_for_z>[-+0-9.]+)\s*partial\sforces", repeats = True),
SM(r":FGL[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_x_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_y_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_z_gl>[-+0-9.]+)\s*partial\sforces", repeats = True) SM(r":FGL[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_x_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_y_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_z_gl>[-+0-9.]+)\s*partial\sforces", repeats = True)
] ]
......
from builtins import object
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in1c)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn1cContext(object):
"""context for wien2k In1c parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn1cMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
# SM(name = 'systemName',
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\s*(?P<x_wien2k_wf_switch>[\w*]+)\s*EF=[-+.0-9]*\s*\W*WFFIL, WFPRI, ENFIL, SUPWF\W"),
SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*")
# SM(r"(?P<x_wien2k_calc_mode>.*)"),
# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"),
# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True,
# sections=["x_wien2k_section_equiv_atoms"],
# subMatchers=[
# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Y=(?P<x_wien2k_atom_pos_y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*Z=(?P<x_wien2k_atom_pos_z>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)",
# repeats=True
# ),
# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[0-9.]+)",)
# ]
# )
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
...@@ -58,7 +58,7 @@ def buildIn2Matchers(): ...@@ -58,7 +58,7 @@ def buildIn2Matchers():
# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), # startReStr = r"(?P<x_wien2k_system_nameIn>.*)"),
SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"), SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"), SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<x_wien2k_smearing_width__rydberg>[-+0-9.]+)\s*.*"), SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<smearing_width__rydberg>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX") SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX")
]) ])
......
from builtins import object
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os, sys, json
################################################################
# This is the subparser for the WIEN2k input file (.in2c)
################################################################
# Copyright 2016-2018 Daria M. Tomecka, Fawzi Mohamed
#
# 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.
__author__ = "Daria M. Tomecka"
__maintainer__ = "Daria M. Tomecka"
__email__ = "tomeckadm@gmail.com;"
__date__ = "15/05/2017"
class Wien2kIn2cContext(object):
"""context for wien2k In2c parser"""
def __init__(self):
self.parser = None
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse different files"""
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()
# description of the input
def buildIn2cMatchers():
return SM(
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method"],
subMatchers = [
SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_smearing_kind>[A-Z]+)\s*\s*(?P<x_wien2k_smearing_width__rydberg>[-+0-9.]+)\s*.*"),
SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX")
])
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata.
Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py.
CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
This allows to run the parser without opening new sections.
Returns:
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json