Skip to content

Commit 329e125

Browse files
committed
Add wannier90 parser
1 parent 4475542 commit 329e125

File tree

8 files changed

+920
-0
lines changed

8 files changed

+920
-0
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ exciting_parser_entry_point = "nomad_simulation_parsers.parsers:exciting_parser_
128128
exciting_schema_package_entry_point = "nomad_simulation_parsers.schema_packages:exciting_schema_package_entry_point"
129129
fhiaims_parser_entry_point = "nomad_simulation_parsers.parsers:fhiaims_parser_entry_point"
130130
fhiaims_schema_package_entry_point = "nomad_simulation_parsers.schema_packages:fhiaims_schema_package_entry_point"
131+
phonopy_parser_entry_point = "nomad_simulation_parsers.parsers:phonopy_parser_entry_point"
132+
phonopy_schema_package_entry_point = "nomad_simulation_parsers.schema_packages:phonopy_schema_package_entry_point"
131133
vasp_parser_entry_point = "nomad_simulation_parsers.parsers:vasp_parser_entry_point"
132134
vasp_schema_package_entry_point = "nomad_simulation_parsers.schema_packages:vasp_schema_package_entry_point"
135+
wannier90_parser_entry_point = "nomad_simulation_parsers.parsers:wannier90_parser_entry_point"
136+
wannier90_schema_package_entry_point = "nomad_simulation_parsers.schema_packages:wannier90_schema_package_entry_point"
133137

134138

135139

src/nomad_simulation_parsers/parsers/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def load(self):
2626
f'Could not load parser class {self.parser_class_name}', exc_info=e
2727
)
2828

29+
class Wannier90ParserEntryPoint(EntryPoint):
30+
equal_cell_positions_tolerance: float = Field(
31+
1e-2,
32+
description='Tolerance (in angstroms) for the cell positions to be considered equal.',
33+
)
34+
2935

3036
exciting_parser_entry_point = EntryPoint(
3137
name='parsers/exciting',
@@ -45,9 +51,22 @@ def load(self):
4551
description='NOMAD parser for FHIAIMS.',
4652
parser_class_name='nomad_simulation_parsers.parsers.fhiaims.parser.FHIAimsParser',
4753
python_package='nomad_simulation_parsers',
54+
code_name='phonopy',
55+
code_homepage='https://aimsclub.fhi-berlin.mpg.de/',
4856
mainfile_contents_re=r'^(.*\n)*?\s*Invoking FHI-aims \.\.\.',
4957
)
5058

