Commit acdd533b authored by Daniel Speckhard's avatar Daniel Speckhard
Browse files

Modified Quantum Espresso for Nomad-FAIRD.

parent f07c7190
import setup_paths
import quantumespressoparser.setup_paths as setup_paths
import calendar
import json
import os
import sys
import re
import numpy as np
import logging
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
from nomadcore.unit_conversion.unit_conversion import convert_unit
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM, CachingLevel
from nomadcore.baseclasses import ParserInterface
############################################################
# This file contains functions and constants that are needed
......@@ -39,13 +41,18 @@ def re_vec(name, units='', split="\s+"):
# loading metadata from
# nomad-meta-info/meta_info/nomad_meta_info/quantum_espresso.nomadmetainfo.json
META_INFO = loadJsonFile(
filePath=os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"../../../../nomad-meta-info/meta_info/nomad_meta_info/quantum_espresso.nomadmetainfo.json")),
dependencyLoader=None,
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None)[0]
# META_INFO = loadJsonFile(
# filePath=os.path.normpath(os.path.join(
# os.path.dirname(os.path.abspath(__file__)),
# "../../../../nomad-meta-info/meta_info/nomad_meta_info/quantum_espresso.nomadmetainfo.json")),
# dependencyLoader=None,
# extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
# uri=None)[0]
import nomad_meta_info
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(nomad_meta_info.__file__)), "quantum_espresso.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
META_INFO = metaInfoEnv
PARSER_INFO_DEFAULT = {
"name": "parser_quantum_espresso",
......@@ -71,13 +78,17 @@ QE_SMEARING_KIND = {
}
class ParserQuantumEspresso(object):
class ParserQuantumEspresso():
"""Base class for all Quantum Espresso parsers"""
def __init__(self,cachingLevelForMetaName=None, coverageIgnoreList=None,
re_program_name=None):
def __init__(
self, cachingLevelForMetaName=None, coverageIgnoreList=None,
re_program_name=None, metainfo_to_keep=None, backend=None, default_units=None,
metainfo_units=None, debug=True, log_level=logging.ERROR, store=True):
self.re_program_name = re_program_name
self.parserInfo = PARSER_INFO_DEFAULT.copy()
self.cachingLevelForMetaName = {}
self.backend = backend
for name in META_INFO.infoKinds:
# set all temporaries to caching-only
if name.startswith('x_qe_t_'):
......@@ -92,11 +103,30 @@ class ParserQuantumEspresso(object):
]
self.coverageIgnore = None
def parse(self):
# Old parser definition pre-Nomad-Fair (dts edit 11/02/2019)
# def parse(self):
# self.coverageIgnore = re.compile(r"^(?:" + r"|".join(self.coverageIgnoreList) + r")$")
# mainFunction(self.mainFileDescription(), META_INFO, self.parserInfo,
# cachingLevelForMetaName=self.cachingLevelForMetaName,
# superContext=self)
def parse(self, mainfile):
self.coverageIgnore = re.compile(r"^(?:" + r"|".join(self.coverageIgnoreList) + r")$")
mainFunction(self.mainFileDescription(), META_INFO, self.parserInfo,
cachingLevelForMetaName=self.cachingLevelForMetaName,
superContext=self)
logging.info('quantum espresso parser started')
logging.getLogger('nomadcore').setLevel(logging.WARNING)
backend = self.backend(META_INFO)
# print("Main File Description in parse()")
# print(self.mainFileDescription())
# with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]):
mainFunction(
self.mainFileDescription(),
META_INFO,
self.parserInfo,
cachingLevelForMetaName=self.cachingLevelForMetaName,
superContext=self,
superBackend=backend,
mainFile=mainfile)
return backend
def adHoc_suicide_qe_program_name(self, parser):
if self.re_program_name is not None:
......@@ -155,6 +185,7 @@ class ParserQuantumEspresso(object):
SM(name='copyright_msg040', coverageIgnore=True,
startReStr=r"\s*in publications or presentations arising from this work. More details at",
),
# Changed CI to False
SM(name='copyright_msg050', coverageIgnore=True,
startReStr=r"\s*http://www.quantum-espresso.org/quote(?:\.php)?",
),
......@@ -250,4 +281,4 @@ class ParserQuantumEspresso(object):
def addSectionDict(self, backend, section_name, section_dict):
gIndex = backend.openSection(section_name)
self.addDict(backend, section_dict)
backend.closeSection(section_name, gIndex)
backend.closeSection(section_name, gIndex)
\ No newline at end of file
# Copyright 2016-2018 Lauri Himanen, Fawzi Mohamed, Ankit Kariryaa
#
# 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 quantumespressoparser.parser_quantum_espresso import QuantumEspressoParserPWSCF
import setup_paths
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os
......@@ -9,10 +8,11 @@ import logging
import nomadcore.unit_conversion.unit_conversion as unit_conversion
import math
import numpy as np
import QuantumEspressoCommon as QeC
import quantumespressoparser.setup_paths as quantumespressoparser
import quantumespressoparser.QuantumEspressoCommon as QeC
from nomadcore.parser_backend import valueForStrValue
from QuantumEspressoCommon import RE_f, RE_i, cRE_f, cRE_i
from QuantumEspressoXC import translate_qe_xc_num
from quantumespressoparser.QuantumEspressoCommon import RE_f, RE_i, cRE_f, cRE_i
from quantumespressoparser.QuantumEspressoXC import translate_qe_xc_num
from nomadcore.parser_backend import valueForStrValue
......@@ -48,9 +48,12 @@ QE_MD_RELAX_SAMPLING_METHOD = {
class QuantumEspressoParserPWSCF(QeC.ParserQuantumEspresso):
"""main place to keep the parser status, open ancillary files,..."""
def __init__(self):
def __init__(self, metainfo_to_keep=None, backend=None, default_units=None,
metainfo_units=None, debug=True, log_level=logging.ERROR, store=True):
QeC.ParserQuantumEspresso.__init__(
self, re_program_name=re.compile(r"^PWSCF$"))
self, re_program_name=re.compile(r"^PWSCF$"), metainfo_to_keep=metainfo_to_keep,
backend=backend, default_units=default_units, metainfo_units=metainfo_units,
debug=debug, log_level=log_level, store=store)
def initialize_values(self):
"""allows to reset values if the same superContext is used to parse
......
Metadata-Version: 1.0
Name: quntumespressoparser
Version: 0.1
Summary: NOMAD parser implementation for QuantumEspresso.
Home-page: UNKNOWN
Author: Glaweh@debian.org
Author-email: dts@physik.hu-berlin.de
License: GPL3
Description: UNKNOWN
Platform: UNKNOWN
README.md
setup.py
./quantumespressoparser/FortranNamelistParser.py
./quantumespressoparser/QuantumEspressoCommon.py
./quantumespressoparser/QuantumEspressoXC.py
./quantumespressoparser/__init__.py
./quantumespressoparser/parser_quantum_espresso.py
./quantumespressoparser/setup_paths.py
./quntumespressoparser.egg-info/PKG-INFO
./quntumespressoparser.egg-info/SOURCES.txt
./quntumespressoparser.egg-info/dependency_links.txt
./quntumespressoparser.egg-info/requires.txt
./quntumespressoparser.egg-info/top_level.txt
\ No newline at end of file
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