diff --git a/parser/parser-wien2k/wien2k_parser.py b/parser/parser-wien2k/wien2k_parser.py index 2cc2f47fa6cab541079bdf1b65c5136e6d8f9de6..d9788fcb3a29e1c2bee5f05679d959589e5bcc30 100644 --- a/parser/parser-wien2k/wien2k_parser.py +++ b/parser/parser-wien2k/wien2k_parser.py @@ -4,7 +4,7 @@ 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 +import wien2k_parser_struct, wien2k_parser_in0 class Wien2kContext(object): """context for wien2k parser""" @@ -28,20 +28,33 @@ class Wien2kContext(object): 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): + 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) + # description of the input mainFileDescription = SM( name = 'root', @@ -66,22 +79,25 @@ mainFileDescription = SM( 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":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__angstrom3>[0-9.]+)"), - SM(r":ENE : \W*\w*\W*\TOTAL ENERGY IN Ry =\s*(?P<x_wien2k_total_ene>[-+0-9.]+)"), - SM(r":FER : (\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene>[-+0-9.]+)"), - SM(r":GAP : (?P<x_wien2k_ene_gap_Ry>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*\W*\w*\s\W"), + 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":GAP :\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":FER : (\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene>[-+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":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), 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":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+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<x_wien2k_total_ene>[-+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) + ] ) ] diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json index 7c4dc3efeccc8003d1b672d388d8dc694defd3f6..fcc98fab51faa164bca0005a216f4f895e0f4a8d 100644 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo.json @@ -33,6 +33,51 @@ "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", @@ -103,6 +148,62 @@ "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", @@ -111,6 +212,30 @@ "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", @@ -119,9 +244,191 @@ "superNames": [ "section_scf_iteration" ], - "units": "m^3" + "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.", + "description": "Version of WIEN2k.", "dtypeStr": "C", "name": "x_wien2k_version", "shape": [], diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json new file mode 100644 index 0000000000000000000000000000000000000000..7c4dc3efeccc8003d1b672d388d8dc694defd3f6 --- /dev/null +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k.nomadmetainfo_old.json @@ -0,0 +1,132 @@ +{ + "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 index 75548643629298a35173572887a8f558d902feb8..2cc2f47fa6cab541079bdf1b65c5136e6d8f9de6 100644 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser.py @@ -69,7 +69,19 @@ mainFileDescription = SM( 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.]+)") + 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__angstrom3>[0-9.]+)"), + SM(r":ENE : \W*\w*\W*\TOTAL ENERGY IN Ry =\s*(?P<x_wien2k_total_ene>[-+0-9.]+)"), + SM(r":FER : (\w*\s*)*-\s\w*\W\w*\WM\W*=\s*(?P<x_wien2k_fermi_ene>[-+0-9.]+)"), + SM(r":GAP : (?P<x_wien2k_ene_gap_Ry>[-+0-9.]+)\s*Ry\s*=\s*(?P<x_wien2k_ene_gap_eV>[-+0-9.]+)\s*eV\s*\W*\w*\s\W"), + 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":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":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), + 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":CTO\s*:\s*\sTOTAL\s*INTERSTITIAL\s*CHARGE=\s*(?P<x_wien2k_tot_int_charge>[-+0-9.]+)") ] ) ] diff --git a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py new file mode 100644 index 0000000000000000000000000000000000000000..75548643629298a35173572887a8f558d902feb8 --- /dev/null +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_old.py @@ -0,0 +1,90 @@ +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 index fb10a7e23f5c30614fc20c081aad70b079b3b83a..72e24285e05c2253a67d579993315f26c621d098 100644 --- a/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct.py @@ -32,14 +32,19 @@ def buildStructureMatchers(): 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"\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.]+)",) ] ) ]) 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 new file mode 100644 index 0000000000000000000000000000000000000000..fb10a7e23f5c30614fc20c081aad70b079b3b83a --- /dev/null +++ b/parser/parser-wien2k/wien2k_parser_backups/wien2k_parser_struct_old.py @@ -0,0 +1,66 @@ +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 diff --git a/parser/parser-wien2k/wien2k_parser_in0.py b/parser/parser-wien2k/wien2k_parser_in0.py new file mode 100644 index 0000000000000000000000000000000000000000..1e0492c7b33d300e7ee9b8d72572539b3aef3da1 --- /dev/null +++ b/parser/parser-wien2k/wien2k_parser_in0.py @@ -0,0 +1,71 @@ +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_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 + return cachingLevelForMetaName + +# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json