59+
phonopy_parser_entry_point = EntryPoint(
60+
name='parsers/phonopy',
61+
aliases=['parsers/phonopy'],
62+
description='NOMAD parser for PHONOPY.',
63+
mainfile_name_re='.*/phon[^/]+yaml',
64+
parser_class_name='nomad_simulation_parsers.parsers.phonopy.parser.PhonopyParser',
65+
code_name='phonopy',
66+
python_package='nomad_simulation_parsers',
67+
code_homepage='https://phonopy.github.io/phonopy/',
68+
)
69+
5170
vasp_parser_entry_point = EntryPoint(
5271
name='parsers/vasp',
5372
description='Parser for VASP XML and OUTCAR outputs',
@@ -64,3 +83,15 @@ def load(self):
6483
mainfile_alternative=True,
6584
supported_compressions=['gz', 'bz2', 'xz'],
6685
)
86+
87+
wannier90_parser_entry_point = Wannier90ParserEntryPoint(
88+
name='parsers/wannier90',
89+
aliases=['parsers/wannier90'],
90+
description='NOMAD parser for WANNIER90.',
91+
parser_class_name='nomad_simulation_parsers.parsers.wannier90.parser.Wannier90Parser',
92+
python_package='nomad_simulation_parsers',
93+
mainfile_contents_re=r'\|\s*WANNIER90\s*\|',
94+
code_name='Wannier90',
95+
code_homepage='http://www.wannier.org/',
96+
code_category='Atomistic code',
97+
)
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import re
2+
3+
from nomad.parsing.file_parser.text_parser import Quantity, TextParser
4+
5+
6+
RE_N = r'[\n\r]'
7+
8+
9+
class WInParser(TextParser):
10+
def init_quantities(self):
11+
def str_proj_to_list(val_in: str) -> list[str]:
12+
# To avoid inconsistent regex that can contain or not spaces
13+
val_n = [re.sub(r'\s.*', '', x) for x in val_in.split('\n') if x]
14+
return [v.strip('[]').replace(' ', '').split(':') for v in val_n]
15+
16+
self._quantities = [
17+
Quantity(
18+
'energy_fermi', r'\n\rfermi_energy\s*=\s*([\d\.\-]+)', repeats=False
19+
),
20+
Quantity(
21+
'projections',
22+
r'[bB]egin [pP]rojections([\s\S]+?)(?:[eE]nd [pP]rojections)',
23+
repeats=False,
24+
str_operation=str_proj_to_list,
25+
),
26+
]
27+
28+
29+
class HrParser(TextParser):
30+
def init_quantities(self):
31+
self._quantities = [
32+
Quantity('degeneracy_factors', r'\s*written on[\s\w]*:\d*:\d*\s*([\d\s]+)'),
33+
Quantity('hoppings', r'\s*([-\d\s.]+)', repeats=False),
34+
]
35+
36+
37+
class WOutParser(TextParser):
38+
def __init__(self):
39+
super().__init__(None)
40+
41+
def init_quantities(self):
42+
kmesh_quantities = [
43+
Quantity('n_points', r'Total points[\s=]*(\d+)', dtype=int, repeats=False),
44+
Quantity(
45+
'grid', r'Grid size *\= *(\d+) *x *(\d+) *x *(\d+)', repeats=False
46+
),
47+
Quantity('k_points', r'\|[\s\d]*(-*\d.[^\|]+)', repeats=True, dtype=float),
48+
]
49+
50+
klinepath_quantities = [
51+
Quantity(
52+
'high_symm_name',
53+
r'\| *From\: *([a-zA-Z]+) [\d\.\-\s]*To\: *([a-zA-Z]+)',
54+
repeats=True,
55+
),
56+
Quantity(
57+
'high_symm_value',
58+
r'\| *From\: *[a-zA-Z]* *([\d\.\-\s]+)To\: *[a-zA-Z]* *([\d\.\-\s]+)\|',
59+
repeats=True,
60+
),
61+
]
62+
63+
disentangle_quantities = [
64+
Quantity(
65+
'outer',
66+
r'\|\s*Outer:\s*([-\d.]+)\s*\w*\s*([-\d.]+)\s*\((?P<__unit>\w+)\)',
67+
dtype=float,
68+
repeats=False,
69+
),
70+
Quantity(
71+
'inner',
72+
r'\|\s*Inner:\s*([-\d.]+)\s*\w*\s*([-\d.]+)\s*\((?P<__unit>\w+)\)',
73+
dtype=float,
74+
repeats=False,
75+
),
76+
]
77+
78+
structure_quantities = [
79+
Quantity('labels', r'\|\s*([A-Z][a-z]*)', repeats=True),
80+
Quantity(
81+
'positions',
82+
r'\|\s*([\-\d\.]+)\s*([\-\d\.]+)\s*([\-\d\.]+)',
83+
repeats=True,
84+
dtype=float,
85+
),
86+
]
87+
88+
self._quantities = [
89+
# Program quantities
90+
Quantity(
91+
'version', r'\s*\|\s*Release\:\s*([\d\.]+)\s*', repeats=False
92+
),
93+
# System quantities
94+
Quantity('lattice_vectors', r'\s*a_\d\s*([\d\-\s\.]+)', repeats=True),
95+
Quantity(
96+
'reciprocal_lattice_vectors', r'\s*b_\d\s*([\d\-\s\.]+)', repeats=True
97+
),
98+
Quantity(
99+
'structure',
100+
rf'(\s*Fractional Coordinate[\s\S]+?)(?:{RE_N}\s*(PROJECTIONS|K-POINT GRID))',
101+
repeats=False,
102+
sub_parser=TextParser(quantities=structure_quantities),
103+
),
104+
# Method quantities
105+
Quantity(
106+
'k_mesh',
107+
r'\s*(K-POINT GRID[\s\S]+?)(?:-\s*MAIN)',
108+
repeats=False,
109+
sub_parser=TextParser(quantities=kmesh_quantities),
110+
),
111+
Quantity(
112+
'k_line_path',
113+
r'\s*(K-space path sections\:[\s\S]+?)(?:\*-------)',
114+
repeats=False,
115+
sub_parser=TextParser(quantities=klinepath_quantities),
116+
),
117+
Quantity(
118+
'Nwannier',
119+
r'\|\s*Number of Wannier Functions\s*\:\s*(\d+)',
120+
repeats=False,
121+
),
122+
Quantity(
123+
'Nband',
124+
r'\|\s*Number of input Bloch states\s*\:\s*(\d+)',
125+
repeats=False,
126+
),
127+
Quantity(
128+
'Niter', r'\|\s*Total number of iterations\s*\:\s*(\d+)', repeats=False
129+
),
130+
Quantity(
131+
'conv_tol',
132+
r'\|\s*Convergence tolerence\s*\:\s*([\d.eE-]+)',
133+
repeats=False,
134+
),
135+
Quantity(
136+
'energy_windows',
137+
r'(\|\s*Energy\s*Windows\s*\|[\s\S]+?)(?:Number of target bands to extract:)',
138+
repeats=False,
139+
sub_parser=TextParser(quantities=disentangle_quantities),
140+
),
141+
# Band related quantities
142+
Quantity(
143+
'n_k_segments',
144+
r'\|\s*Number of K-path sections\s*\:\s*(\d+)',
145+
repeats=False,
146+
),
147+
Quantity(
148+
'div_first_k_segment',
149+
r'\|\s*Divisions along first K-path section\s*\:\s*(\d+)',
150+
repeats=False,
151+
),
152+
Quantity(
153+
'band_segments_points',
154+
r'\|\s*From\:\s*\w+([\d\s\-\.]+)To\:\s*\w+([\d\s\-\.]+)',
155+
repeats=True,
156+
),
157+
]
158+

src/nomad_simulation_parsers/parsers/wannier90/hr_parser.py

Whitespace-only changes.

0 commit comments

Comments
 (0)