-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patching w2dynamics parser copy-pasting the wannier90 textparsers
- Loading branch information
1 parent
aae609e
commit 8c26d4e
Showing
2 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), | ||
] |