Commit f4500614 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added more parsers to NOMAD

parent 11e8b765
......@@ -55,3 +55,5 @@ TAGS
lib/
env/
*.egg-info/*
\ No newline at end of file
......@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import setup_paths
import calendar
import json
import os
......@@ -53,13 +52,13 @@ def re_vec(name, units='', split="\s+"):
# loading metadata from
# nomad-meta-info/meta_info/nomad_meta_info/fplo.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/fplo.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/fplo.nomadmetainfo.json")),
# dependencyLoader=None,
# extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
# uri=None)[0]
PARSER_INFO_DEFAULT = {
"name": "parser_fplo",
......
......@@ -25,15 +25,13 @@ This module is implemented as follows:
TODO:
4) transform AST to metaInfo backend calls
"""
import setup_paths
import re
import sys
import os
import logging
import json
import FploCommon as FploC
from . import FploCommon as FploC
from nomadcore.match_highlighter import ANSI
from nomadcore.parser_backend import JsonParseEventsWriterBackend
from nomadcore.caching_backend import CachingLevel, ActiveBackend
LOGGER = logging.getLogger(__name__)
......
from .parser_fplo_14 import FploParser
\ No newline at end of file
import sys
from nomad.metainfo import Environment
from nomad.metainfo.legacy import LegacyMetainfoEnvironment
import fploparser.metainfo.fplo
import nomad.datamodel.metainfo.common
import nomad.datamodel.metainfo.public
import nomad.datamodel.metainfo.general
import fploparser.metainfo.fplo_temporaries
import fploparser.metainfo.fplo_input_autogenerated
m_env = LegacyMetainfoEnvironment()
m_env.m_add_sub_section(Environment.packages, sys.modules['fploparser.metainfo.fplo'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.common'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.public'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['nomad.datamodel.metainfo.general'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['fploparser.metainfo.fplo_temporaries'].m_package) # type: ignore
m_env.m_add_sub_section(Environment.packages, sys.modules['fploparser.metainfo.fplo_input_autogenerated'].m_package) # type: ignore
import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import
from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference
)
from nomad.metainfo.legacy import LegacyDefinition
from nomad.datamodel.metainfo import public
from nomad.datamodel.metainfo import common
m_package = Package(
name='fplo_nomadmetainfo_json',
description='None',
a_legacy=LegacyDefinition(name='fplo.nomadmetainfo.json'))
class section_run(public.section_run):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_run'))
x_fplo_program_version_sub = Quantity(
type=str,
shape=[],
description='''
FPLO sub version
''',
a_legacy=LegacyDefinition(name='x_fplo_program_version_sub'))
x_fplo_program_compilation_options = Quantity(
type=str,
shape=[],
description='''
FPLO compilation options
''',
a_legacy=LegacyDefinition(name='x_fplo_program_compilation_options'))
class section_system(public.section_system):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_system'))
x_fplo_reciprocal_cell = Quantity(
type=np.dtype(np.float64),
shape=[3, 3],
unit='1 / meter',
description='''
Reciprocal Lattice vectors (in Cartesian coordinates). The first index runs over
the $x,y,z$ Cartesian coordinates, and the second index runs over the 3 lattice
vectors.
''',
categories=[public.configuration_core],
a_legacy=LegacyDefinition(name='x_fplo_reciprocal_cell'))
x_fplo_atom_idx = Quantity(
type=np.dtype(np.int32),
shape=['number_of_atoms'],
description='''
FPLO-internal index for each atom
''',
a_legacy=LegacyDefinition(name='x_fplo_atom_idx'))
x_fplo_atom_wyckoff_idx = Quantity(
type=np.dtype(np.int32),
shape=['number_of_atoms'],
description='''
Wyckoff position index of each atom
''',
a_legacy=LegacyDefinition(name='x_fplo_atom_wyckoff_idx'))
x_fplo_atom_cpa_block = Quantity(
type=np.dtype(np.int32),
shape=['number_of_atoms'],
description='''
CPA block of each atom
''',
a_legacy=LegacyDefinition(name='x_fplo_atom_cpa_block'))
x_fplo_structure_type = Quantity(
type=str,
shape=[],
description='''
FPLO structure type: Crystal/Molecule
''',
a_legacy=LegacyDefinition(name='x_fplo_structure_type'))
class section_method(public.section_method):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_method'))
x_fplo_xc_functional_number = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
FPLO number xc functional
''',
a_legacy=LegacyDefinition(name='x_fplo_xc_functional_number'))
x_fplo_xc_functional = Quantity(
type=str,
shape=[],
description='''
FPLO notation of xc functional
''',
a_legacy=LegacyDefinition(name='x_fplo_xc_functional'))
x_fplo_dft_plus_u_projection_type = Quantity(
type=str,
shape=[],
description='''
FPLO notation of DFT+U projection
''',
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_projection_type'))
x_fplo_dft_plus_u_functional = Quantity(
type=str,
shape=[],
description='''
FPLO notation of DFT+U functional
''',
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_functional'))
class section_dft_plus_u_orbital(common.section_dft_plus_u_orbital):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_dft_plus_u_orbital'))
x_fplo_dft_plus_u_orbital_element = Quantity(
type=str,
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: element
''',
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_element'))
x_fplo_dft_plus_u_orbital_species = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: species index
''',
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_species'))
x_fplo_dft_plus_u_orbital_F0 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: value F0
''',
categories=[public.energy_value],
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_F0'))
x_fplo_dft_plus_u_orbital_F2 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: value F2
''',
categories=[public.energy_value],
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_F2'))
x_fplo_dft_plus_u_orbital_F4 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: value F4
''',
categories=[public.energy_value],
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_F4'))
x_fplo_dft_plus_u_orbital_F6 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
FPLO: Atom/Orbital dependent DFT+U property: value F6
''',
categories=[public.energy_value],
a_legacy=LegacyDefinition(name='x_fplo_dft_plus_u_orbital_F6'))
m_package.__init_metainfo__()
This diff is collapsed.
import numpy as np # pylint: disable=unused-import
import typing # pylint: disable=unused-import
from nomad.metainfo import ( # pylint: disable=unused-import
MSection, MCategory, Category, Package, Quantity, Section, SubSection, SectionProxy,
Reference
)
from nomad.metainfo.legacy import LegacyDefinition
from nomad.datamodel.metainfo import public
m_package = Package(
name='fplo_temporaries_nomadmetainfo_json',
description='None',
a_legacy=LegacyDefinition(name='fplo.temporaries.nomadmetainfo.json'))
class section_run(public.section_run):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_run'))
x_fplo_t_program_version_main = Quantity(
type=str,
shape=[],
description='''
temporary: FPLO main version
''',
a_legacy=LegacyDefinition(name='x_fplo_t_program_version_main'))
x_fplo_t_program_version_release = Quantity(
type=str,
shape=[],
description='''
temporary: FPLO release number
''',
a_legacy=LegacyDefinition(name='x_fplo_t_program_version_release'))
x_fplo_t_run_hosts = Quantity(
type=str,
shape=[],
description='''
temporary: FPLO run hosts
''',
a_legacy=LegacyDefinition(name='x_fplo_t_run_hosts'))
class section_system(public.section_system):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_system'))
x_fplo_t_vec_a_x = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for direct lattice vectors, x-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_a_x'))
x_fplo_t_vec_a_y = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for direct lattice vectors, y-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_a_y'))
x_fplo_t_vec_a_z = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for direct lattice vectors, z-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_a_z'))
x_fplo_t_vec_b_x = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for reciprocal lattice vectors, x-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_b_x'))
x_fplo_t_vec_b_y = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for reciprocal lattice vectors, y-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_b_y'))
x_fplo_t_vec_b_z = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for reciprocal lattice vectors, z-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_vec_b_z'))
x_fplo_t_atom_positions_x = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for atom positions, x-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_positions_x'))
x_fplo_t_atom_positions_y = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for atom positions, y-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_positions_y'))
x_fplo_t_atom_positions_z = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for atom positions, z-component
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_positions_z'))
x_fplo_t_atom_idx = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO atom index
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_idx'))
x_fplo_t_atom_labels = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO atom labels
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_labels'))
x_fplo_t_atom_wyckoff_idx = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO Wyckoff position index of each atom
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_wyckoff_idx'))
x_fplo_t_atom_cpa_block = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO CPA block of each atom
''',
a_legacy=LegacyDefinition(name='x_fplo_t_atom_cpa_block'))
class section_method(public.section_method):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_method'))
x_fplo_t_relativity_method = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO relativistic method
''',
a_legacy=LegacyDefinition(name='x_fplo_t_relativity_method'))
x_fplo_t_dft_plus_u_species_subshell_species = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U species
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_species'))
x_fplo_t_dft_plus_u_species_subshell_element = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U element
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_element'))
x_fplo_t_dft_plus_u_species_subshell_subshell = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U (n,l)subshell
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_subshell'))
x_fplo_t_dft_plus_u_species_subshell_F0 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U F0
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_F0'))
x_fplo_t_dft_plus_u_species_subshell_F2 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U F2
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_F2'))
x_fplo_t_dft_plus_u_species_subshell_F4 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U F4
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_F4'))
x_fplo_t_dft_plus_u_species_subshell_F6 = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U F6
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_F6'))
x_fplo_t_dft_plus_u_species_subshell_U = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U U
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_U'))
x_fplo_t_dft_plus_u_species_subshell_J = Quantity(
type=np.dtype(np.float64),
shape=[],
description='''
Temporary storage for FPLO per species/(n,l)subshell DFT+U J
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_species_subshell_J'))
x_fplo_t_dft_plus_u_site_index = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO per site DFT+U index
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_index'))
x_fplo_t_dft_plus_u_site_element = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO per site DFT+U element
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_element'))
x_fplo_t_dft_plus_u_site_species = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO per site DFT+U species
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_species'))
x_fplo_t_dft_plus_u_site_subshell = Quantity(
type=str,
shape=[],
description='''
Temporary storage for FPLO per site DFT+U (n,l)subshell
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_subshell'))
x_fplo_t_dft_plus_u_site_ubi1 = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO per site DFT+U ubi1
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_ubi1'))
x_fplo_t_dft_plus_u_site_ubi2 = Quantity(
type=np.dtype(np.int32),
shape=[],
description='''
Temporary storage for FPLO per site DFT+U ubi2
''',
a_legacy=LegacyDefinition(name='x_fplo_t_dft_plus_u_site_ubi2'))
class section_scf_iteration(public.section_scf_iteration):
m_def = Section(validate=False, extends_base_section=True, a_legacy=LegacyDefinition(name='section_scf_iteration'))
x_fplo_t_energy_reference_fermi_iteration = Quantity(
type=np.dtype(np.float64),
shape=[],
unit='joule',
description='''
Temporary storage for FPLO Fermi energy in iteration
''',
categories=[public.energy_type_reference, public.energy_value],
a_legacy=LegacyDefinition(name='x_fplo_t_energy_reference_fermi_iteration'))
m_package.__init_metainfo__()
......@@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import setup_paths
from nomadcore.simple_parser import mainFunction, SimpleMatcher as SM, CachingLevel
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
import os
......@@ -24,12 +23,12 @@ import logging
import nomadcore.unit_conversion.unit_conversion as unit_conversion
import math
import numpy as np
import FploCommon as FploC
from . import FploCommon as FploC
import calendar
from nomadcore.parser_backend import valueForStrValue
from FploCommon import RE_f, RE_i, cRE_f, cRE_i
from .FploCommon import RE_f, RE_i, cRE_f, cRE_i
from nomadcore.parser_backend import valueForStrValue
import FploInputParser
from . import FploInputParser
LOGGER = logging.getLogger(__name__)
......@@ -77,10 +76,10 @@ FPLO_DFT_PLUS_U_FUNCTIONAL = {
class ParserFplo14(object):
"""main place to keep the parser status, open ancillary files,..."""
def __init__(self):
def __init__(self, metaInfoEnv):
self.parserInfo = FploC.PARSER_INFO_DEFAULT.copy()
self.cachingLevelForMetaName = {}
for name in FploC.META_INFO.infoKinds:
for name in metaInfoEnv.infoKinds:
# set all temporaries to caching-only
if name.startswith('x_fplo_t_'):
self.cachingLevelForMetaName[name] = CachingLevel.Cache
......@@ -98,7 +97,7 @@ class ParserFplo14(object):
def parse(self):
self.coverageIgnore = re.compile(r"^(?:" + r"|".join(self.coverageIgnoreList) + r")$")
mainFunction(self.mainFileDescription(), FploC.META_INFO, self.parserInfo,
mainFunction(self.mainFileDescription(), metaInfoEnv, self.parserInfo,
cachingLevelForMetaName=self.cachingLevelForMetaName,
superContext=self)
......@@ -695,6 +694,27 @@ class ParserFplo14(object):
backend.addValue(key, value)
backend.closeSection(section_name, gIndex)
if __name__ == "__main__":
parser = ParserFplo14()