From 241ad2b31fab23809aaea1a1448a1582806234f2 Mon Sep 17 00:00:00 2001 From: Daria Tomecka <zarvok79@yahoo.com> Date: Tue, 6 Sep 2016 23:20:33 +0200 Subject: [PATCH] wien2k: cleanup --- parser/parser-wien2k/wien2k_parser.py | 2 +- .../wien2k_parser_backups/setup_paths.py | 6 - .../wien2k.nomadmetainfo.json | 439 ------------------ .../wien2k.nomadmetainfo_old.json | 132 ------ .../wien2k_parser_backups/wien2k_parser.py | 175 ------- .../wien2k_parser_in0.py | 69 --- .../wien2k_parser_in1.py | 69 --- .../wien2k_parser_in1c.py | 69 --- .../wien2k_parser_in2.py | 69 --- .../wien2k_parser_in2c.py | 57 --- .../wien2k_parser_old.py | 90 ---- .../wien2k_parser_struct.py | 92 ---- .../wien2k_parser_struct_old.py | 66 --- 13 files changed, 1 insertion(+), 1334 deletions(-) delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/setup_paths.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in0.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1c.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2c.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py delete mode 100644 parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct_old.py diff --git a/parser/parser-wien2k/wien2k_parser.py b/parser/parser-wien2k/wien2k_parser.py index 76e8eb6..5fd941e 100644 --- a/parser/parser-wien2k/wien2k_parser.py +++ b/parser/parser-wien2k/wien2k_parser.py @@ -8,7 +8,7 @@ import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_pars ################################################################ -# This is the parser for the main output file (.scp) of WIEN2k. +# This is the parser for the main output file (.scf) of WIEN2k. ################################################################ diff --git a/parser/parser-wien2k/wien2k_parser_backups/setup_paths.py b/parser/parser-wien2k/wien2k_parser_backups/setup_paths.py deleted file mode 100644 index e0a0fb0..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/setup_paths.py +++ /dev/null @@ -1,6 +0,0 @@ -import sys, os, os.path -baseDir = os.path.dirname(os.path.abspath(__file__)) -commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python")) - -if not commonDir in sys.path: - sys.path.insert(0, commonDir) diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json deleted file mode 100644 index fcc98fa..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json +++ /dev/null @@ -1,439 +0,0 @@ -{ - "type": "nomad_meta_info_1_0", - "description": "meta info used by the wien2k parser. All names are expected to start with x_wien2k_", - "dependencies": [ { - "relativePath": "common.nomadmetainfo.json" - }, { - "relativePath": "meta_types.nomadmetainfo.json" - }], - "metaInfos": [ { - "description": "position of atom x in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_x", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "position of atom y in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_y", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "position of atom z in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_z", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - },{ - "description": "name of atom, labelling non-equvalent atoms", - "dtypeStr": "C", - "name": "x_wien2k_atom_name", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - },{ - "description": "number of radial mesh points", - "dtypeStr": "i", - "name": "x_wien2k_NPT", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - },{ - "description": "atomic sphere radius (muffin-tin radius)", - "dtypeStr": "f", - "name": "x_wien2k_RMT", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - },{ - "description": "first radial mesh point", - "dtypeStr": "f", - "name": "x_wien2k_R0", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - },{ - "description": "atomic number Z", - "dtypeStr": "f", - "name": "x_wien2k_atomic_number_Z", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "header (labels) of wien2k.", - "kindStr": "type_section", - "name": "x_wien2k_header", - "superNames": [ - "section_run" - ] - }, { - "description": "scf iteration number", - "dtypeStr": "i", - "name": "x_wien2k_iteration_number", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "number of inequivalent atoms in the unit cell", - "dtypeStr": "i", - "name": "x_wien2k_nonequiv_atoms", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "number of independent atoms in the cell", - "dtypeStr": "i", - "name": "x_wien2k_number_of_independent_atoms", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "exchange correlation potential option", - "dtypeStr": "i", - "name": "x_wien2k_potential_option", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "Release date of wien2k.", - "dtypeStr": "C", - "name": "x_wien2k_release_date", - "shape": [], - "superNames": [ - "x_wien2k_header" - ] - }, { - "description": "section containing a class of equivalent atoms", - "kindStr": "type_section", - "name": "x_wien2k_section_equiv_atoms", - "superNames": [ - "section_system" - ] - }, { - "description": "user given name for this system given in the struct file", - "dtypeStr": "C", - "name": "x_wien2k_system_nameIn", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "user given name for this system", - "dtypeStr": "C", - "name": "x_wien2k_system_name", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "relativistic or nonrelativistic calculation mode", - "dtypeStr": "C", - "name": "x_wien2k_calc_mode", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - a", - "dtypeStr": "f", - "name": "x_wien2k_unit_cell_param_a", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - b", - "dtypeStr": "f", - "name": "x_wien2k_unit_cell_param_b", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - c", - "dtypeStr": "f", - "name": "x_wien2k_unit_cell_param_c", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - alfa", - "dtypeStr": "f", - "name": "x_wien2k_angle_between_unit_axis_alfa", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - beta", - "dtypeStr": "f", - "name": "x_wien2k_angle_between_unit_axis_beta", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "unit cell parameters - gamma", - "dtypeStr": "f", - "name": "x_wien2k_angle_between_unit_axis_gamma", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "total number of atoms in the cell", - "dtypeStr": "i", - "name": "x_wien2k_total_atoms", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "lattice parameter a in this calculation", - "dtypeStr": "f", - "name": "x_wien2k_lattice_const_a", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "lattice parameter b in this calculation", - "dtypeStr": "f", - "name": "x_wien2k_lattice_const_b", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "lattice parameter c in this calculation", - "dtypeStr": "f", - "name": "x_wien2k_lattice_const_c", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "unit cell volume", - "dtypeStr": "f", - "name": "x_wien2k_unit_cell_volume", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "bohr^3" - }, { - "description": "total energy", - "dtypeStr": "f", - "name": "x_wien2k_total_ene", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "Ry" - }, { - "description": "Fermi energy", - "dtypeStr": "f", - "name": "x_wien2k_fermi_ene", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "Ry" - }, { - "description": "energy gap in Ry", - "dtypeStr": "f", - "name": "x_wien2k_ene_gap_Ry", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "Ry" - }, { - "description": "energy gap in eV", - "dtypeStr": "f", - "name": "x_wien2k_ene_gap_eV", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "eV" - }, { - "description": "matrix size", - "dtypeStr": "i", - "name": "x_wien2k_matrix_size", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "rkm", - "dtypeStr": "f", - "name": "x_wien2k_rkm", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "LOs", - "dtypeStr": "i", - "name": "x_wien2k_LOs", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "total magnetic moment in cell", - "dtypeStr": "f", - "name": "x_wien2k_mmtot", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "magnetic moment in the interstital region", - "dtypeStr": "f", - "name": "x_wien2k_mmint", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "magnetic moment inside the sphere", - "dtypeStr": "f", - "name": "x_wien2k_mmi001", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the local (for each atom) cartesian coordinate system): |F|", - "dtypeStr": "f", - "name": "x_wien2k_for_abs", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the local (for each atom) cartesian coordinate system): Fx", - "dtypeStr": "f", - "name": "x_wien2k_for_x", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the local (for each atom) cartesian coordinate system): Fy", - "dtypeStr": "f", - "name": "x_wien2k_for_y", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the local (for each atom) cartesian coordinate system): Fz", - "dtypeStr": "f", - "name": "x_wien2k_for_z", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the global coordinate system of the unit cell (in the same way as the atomic positions are specified)): Fx", - "dtypeStr": "f", - "name": "x_wien2k_for_x_gl", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the global coordinate system of the unit cell (in the same way as the atomic positions are specified)): Fy", - "dtypeStr": "f", - "name": "x_wien2k_for_y_gl", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "force on atom xx in mRy/bohr (in the global coordinate system of the unit cell (in the same way as the atomic positions are specified)): Fz", - "dtypeStr": "f", - "name": "x_wien2k_for_z_gl", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "number of atom, labelling atoms", - "dtypeStr": "C", - "name": "x_wien2k_atom_nr", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "number of sphere, labelling spheres", - "dtypeStr": "C", - "name": "x_wien2k_sphere_nr", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "total difference charge density for atom xx between last 2 iterations", - "dtypeStr": "f", - "name": "x_wien2k_tot_diff_charge", - "repeats": true, - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "total interstitial charge", - "dtypeStr": "f", - "name": "x_wien2k_tot_int_charge", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "Version of WIEN2k.", - "dtypeStr": "C", - "name": "x_wien2k_version", - "shape": [], - "superNames": [ - "x_wien2k_header" - ] - }] -} diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json deleted file mode 100644 index 7c4dc3e..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "type": "nomad_meta_info_1_0", - "description": "meta info used by the wien2k parser. All names are expected to start with x_wien2k_", - "dependencies": [ { - "relativePath": "common.nomadmetainfo.json" - }, { - "relativePath": "meta_types.nomadmetainfo.json" - }], - "metaInfos": [ { - "description": "position of atom x in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_x", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "position of atom y in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_y", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "position of atom z in internal units", - "dtypeStr": "f", - "name": "x_wien2k_atom_pos_z", - "repeats": true, - "shape": [], - "superNames": [ - "x_wien2k_section_equiv_atoms" - ] - }, { - "description": "header (labels) of wien2k.", - "kindStr": "type_section", - "name": "x_wien2k_header", - "superNames": [ - "section_run" - ] - }, { - "description": "scf iteration number", - "dtypeStr": "i", - "name": "x_wien2k_iteration_number", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "number of inequivalent atoms in the unit cell", - "dtypeStr": "i", - "name": "x_wien2k_nonequiv_atoms", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "number of independent atoms in the cell", - "dtypeStr": "i", - "name": "x_wien2k_number_of_independent_atoms", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "exchange correlation potential option", - "dtypeStr": "i", - "name": "x_wien2k_potential_option", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "Release date of wien2k.", - "dtypeStr": "C", - "name": "x_wien2k_release_date", - "shape": [], - "superNames": [ - "x_wien2k_header" - ] - }, { - "description": "section containing a class of equivalent atoms", - "kindStr": "type_section", - "name": "x_wien2k_section_equiv_atoms", - "superNames": [ - "section_system" - ] - }, { - "description": "user given name for this system given in the struct file", - "dtypeStr": "C", - "name": "x_wien2k_system_nameIn", - "shape": [], - "superNames": [ - "section_system" - ] - }, { - "description": "user given name for this system", - "dtypeStr": "C", - "name": "x_wien2k_system_name", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "total number of atoms in the cell", - "dtypeStr": "i", - "name": "x_wien2k_total_atoms", - "shape": [], - "superNames": [ - "section_scf_iteration" - ] - }, { - "description": "unit cell volume", - "dtypeStr": "f", - "name": "x_wien2k_unit_cell_volume", - "shape": [], - "superNames": [ - "section_scf_iteration" - ], - "units": "m^3" - }, { - "description": "Version of wien2k.", - "dtypeStr": "C", - "name": "x_wien2k_version", - "shape": [], - "superNames": [ - "x_wien2k_header" - ] - }] -} diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py deleted file mode 100644 index b56404a..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py +++ /dev/null @@ -1,175 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json -import wien2k_parser_struct, wien2k_parser_in0, wien2k_parser_in1c, wien2k_parser_in2c, wien2k_parser_in1, wien2k_parser_in2 - -class Wien2kContext(object): - """context for wien2k parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - self.metaInfoEnv = self.parser.parserBuilder.metaInfoEnv - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - def onClose_x_wien2k_header(self, backend, gIndex, section): - backend.addValue("program_version", - section["x_wien2k_version"][0] + " " + - section["x_wien2k_release_date"][0]) - - def onOpen_section_system(self, backend, gIndex, section): - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".struct" - if os.path.exists(fName): - structSuperContext = wien2k_parser_struct.Wien2kStructContext() - structParser = AncillaryParser( - fileDescription = wien2k_parser_struct.buildStructureMatchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_struct.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = structSuperContext) - - with open(fName) as fIn: - structParser.parseFile(fIn) - - def onOpen_section_method(self, backend, gIndex, section): - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".in0" - if os.path.exists(fName): - subSuperContext = wien2k_parser_in0.Wien2kIn0Context() - subParser = AncillaryParser( - fileDescription = wien2k_parser_in0.buildIn0Matchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_in0.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = subSuperContext) - with open(fName) as fIn: - subParser.parseFile(fIn) - - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".in1c" - if os.path.exists(fName): - subSuperContext = wien2k_parser_in1c.Wien2kIn1cContext() - subParser = AncillaryParser( - fileDescription = wien2k_parser_in1c.buildIn1cMatchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_in1c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = subSuperContext) - with open(fName) as fIn: - subParser.parseFile(fIn) - - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".in2c" - if os.path.exists(fName): - subSuperContext = wien2k_parser_in2c.Wien2kIn2cContext() - subParser = AncillaryParser( - fileDescription = wien2k_parser_in2c.buildIn2cMatchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_in2c.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = subSuperContext) - with open(fName) as fIn: - subParser.parseFile(fIn) - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".in1" - if os.path.exists(fName): - subSuperContext = wien2k_parser_in1.Wien2kIn1Context() - subParser = AncillaryParser( - fileDescription = wien2k_parser_in1.buildIn1Matchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_in1.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = subSuperContext) - with open(fName) as fIn: - subParser.parseFile(fIn) - - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".in2" - if os.path.exists(fName): - subSuperContext = wien2k_parser_in2.Wien2kIn2Context() - subParser = AncillaryParser( - fileDescription = wien2k_parser_in2.buildIn2Matchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_in2.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = subSuperContext) - with open(fName) as fIn: - subParser.parseFile(fIn) - -# description of the input -mainFileDescription = SM( - name = 'root', - weak = True, - startReStr = "", - subMatchers = [ - SM(name = 'newRun', - startReStr = r"\s*:LABEL[0-9]+: using WIEN2k_(?:[0-9.]+) \(Release (?:[0-9/.]+)\) in ", - repeats = True, - required = True, - forwardMatch = True, - sections = ['section_run', 'section_method', 'section_system', 'section_single_configuration_calculation'], - subMatchers = [ - SM( - name = 'header', - startReStr = r"\s*:LABEL[0-9]+: using WIEN2k_(?P<x_wien2k_version>[0-9.]+) \(Release (?P<x_wien2k_release_date>[0-9/.]+)\) in ", - sections=["x_wien2k_header"], - fixedStartValues={'program_name': 'WIEN2k', 'program_basis_set_type': '(L)APW+lo' } - ), SM( - name = "scf iteration", - startReStr = r"\s*:ITE(?P<x_wien2k_iteration_number>[0-9]+):\s*[0-9]*. ITERATION", - sections=["section_scf_iteration"], - repeats = True, - subMatchers=[ - SM(r":NATO\s*:\s*(?P<x_wien2k_nr_of_independent_atoms>[0-9]+)\s*INDEPENDENT AND\s*(?P<x_wien2k_total_atoms>[0-9]+)\s*TOTAL ATOMS IN UNITCELL"), - SM(r"\s*SUBSTANCE: (?P<x_wien2k_system_name>.*)"), - SM(r":POT\s*:\s*POTENTIAL OPTION\s*(?P<x_wien2k_potential_option>[0-9]+)"), - SM(r":LAT\s*:\s*LATTICE CONSTANTS=\s*(?P<x_wien2k_lattice_const_a>[0-9.]+)\s*(?P<x_wien2k_lattice_const_b>[0-9.]+)\s*(?P<x_wien2k_lattice_const_c>[0-9.]+)"), - SM(r":VOL\s*:\s*UNIT CELL VOLUME\s*=\s*(?P<x_wien2k_unit_cell_volume_bohr3>[0-9.]+)"), - SM(r":RKM : MATRIX SIZE (?P<x_wien2k_matrix_size>[0-9]+)\s*LOs:\s*(?P<x_wien2k_LOs>[0-9.]+)\s*RKM=\s*(?P<x_wien2k_rkm>[0-9.]+)\s*WEIGHT=\s*[0-9.]*\s*\w*:"), - SM(r":KPT\s*:\s*NUMBER\s*OF\s*K-POINTS:\s*(?P<x_wien2k_nr_kpts>[-+0-9.]+)"), - SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*(?P<x_wien2k_cutoff>[0-9.]+)\s*Ry\W\W[0-9.]+"), - SM(r":GAP\s*:\s*(?P<x_wien2k_ene_gap_Ry>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*.*"), - SM(r":NOE\s*:\s*NUMBER\sOF\sELECTRONS\s*=\s*(?P<x_wien2k_noe>[0-9.]+)"), - SM(r":FER\s*:\s(\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene>[-+0-9.]+)"), - SM(r":GMA\s*:\s*POTENTIAL\sAND\sCHARGE\sCUT-OFF\s*[0-9.]+\s*Ry\W\W[0-9.]+"), - SM(r":MMTOT: TOTAL MAGNETIC MOMENT IN CELL =\s*(?P<x_wien2k_mmtot>[-+0-9.]+)"), - SM(r":MMINT: MAGNETIC MOMENT IN INTERSTITIAL =\s*(?P<x_wien2k_mmint>[-+0-9.]+)"), - SM(r":MMI001: MAGNETIC MOMENT IN SPHERE 1 =\s*(?P<x_wien2k_mmi001>[-+0-9.]+)"), - SM(r":NTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge_nm>[-+0-9.]+)"), - SM(r":NTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere_nm>[-+0-9.]+)",repeats = True), - SM(r":DTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\sTOTAL\s*DIFFERENCE\s*CHARGE\W*\w*\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_diff_charge>[-+0-9.]+)", repeats = True), - SM(r":DIS\s*:\s*CHARGE\sDISTANCE\s*\W*[0-9.]+\sfor\satom\s*[0-9]*\sspin\s[0-9]*\W\s*(?P<x_wien2k_charge_distance>[0-9.]+)"), - SM(r":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+0-9.]+)"), - SM(r":CTO(?P<x_wien2k_atom_nr>[-+0-9]+)[0-9]*:\s*\sTOTAL\s*CHARGE\s*IN\s*SPHERE\s*(?P<x_wien2k_sphere_nr>[-+0-9]+)\s*=\s*(?P<x_wien2k_tot_charge_in_sphere>[-+0-9.]+)",repeats = True), - SM(r":ENE\s*:\s*\W*\w*\W*\s*TOTAL\s*ENERGY\s*IN\s*Ry\s*=\s*(?P<energy_total>[-+0-9.]+)"), - SM(r":FOR[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_abs>[0-9.]+)\s*(?P<x_wien2k_for_x>[-++0-9.]+)\s*(?P<x_wien2k_for_y>[-+0-9.]+)\s*(?P<x_wien2k_for_z>[-+0-9.]+)\s*partial\sforces", repeats = True), - SM(r":FGL[0-9]*:\s*(?P<x_wien2k_atom_nr>[0-9]+).ATOM\s*(?P<x_wien2k_for_x_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_y_gl>[-+0-9.]+)\s*(?P<x_wien2k_for_z_gl>[-+0-9.]+)\s*partial\sforces", repeats = True) - ] - ) - ] - ) - ]) - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json - -parserInfo = { - "name": "Wien2k" -# "version": "1.0" -} - -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) - -if __name__ == "__main__": - superContext = Wien2kContext() - mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext) diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in0.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in0.py deleted file mode 100644 index b602d6a..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in0.py +++ /dev/null @@ -1,69 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kIn0Context(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildIn0Matchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_method"], - subMatchers = [ -# SM(name = 'systemName', -# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"(?P<x_wien2k_switch>\w*)\s*(?P<x_wien2k_indxc>[0-9]+)\s*.*"), - 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]+).*") -# SM(r"(?P<x_wien2k_calc_mode>.*)"), -# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"), -# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True, -# sections=["x_wien2k_section_equiv_atoms"], -# subMatchers=[ -# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True -# ), -# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_method': CachingLvl - } - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1.py deleted file mode 100644 index ab4a58b..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1.py +++ /dev/null @@ -1,69 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kIn1Context(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildIn1Matchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_method"], - subMatchers = [ -# SM(name = 'systemName', -# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"\s*(?P<x_wien2k_wf_switch>[\w*]+)\s*EF=[-+.0-9]*\s*\W*WFFIL, WFPRI, ENFIL, SUPWF\W"), - SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*") -# SM(r"(?P<x_wien2k_calc_mode>.*)"), -# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"), -# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True, -# sections=["x_wien2k_section_equiv_atoms"], -# subMatchers=[ -# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True -# ), -# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_method': CachingLvl - } - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1c.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1c.py deleted file mode 100644 index 218e775..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in1c.py +++ /dev/null @@ -1,69 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kIn1cContext(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildIn1cMatchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_method"], - subMatchers = [ -# SM(name = 'systemName', -# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"\s*(?P<x_wien2k_wf_switch>[\w*]+)\s*EF=[-+.0-9]*\s*\W*WFFIL, WFPRI, ENFIL, SUPWF\W"), - SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*") -# SM(r"(?P<x_wien2k_calc_mode>.*)"), -# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"), -# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True, -# sections=["x_wien2k_section_equiv_atoms"], -# subMatchers=[ -# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True -# ), -# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_method': CachingLvl - } - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2.py deleted file mode 100644 index 947daf5..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2.py +++ /dev/null @@ -1,69 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kIn2Context(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildIn2Matchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_method"], - subMatchers = [ -# SM(name = 'systemName', -# startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*") -# SM(r"\s*(?P<x_wien2k_rkmax>[0-9.]+)\s*[0-9]+\s*[0-9]+\s*\WR-..\WK-...; MAX \w*.*") -# SM(r"(?P<x_wien2k_calc_mode>.*)"), -# SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"), -# SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True, -# sections=["x_wien2k_section_equiv_atoms"], -# subMatchers=[ -# SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", -# repeats=True -# ), -# SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_method': CachingLvl - } - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2c.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2c.py deleted file mode 100644 index 4d0d171..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_in2c.py +++ /dev/null @@ -1,57 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kIn2cContext(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildIn2cMatchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_method"], - subMatchers = [ - SM(r"\s*(?P<x_wien2k_in2c_switch>[A-Z]+)\s*.*"), - SM(r"\s*(?P<x_wien2k_in2c_emin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_ne>[-+0-9.]+)\s*(?P<x_wien2k_in2c_espermin>[-+0-9.]+)\s*(?P<x_wien2k_in2c_esper0>[-+0-9.]+)\s*.*"), - SM(r"\s*(?P<smearing_kind>[A-Z]+)\s*\s*(?P<smearing_width>[-+0-9.]+)\s*.*"), - SM(r"\s*(?P<x_wien2k_in2c_gmax>[-+0-9.]+)\s*GMAX") - ]) - -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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_method': CachingLvl - } - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py deleted file mode 100644 index 7554864..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py +++ /dev/null @@ -1,90 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, AncillaryParser, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json -import wien2k_parser_struct - -class Wien2kContext(object): - """context for wien2k parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - self.metaInfoEnv = self.parser.parserBuilder.metaInfoEnv - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - def onClose_x_wien2k_header(self, backend, gIndex, section): - backend.addValue("program_version", - section["x_wien2k_version"][0] + " " + - section["x_wien2k_release_date"][0]) - - def onOpen_section_system(self, backend, gIndex, section): - - structSuperContext = wien2k_parser_struct.Wien2kStructContext() - structParser = AncillaryParser( - fileDescription = wien2k_parser_struct.buildStructureMatchers(), - parser = self.parser, - cachingLevelForMetaName = wien2k_parser_struct.get_cachingLevelForMetaName(self.metaInfoEnv, CachingLevel.PreOpenedIgnore), - superContext = structSuperContext) - - mainFile = self.parser.fIn.fIn.name - fName = mainFile[:-4] + ".struct" - if os.path.exists(fName): - with open(fName) as fIn: - structParser.parseFile(fIn) - -# description of the input -mainFileDescription = SM( - name = 'root', - weak = True, - startReStr = "", - subMatchers = [ - SM(name = 'newRun', - startReStr = r"\s*:LABEL[0-9]+: using WIEN2k_(?:[0-9.]+) \(Release (?:[0-9/.]+)\) in ", - repeats = True, - required = True, - forwardMatch = True, - sections = ['section_run', 'section_method', 'section_system', 'section_single_configuration_calculation'], - subMatchers = [ - SM( - name = 'header', - startReStr = r"\s*:LABEL[0-9]+: using WIEN2k_(?P<x_wien2k_version>[0-9.]+) \(Release (?P<x_wien2k_release_date>[0-9/.]+)\) in ", - sections=["x_wien2k_header"], - fixedStartValues={'program_name': 'WIEN2k', 'program_basis_set_type': '(L)APW+lo' } - ), SM( - name = "scf iteration", - startReStr = r"\s*:ITE(?P<x_wien2k_iteration_number>[0-9]+):\s*[0-9]*. ITERATION", - sections=["section_scf_iteration"], - repeats = True, - subMatchers=[ - SM(r":NATO :\s*(?P<x_wien2k_number_of_independent_atoms>[0-9]+)INDEPENDENT AND\s*(?P<x_wien2k_total_atoms>[0-9]+)\s*TOTAL ATOMS IN UNITCELL"), - SM(r"\s*SUBSTANCE: (?P<x_wien2k_system_name>.*)"), - SM(r":POT\s*:\s*POTENTIAL OPTION\s*(?P<x_wien2k_potential_option>[0-9]+)"), - SM(r":VOL\s*:\s*UNIT CELL VOLUME\s*=\s*(?P<x_wien2k_unit_cell_volume__angstrom3>[0-9.]+)") - ] - ) - ] - ) - ]) - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json - -parserInfo = { - "name": "Wien2k" -} - -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) - -if __name__ == "__main__": - superContext = Wien2kContext() - mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext) diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py deleted file mode 100644 index 01d3c49..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py +++ /dev/null @@ -1,92 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json, logging -import numpy as np - -class Wien2kStructContext(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - def onClose_section_system(self, backend, gIndex, section): - equiv_atoms = section["x_wien2k_section_equiv_atoms"] - #logging.error("section: %s", section) - labels = [] - pos = [] - for eqAtoms in equiv_atoms: - label = eqAtoms["x_wien2k_atom_name"][0] - x = eqAtoms["x_wien2k_atom_pos_x"] - y = eqAtoms["x_wien2k_atom_pos_y"] - z = eqAtoms["x_wien2k_atom_pos_z"] - if len(x) != len(y) or len(x) != len(z): - raise Exception("incorrect parsing, different number of x,y,z components") - groupPos = [[x[i],y[i],z[i]] for i in range(len(x))] - nAt = len(groupPos) - labels += [label for i in range(nAt)] - pos += groupPos - backend.addValue("atom_labels", labels) - backend.addValue("atom_positions", pos) - - -# description of the input -def buildStructureMatchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_system"], - subMatchers = [ - SM(name = 'systemName', - startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"\w+\s*LATTICE,NONEQUIV\.ATOMS.\s*(?P<x_wien2k_nonequiv_atoms>[0-9]+)"), - SM(r"(?P<x_wien2k_calc_mode>.*)"), - # SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9.eEdD]+)\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9.eEdD]+)\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9.eEdD]+)\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+0-9.eEdD]{9})\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+0-9.eEdD]{9})\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+0-9.eEdD]+)"), - SM(r"\s*(?P<x_wien2k_unit_cell_param_a>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_b>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_unit_cell_param_c>[-+0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_alfa>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_beta>[-+]?[0-9]*\.\d{0,6}){0,10}\s*(?P<x_wien2k_angle_between_unit_axis_gamma>[-+]?[0-9]*\.\d*)"), - SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", - repeats=True, - sections=["x_wien2k_section_equiv_atoms"], - subMatchers=[ - SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", - repeats=True - ), - # SM(r"\s*(?P<atom>.{10})\s*NPT=\s*(?P<NPT>[0-9]+)\s*R0=(?P<r0>[0-9.]+)\s*RMT=\s*(?P<rmt>[0-9.]+)\s*Z:\s*(?P<z>[0-9.]+)",) - SM(r"\s*(?P<x_wien2k_atom_name>^.+)\s*NPT=\s*(?P<x_wien2k_NPT>[0-9]+)\s*R0=(?P<x_wien2k_R0>[0-9.]+)\s*RMT=\s*(?P<x_wien2k_RMT>[0-9.]+)\s*Z:\s*(?P<x_wien2k_atomic_number_Z>[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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_system': CachingLvl - } - cachingLevelForMetaName["x_wien2k_system_nameIn"] = CachingLevel.ForwardAndCache - cachingLevelForMetaName["x_wien2k_section_equiv_atoms"] = CachingLevel.ForwardAndCache - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct_old.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct_old.py deleted file mode 100644 index fb10a7e..0000000 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct_old.py +++ /dev/null @@ -1,66 +0,0 @@ -from builtins import object -import setup_paths -from nomadcore.simple_parser import mainFunction, CachingLevel -from nomadcore.simple_parser import SimpleMatcher as SM -from nomadcore.local_meta_info import loadJsonFile, InfoKindEl -import os, sys, json - -class Wien2kStructContext(object): - """context for wien2k struct parser""" - - def __init__(self): - self.parser = None - - def initialize_values(self): - """allows to reset values if the same superContext is used to parse different files""" - pass - - def startedParsing(self, path, parser): - """called when parsing starts""" - self.parser = parser - # allows to reset values if the same superContext is used to parse different files - self.initialize_values() - - -# description of the input -def buildStructureMatchers(): - return SM( - name = 'root', - weak = True, - startReStr = "", - sections = ["section_run", "section_system"], - subMatchers = [ - SM(name = 'systemName', - startReStr = r"(?P<x_wien2k_system_nameIn>.*)"), - SM(r"\w+\s*LATTICE,NONEQUIV\.ATOMS:\s*(?P<x_wien2k_nonequiv_atoms>[0-9]+)"), - SM(r"\s*ATOM\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", - repeats=True, - sections=["x_wien2k_section_equiv_atoms"], - subMatchers=[ - SM(r"\s*[-0-9]+:\s*X=(?P<x_wien2k_atom_pos_x>[-+0-9.eEdD]+)\s*Y=(?P<x_wien2k_atom_pos_y>[-+0-9.eEdD]+)\s*Z=(?P<x_wien2k_atom_pos_z>[-+0-9.eEdD]+)", - repeats=True - ) - ] - ) - ]) - -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. - - Returns: - Dictionary with metaname as key and caching level as value. - """ - # manually adjust caching of metadata - cachingLevelForMetaName = { - 'section_run': CachingLvl, - 'section_system': CachingLvl - } - cachingLevelForMetaName["x_wien2k_system_nameIn"] = CachingLevel.ForwardAndCache - return cachingLevelForMetaName - -# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json -- GitLab