Commit 9b436f9e authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Applied patches provided by Pavel Ondračka

parent 01958ae4
......@@ -687,54 +687,54 @@ class section_method(public.section_method):
''',
a_legacy=LegacyDefinition(name='x_wien2k_rkmax'))
x_wien2k_in2c_switch = Quantity(
x_wien2k_in2_switch = Quantity(
type=str,
shape=[],
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),
shape=[],
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),
shape=[],
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),
shape=[],
description='''
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 -
.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),
shape=[],
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(
type=str,
shape=[],
description='''
determines how EF is determined; in in2c
determines how EF is determined; in in2
''',
a_legacy=LegacyDefinition(name='x_wien2k_smearing_kind'))
......@@ -744,17 +744,17 @@ class section_method(public.section_method):
unit='joule',
description='''
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'))
x_wien2k_in2c_gmax = Quantity(
x_wien2k_in2_gmax = Quantity(
type=np.dtype(np.float64),
shape=[],
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(
sub_section=SectionProxy('x_wien2k_section_XC'),
......
......@@ -10,8 +10,6 @@ from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import wien2kparser.wien2k_parser_struct as wien2k_parser_struct
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_in2 as wien2k_parser_in2
import logging
......@@ -91,32 +89,10 @@ class Wien2kContext(object):
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 not os.path.exists(fName):
fName = mainFile[:-4] + ".in1c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in1.Wien2kIn1Context()
subParser = AncillaryParser(
......@@ -130,6 +106,8 @@ class Wien2kContext(object):
mainFile = self.parser.fIn.fIn.name
fName = mainFile[:-4] + ".in2"
if not os.path.exists(fName):
fName = mainFile[:-4] + ".in2c"
if os.path.exists(fName):
subSuperContext = wien2k_parser_in2.Wien2kIn2Context()
subParser = AncillaryParser(
......@@ -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":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":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":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":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":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.]+)"),
......@@ -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(?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":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":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():
# 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_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")
])
......
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
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