Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Find below an itemized list of changes in this release.
* Add ABINIT support to `Wannier90Converter` for charge self-consistent calculations
* Read VASP `ICHARG=5` miscellaneous input from `vaspout.h5`

### Wien2k
* Read the high-symmetry k-path labels from the end of `case.outband` and store them as `kpts_labels` / `kpts_labels_idx` in `dft_bands_input`, matching the VASP band conversion

### Fix
* Fix a bug in the `deltaN` write for the Quantum Espresso and Abinit interfaces

Expand Down
9 changes: 9 additions & 0 deletions doc/h5structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,15 @@ counting the k-points along the path.
``max(n_parproj)``, ``max(shells['dim'])``, ``max(n_orbitals)``]
- As in ``dft_parproj_input``, along the path. Elk writes a dummy
``array([0])``.
* - ``kpts_labels``
- list of string
- Names of the high-symmetry points of the path (e.g. ``'GAMMA'``, ``'X'``),
for labelling the ticks of a band plot. Only written by Wien2k and VASP,
and only when the underlying DFT output provides the labels.
* - ``kpts_labels_idx``
- numpy.array.int, dim [``len(kpts_labels)``]
- Position of each entry of ``kpts_labels`` along the path, as a 0-based
index into the ``n_k`` k-points.

.. note::

Expand Down
51 changes: 51 additions & 0 deletions python/triqs_dftkit/wien2k/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from h5 import *
from ..converter_tools import *
import os.path
import re


class Converter(ConverterTools):
Expand Down Expand Up @@ -396,6 +397,51 @@ def convert_bands_input(self):
if not (mpi.is_master_node()):
return

def _read_kpath_labels(band_file, n_k):
"""
Read the high-symmetry k-path labels appended to the end of
case.outband and map them onto the flattened band k-point index.

dmftproj writes one line per high-symmetry point after the projector
data, in fixed Fortran format (2i6,a): a running counter, the 1-based
position of the point along the band path, and the label, e.g.

1 1GAMMA
2 122X

Returns (labels, idx) where labels is a list of label strings and idx
is a 0-based numpy int array giving, for each label, the position of
that high-symmetry point in the n_k band path. Returns (None, None)
if no label block is present.
"""
with open(band_file, 'r') as R:
lines = R.readlines()
while lines and not lines[-1].strip():
lines.pop()

# Walk backwards from the end of the file: the label block is the
# trailing run of lines matching 'counter index label'.
labels = []
idx = []
for line in reversed(lines):
match = re.match(r'\s*(\d+)\s+(\d+)\s*([A-Za-z]\S*)\s*$', line)
if match is None:
break
labels.append(match.group(3))
idx.append(int(match.group(2)) - 1)
labels.reverse()
idx.reverse()

if not labels:
return None, None

idx = numpy.array(idx, dtype=int)
if idx[0] < 0 or idx[-1] >= n_k or numpy.any(numpy.diff(idx) <= 0):
mpi.report("convert_bands_input : WARNING : inconsistent high-symmetry point indices in %s; skipping k-path labels." % band_file)
return None, None

return labels, idx

try:
# get needed data from hdf file
with HDFArchive(self.hdf_file, 'a') as ar:
Expand Down Expand Up @@ -483,6 +529,8 @@ def convert_bands_input(self):

# Reading done!

kpts_labels, kpts_labels_idx = _read_kpath_labels(self.band_file, n_k)

# Save it to the HDF:
with HDFArchive(self.hdf_file, 'a') as ar:
if not (self.bands_subgrp in ar):
Expand All @@ -491,6 +539,9 @@ def convert_bands_input(self):
# created. If it exists, the data is overwritten!
things_to_save = ['n_k', 'n_orbitals', 'proj_mat',
'hopping', 'n_parproj', 'proj_mat_all']
if kpts_labels is not None:
things_to_save += ['kpts_labels', 'kpts_labels_idx']
mpi.report(" Stored %i high-symmetry k-path labels: %s" % (len(kpts_labels), ', '.join(kpts_labels)))
for it in things_to_save:
ar[self.bands_subgrp][it] = locals()[it]

Expand Down
Loading