Skip to content

Commit

Permalink
Patching w2dynamics parser copy-pasting the wannier90 textparsers
Browse files Browse the repository at this point in the history
  • Loading branch information
JosePizarro3 committed May 30, 2024
1 parent aae609e commit 8c26d4e
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 1 deletion.
2 changes: 1 addition & 1 deletion electronicparsers/w2dynamics/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
x_w2dynamics_config_parameters,
x_w2dynamics_config_atoms_parameters,
)
from ..wannier90.parser import WOutParser, HrParser
from .patch_wannier90 import WOutParser, HrParser

# For automatic workflows
from ..utils import get_files, BeyondDFTWorkflowsParser
Expand Down
154 changes: 154 additions & 0 deletions electronicparsers/w2dynamics/patch_wannier90.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
#
# Copyright The NOMAD Authors.
#
# This file is part of NOMAD.
# See https://nomad-lab.eu for further info.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from nomad.parsing.file_parser import TextParser, Quantity
from runschema.run import Program

re_n = r'[\n\r]'


class WOutParser(TextParser):
def __init__(self):
super().__init__(None)

def init_quantities(self):
kmesh_quantities = [
Quantity('n_points', r'Total points[\s=]*(\d+)', dtype=int, repeats=False),
Quantity(
'grid', r'Grid size *\= *(\d+) *x *(\d+) *x *(\d+)', repeats=False
),
Quantity('k_points', r'\|[\s\d]*(-*\d.[^\|]+)', repeats=True, dtype=float),
]

klinepath_quantities = [
Quantity(
'high_symm_name',
r'\| *From\: *([a-zA-Z]+) [\d\.\-\s]*To\: *([a-zA-Z]+)',
repeats=True,
),
Quantity(
'high_symm_value',
r'\| *From\: *[a-zA-Z]* *([\d\.\-\s]+)To\: *[a-zA-Z]* *([\d\.\-\s]+)\|',
repeats=True,
),
]

disentangle_quantities = [
Quantity(
'outer',
r'\|\s*Outer:\s*([-\d.]+)\s*\w*\s*([-\d.]+)\s*\((?P<__unit>\w+)\)',
dtype=float,
repeats=False,
),
Quantity(
'inner',
r'\|\s*Inner:\s*([-\d.]+)\s*\w*\s*([-\d.]+)\s*\((?P<__unit>\w+)\)',
dtype=float,
repeats=False,
),
]

structure_quantities = [
Quantity('labels', r'\|\s*([A-Z][a-z]*)', repeats=True),
Quantity(
'positions',
rf'\|\s*([\-\d\.]+)\s*([\-\d\.]+)\s*([\-\d\.]+)',
repeats=True,
dtype=float,
),
]

self._quantities = [
# Program quantities
Quantity(
Program.version, r'\s*\|\s*Release\:\s*([\d\.]+)\s*', repeats=False
),
# System quantities
Quantity('lattice_vectors', r'\s*a_\d\s*([\d\-\s\.]+)', repeats=True),
Quantity(
'reciprocal_lattice_vectors', r'\s*b_\d\s*([\d\-\s\.]+)', repeats=True
),
Quantity(
'structure',
rf'(\s*Fractional Coordinate[\s\S]+?)(?:{re_n}\s*(PROJECTIONS|K-POINT GRID))',
repeats=False,
sub_parser=TextParser(quantities=structure_quantities),
),
# Method quantities
Quantity(
'k_mesh',
rf'\s*(K-POINT GRID[\s\S]+?)(?:-\s*MAIN)',
repeats=False,
sub_parser=TextParser(quantities=kmesh_quantities),
),
Quantity(
'k_line_path',
rf'\s*(K-space path sections\:[\s\S]+?)(?:\*-------)',
repeats=False,
sub_parser=TextParser(quantities=klinepath_quantities),
),
Quantity(
'Nwannier',
r'\|\s*Number of Wannier Functions\s*\:\s*(\d+)',
repeats=False,
),
Quantity(
'Nband',
r'\|\s*Number of input Bloch states\s*\:\s*(\d+)',
repeats=False,
),
Quantity(
'Niter', r'\|\s*Total number of iterations\s*\:\s*(\d+)', repeats=False
),
Quantity(
'conv_tol',
r'\|\s*Convergence tolerence\s*\:\s*([\d.eE-]+)',
repeats=False,
),
Quantity(
'energy_windows',
rf'(\|\s*Energy\s*Windows\s*\|[\s\S]+?)(?:Number of target bands to extract:)',
repeats=False,
sub_parser=TextParser(quantities=disentangle_quantities),
),
# Band related quantities
Quantity(
'n_k_segments',
r'\|\s*Number of K-path sections\s*\:\s*(\d+)',
repeats=False,
),
Quantity(
'div_first_k_segment',
r'\|\s*Divisions along first K-path section\s*\:\s*(\d+)',
repeats=False,
),
Quantity(
'band_segments_points',
r'\|\s*From\:\s*\w+([\d\s\-\.]+)To\:\s*\w+([\d\s\-\.]+)',
repeats=True,
),
]


class HrParser(TextParser):
def init_quantities(self):
self._quantities = [
Quantity('degeneracy_factors', r'\s*written on[\s\w]*:\d*:\d*\s*([\d\s]+)'),
Quantity('hoppings', rf'\s*([-\d\s.]+)', repeats=False),
]

0 comments on commit 8c26d4e

Please sign in to comment.