Skip to content

Commit

Permalink
parse nnkpts block in NNKP file
Browse files Browse the repository at this point in the history
  • Loading branch information
jimustafa committed Sep 15, 2023
1 parent 5b1b527 commit 92ee82b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/wannier90io/_nnkp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
r'(?P<projections>.+)',
re.IGNORECASE | re.DOTALL
),
'nnkpts': re.compile(
r'\d+\s+'
r'(?P<nnkpts>.+)',
re.IGNORECASE | re.DOTALL
),
'exclude_bands': re.compile(
r'\d+\s*'
r'(?P<exclude_bands>.*)',
Expand Down Expand Up @@ -115,6 +120,12 @@ def parse_spinor_projections(string: str) -> dict:
]


def parse_nnkpts(string: str) -> list:
match = patterns['nnkpts'].search(string)

return [[int(x) for x in line.split()] for line in match.group('nnkpts').splitlines()]


def parse_exclude_bands(string: str) -> dict:
match = patterns['exclude_bands'].search(string)

Expand Down Expand Up @@ -149,6 +160,7 @@ def parse_nnkp_raw(string: str) -> dict:
'direct_lattice': parse_direct_lattice(blocks['real_lattice']),
'reciprocal_lattice': parse_reciprocal_lattice(blocks['recip_lattice']),
'kpoints': parse_kpoints(blocks['kpoints']),
'nnkpts': parse_nnkpts(blocks['nnkpts']),
'exclude_bands': parse_exclude_bands(blocks['exclude_bands']),
}
if 'projections' in blocks:
Expand Down
1 change: 1 addition & 0 deletions src/wannier90io/_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class NNKP(pydantic.BaseModel):
comments: typing.List[str]
parameters: dict
blocks: dict
nnkpts: typing.List[typing.List[int]]
direct_lattice: DirectLattice
reciprocal_lattice: ReciprocalLattice
kpoints: Kpoints
Expand Down

0 comments on commit 92ee82b

Please sign in to comment.