diff --git a/parser/parser-atk/libxc_names.py b/parser/parser-atk/libxc_names.py index 3a783201e0cf35985b216876ee6a59615cd2759a..00dec81db42ac5f42748f9be8ac1348a1ca7671d 100644 --- a/parser/parser-atk/libxc_names.py +++ b/parser/parser-atk/libxc_names.py @@ -1,4 +1,7 @@ from __future__ import print_function +import re +p = re.compile( + '((?P<x_name>(GGA|LDA|MGGA|HF|HYB_MGGA)_X.*)|(?P<c_name>(GGA|LDA|MGGA)_C.*))') short_names = { 'LDA.RPA': 'LDA_X+LDA_C_RPA', @@ -27,6 +30,36 @@ def get_libxc_name(name): return libxc_name +def get_libxc_xc_names(name): + """get dictionary with + x_name: Exchange name (None if xc_name is not None) + c_name: Correlation name (-||-) + xc_name: XC name + """ + name = get_libxc_name(name) + xc = {'xc_name': None, + 'x_name' : None, + 'c_name': None} + + if '_XC_' in name: + xc['xc_name'] = name + return xc + + if '+' in name: + s = name.split('+') + xc['x_name'] = s[0] + xc['c_name'] = s[1] + return xc + + m = re.search(p, name) + if m is not None: # it is either a correlation or exchange functional + xc.update(m.groupdict()) + return xc + + xc['xc_name'] = name # for something like BEEF-vdW + return xc + + if __name__ == '__main__': - print(get_libxc_name('LDA')) - print(get_libxc_name('GGA_X_PBE')) + print(get_libxc_xc_names('LDA.PZ')) + #print(get_libxc_name('GGA_X_PBE')) diff --git a/parser/parser-atk/parser_atk.py b/parser/parser-atk/parser_atk.py index bb4ac072164f357d1920db8550574ac27a84d77b..376ce5c5cab9176a6c6acd70ca92b5aeab914f1e 100644 --- a/parser/parser-atk/parser_atk.py +++ b/parser/parser-atk/parser_atk.py @@ -10,7 +10,7 @@ import setup_paths from nomadcore.unit_conversion.unit_conversion import convert_unit as cu from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.parser_backend import JsonParseEventsWriterBackend -from libxc_names import get_libxc_name +from libxc_names import get_libxc_xc_names @contextmanager @@ -87,8 +87,14 @@ def parse(filename): electron_temperature, 'K')) p.addRealValue('total_charge', r.c.charge) with o(p, 'section_XC_functionals'): - p.addValue('XC_functional_name', - get_libxc_name(r.c.exchange_correlation)) + xc = get_libxc_xc_names(r.c.exchange_correlation) + if xc['xc_name'] is not None: + p.addValue('XC_functional_name', xc['xc_name']) + if xc['x_name'] is not None: + p.addValue('XC_functional_name', xc['x_name']) + if xc['c_name'] is not None: + p.addValue('XC_functional_name', xc['c_name']) + with o(p, 'section_single_configuration_calculation'): p.addValue('single_configuration_calculation_to_system_ref', system_gid)