Commit 268e1923 authored by Daria Tomecka's avatar Daria Tomecka
Browse files

wien2k: adding missing metainfo

parent 241ad2b3
......@@ -21,6 +21,10 @@ class Wien2kContext(object):
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"""
......@@ -112,6 +116,75 @@ class Wien2kContext(object):
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 onOpen_section_system(self, backend, gIndex, section):
#if self.secSystemIndex is None:
self.secSystemIndex = gIndex
# self.secSystemIndex["single_configuration_calculation_to_system_ref"] = gIndex
def onClose_section_system(self, backend, gIndex, section):
#backend.addValue("smearing_kind", x_fleur_smearing_kind)
smear_kind = section['x_wien2k_smearing_kind']
if smear_kind is not None:
# value = ''
backend.addValue('x_wien2k_smearing_kind', value)
smear_width = section['x_wien2k_smearing_width']
if smear_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)))
# unit_cell
unit_cell = []
for i in ['a', 'b', 'c']:
uci = section['x_wien2k_unit_cell_param_' + i]
if uci is not None:
unit_cell.append(uci)
if unit_cell:
backend.addArrayValues('simulation_cell', np.asarray(unit_cell))
backend.addArrayValues("configuration_periodic_dimensions", np.ones(3, dtype=bool))
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',
......@@ -170,6 +243,16 @@ mainFileDescription = SM(
)
])
# 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 = {
......
......@@ -13,7 +13,7 @@ import os, sys, json
class Wien2kIn0Context(object):
"""context for wien2k struct parser"""
"""context for wien2k In0 parser"""
def __init__(self):
self.parser = None
......@@ -28,118 +28,123 @@ class Wien2kIn0Context(object):
# 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]
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:
def onClose_x_wien2k_section_XC(self, backend, gIndex, section):
xc_index = section["x_wien2k_indxc"] #[0]
if not xc_index:
functional = "XC_PBE"
if functional:
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'],
# 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 = functionalMap.get(indxc)
# if not xc_map_legend:
# raise Exception("Unhandled xc functional %s found" % functional)
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)
# 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(functional)
if not xc_map_legend:
raise Exception("Unhandled xc functional %s found" % functional)
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 = "",
name = 'root',
weak = True,
startReStr = "",
sections = ["section_run", "section_method", "section_XC_functionals"],
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]+).*")
])
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.
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.
Dictionary with metaname as key and caching level as value.
"""
# manually adjust caching of metadata
cachingLevelForMetaName = {
'section_run': CachingLvl,
'section_method': CachingLvl
}
'section_run': CachingLvl,
'section_method': CachingLvl
}
return cachingLevelForMetaName
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
......@@ -12,7 +12,7 @@ import os, sys, json
class Wien2kIn1Context(object):
"""context for wien2k struct parser"""
"""context for wien2k In1 parser"""
def __init__(self):
self.parser = None
......
......@@ -12,7 +12,7 @@ import os, sys, json
class Wien2kIn1cContext(object):
"""context for wien2k struct parser"""
"""context for wien2k In1c parser"""
def __init__(self):
self.parser = None
......
......@@ -12,7 +12,7 @@ import os, sys, json
class Wien2kIn2Context(object):
"""context for wien2k struct parser"""
"""context for wien2k In2 parser"""
def __init__(self):
self.parser = None
......
......@@ -12,7 +12,7 @@ import os, sys, json
class Wien2kIn2cContext(object):
"""context for wien2k struct parser"""
"""context for wien2k In2c parser"""
def __init__(self):
self.parser = None
......
......@@ -46,8 +46,23 @@ class Wien2kStructContext(object):
pos += groupPos
backend.addValue("atom_labels", labels)
backend.addValue("atom_positions", pos)
##OR
"""
# atom_positions
atom_pos = []
for i in ['x', 'y', 'z']:
api = section['x_wien2k_atom_pos_' + i]
if api is not None:
atom_pos.append(api)
if atom_pos:
# need to transpose array since its shape is [number_of_atoms,3] in the metadata
backend.addArrayValues('atom_positions', np.transpose(np.asarray(atom_pos)))
# atom labels
atom_labels = section['x_wien2k_atom_name']
if atom_labels is not None:
backend.addArrayValues('atom_labels', np.asarray(atom_labels))
"""
# description of the input
def buildStructureMatchers():
return SM(
......@@ -93,6 +108,7 @@ def get_cachingLevelForMetaName(metaInfoEnv, 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
Supports Markdown
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