Commit 45edbd90 authored by Popov, Igor (igop)'s avatar Popov, Igor (igop)
Browse files

Adopting wien2k parser to NOMAD-FAIR

parent f768736e
...@@ -52,3 +52,6 @@ TAGS ...@@ -52,3 +52,6 @@ TAGS
lib/ lib/
env/ env/
*egg-info
from wien2kparser.wien2k_parser import Wien2kParser
\ No newline at end of file
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
import numpy as np import numpy as np
from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM 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 os, sys, json, logging import os, sys, json, logging
import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2 from wien2kparser import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2
################################################################ ################################################################
...@@ -164,8 +164,8 @@ class Wien2kContext(object): ...@@ -164,8 +164,8 @@ class Wien2kContext(object):
atom_labels = section['x_wien2k_atom_name'] atom_labels = section['x_wien2k_atom_name']
if atom_labels is not None: if atom_labels is not None:
backend.addArrayValues('atom_labels', np.asarray(atom_labels)) backend.addArrayValues('atom_labels', np.asarray(atom_labels))
# atom force # atom force
atom_force = [] atom_force = []
for i in ['x', 'y', 'z']: for i in ['x', 'y', 'z']:
...@@ -193,7 +193,7 @@ class Wien2kContext(object): ...@@ -193,7 +193,7 @@ class Wien2kContext(object):
def onClose_section_scf_iteration(self, backend, gIndex, section): def onClose_section_scf_iteration(self, backend, gIndex, section):
#Trigger called when section_scf_iteration is closed. #Trigger called when section_scf_iteration is closed.
# count number of SCF iterations # count number of SCF iterations
self.scfIterNr += 1 self.scfIterNr += 1
...@@ -264,7 +264,7 @@ cachingLevelForMetaName = { ...@@ -264,7 +264,7 @@ cachingLevelForMetaName = {
"XC_functional_name": CachingLevel.ForwardAndCache, "XC_functional_name": CachingLevel.ForwardAndCache,
"energy_total": CachingLevel.ForwardAndCache "energy_total": CachingLevel.ForwardAndCache
} }
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json # loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
...@@ -277,6 +277,36 @@ parserInfo = { ...@@ -277,6 +277,36 @@ parserInfo = {
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")) 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) 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__": if __name__ == "__main__":
superContext = Wien2kContext() superContext = Wien2kContext()
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext) mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext)
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
...@@ -88,7 +88,7 @@ class Wien2kIn0Context(object): ...@@ -88,7 +88,7 @@ class Wien2kIn0Context(object):
'XC_TPSS': ['MGGA_X_TPSS','MGGA_C_TPSS'], 'XC_TPSS': ['MGGA_X_TPSS','MGGA_C_TPSS'],
'46':['GGA_X_HTBS'], '46':['GGA_X_HTBS'],
'XC_HTBS': ['GGA_X_HTBS'], 'XC_HTBS': ['GGA_X_HTBS'],
'47': ['HYB_GGA_XC_B3LYP'], '47': ['HYB_GGA_XC_B3LYP'],
'XC_B3LYP': ['HYB_GGA_XC_B3LYP'], 'XC_B3LYP': ['HYB_GGA_XC_B3LYP'],
...@@ -99,15 +99,15 @@ class Wien2kIn0Context(object): ...@@ -99,15 +99,15 @@ class Wien2kIn0Context(object):
# VX_SLDA: # VX_SLDA:
# 52: ['-'], # 52: ['-'],
# EX_SPBE: # EX_SPBE:
# VX_SPBE: # VX_SPBE:
# 53: ['-'], # 53: ['-'],
# EX_SWC: # EX_SWC:
# VX_SWC: # VX_SWC:
# 54: ['-'], # 54: ['-'],
# EX_SPBESOL: # EX_SPBESOL:
# VX_SPBESOL: # VX_SPBESOL:
# 55: ['-'], # 55: ['-'],
...@@ -149,7 +149,7 @@ def buildIn0Matchers(): ...@@ -149,7 +149,7 @@ def buildIn0Matchers():
def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl): def get_cachingLevelForMetaName(metaInfoEnv, CachingLvl):
"""Sets the caching level for the metadata. """Sets the caching level for the metadata.
Args: Args:
metaInfoEnv: metadata which is an object of the class InfoKindEnv in nomadcore.local_meta_info.py. 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. CachingLvl: Sets the CachingLevel for the sections k_band, run, and single_configuration_calculation.
......
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object from builtins import object
import setup_paths from wien2kparser import setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
# Copyright 2015-2018 Lorenzo Pardini
#
# 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.
from setuptools import setup, find_packages
def main():
setup(
name='wien2kparser',
version='0.1',
description='NOMAD parser implementation for Wien2k.',
license='APACHE 2.0',
package_dir={'': 'parser'},
packages=find_packages('parser'),
install_requires=[
'nomadcore'
],
)
if __name__ == '__main__':
main()
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