Skip to content
Snippets Groups Projects
Commit 60a2a47f authored by Daria Tomecka's avatar Daria Tomecka
Browse files

wien2k: add number of k-points and in0 input file

parent 222fac77
No related branches found
No related tags found
No related merge requests found
......@@ -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,7 +28,9 @@ class Wien2kContext(object):
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(),
......@@ -36,11 +38,22 @@ class Wien2kContext(object):
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] + ".struct"
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:
structParser.parseFile(fIn)
subParser.parseFile(fIn)
# description of the input
mainFileDescription = SM(
......@@ -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)
]
)
]
......
......@@ -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": [],
......
{
"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"
]
}]
}
......@@ -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.]+)")
]
)
]
......
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)
......@@ -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.]+)",)
]
)
])
......
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
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment