3
0
mirror of https://github.com/triqs/dft_tools synced 2024-10-31 11:13:46 +01:00

read wannier centres and symmetry kpath from w90 (#253)

This PR/ commit adds two new features to the w90 converter stored to the h5 archive: 
1. Centres of Wannier functions: This can be obtained using the `read_wannier90_centres()` function. This would also be useful if one wants to shift Wannier centres back to the home unit cells on-the-fly in `dft_tool`. 
2. High-symmetry k-path for band structure: This can be obtained using the `read_wannier90_symm_kpath()` function. 

changes:
* read wannier centres and symmetry kpath from w90
* [fix] w90convert test after fix for kpt_basis stor

---------

Co-authored-by: Alexander Hampel <ahampel@flatironinstitute.org>
This commit is contained in:
Chia-Nan Yeh 2024-06-03 15:00:01 -04:00 committed by GitHub
parent a87276b6c4
commit b8a667b3a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 430 additions and 5 deletions

View File

@ -166,8 +166,15 @@ class Wannier90Converter(ConverterTools):
# Second, let's read the file containing the Hamiltonian in WF basis
# produced by Wannier90
(wannier_hr, u_total, ks_eigenvals, r_vector, r_degeneracy, n_wannier, n_bands,
k_mesh_from_umat) = read_all_wannier90_data(n_spin_blocks, dim_corr_shells, self.w90_seed,
self.add_lambda, self.bloch_basis)
k_mesh_from_umat, wan_centres) = read_all_wannier90_data(n_spin_blocks, dim_corr_shells,
self.w90_seed, self.add_lambda,
self.bloch_basis)
# Read high-symmetry k-path from _band.kpt
w90_kpath_results = None
if mpi.is_master_node():
w90_kpath_results = read_wannier90_symm_kpath(self.w90_seed)
symm_kpath_info = mpi.bcast(w90_kpath_results)
# Builds kmesh or uses kmesh from _u.mat
if self.bloch_basis:
@ -315,8 +322,10 @@ class Wannier90Converter(ConverterTools):
'symm_op', 'n_shells', 'shells', 'n_corr_shells', 'corr_shells', 'use_rotations', 'rot_mat',
'rot_mat_time_inv', 'n_reps', 'dim_reps', 'T', 'n_orbitals', 'proj_mat', 'bz_weights', 'hopping',
'n_inequiv_shells', 'corr_to_inequiv', 'inequiv_to_corr', 'kpt_weights', 'kpts', 'dft_code']
if wan_centres is not None:
things_to_save.append('wan_centres')
if self.bloch_basis:
np.append(things_to_save, 'kpt_basis')
things_to_save.append('kpt_basis')
for it in things_to_save:
archive[self.dft_subgrp][it] = locals()[it]
@ -324,6 +333,12 @@ class Wannier90Converter(ConverterTools):
if self.misc_subgrp not in archive:
archive.create_group(self.misc_subgrp)
archive[self.misc_subgrp]['dft_fermi_energy'] = fermi_energy
if symm_kpath_info is not None:
archive[self.misc_subgrp].create_group('symm_kpath')
kpath_grp = archive[self.misc_subgrp]['symm_kpath']
kpath_grp['kpts'] = symm_kpath_info[0]
kpath_grp['labels'] = symm_kpath_info[1]
kpath_grp['label_idx'] = symm_kpath_info[2]
if self.bloch_basis:
archive[self.misc_subgrp]['dft_fermi_weights'] = f_weights
archive[self.misc_subgrp]['band_window'] = band_window+1 # Change to 1-based index
@ -620,7 +635,7 @@ def read_wannier90_blochbasis_data(wannier_seed, n_wannier_spin):
assert ks_eigenvals_spin.shape[1] == num_ks_bands, '.eig and u_dis.mat data inconsistent'
if disentangle:
# In case the disentanglement window is not set by the user, change manually both limits to
# In case the disentanglement window is not set by the user, change manually both limits to
# larger window to avoid possible counting error in next line
dis_tol = 1e-5
shift_dis_down = np.any(np.isclose(np.min(ks_eigenvals_spin, axis=1), dis_window_min, atol=dis_tol, rtol=0.) == True)
@ -665,6 +680,59 @@ def read_wannier90_blochbasis_data(wannier_seed, n_wannier_spin):
return u_mat_spin, udis_mat_spin, ks_eigenvals_spin, k_mesh
def read_wannier90_centres(wannier_seed):
centres_filename = wannier_seed + '_centres.xyz'
if not os.path.isfile(centres_filename):
mpi.report(f'Wannier centres file, {centres_filename}, does not exist. Please set: '
'write_xyz = true, translate_home_cell = false if you want to use the centres.')
return None
else:
mpi.report(f'Wannier centres read from file: {centres_filename}')
centres = []
with open(centres_filename, 'r') as c_file:
c_data = c_file.readlines()
mpi.report('Reading {}: {}'.format(centres_filename, c_data[1].strip()))
for l in c_data:
if l[0] == 'X':
x = np.asarray(l.split())
R = x[1:].astype(float)
centres.append(R)
centres = np.asarray(centres)
return centres
def read_wannier90_symm_kpath(wannier_seed):
kpath_filename = wannier_seed + '_band.kpt'
label_filename = wannier_seed + '_band.labelinfo.dat'
if not os.path.isfile(kpath_filename) or not os.path.isfile(label_filename):
return None
labels = ''
label_idx = []
with open(label_filename, 'r') as label_file:
label_data = label_file.readlines()
for line in label_data:
l, idx = line.split()[:2]
labels += l
label_idx.append(int(idx))
label_idx = np.asarray(label_idx)
kpts_interpolate = []
with open(kpath_filename, 'r') as path_file:
linelist = path_file.readlines()
mpi.report('Reading {}: high-symmetry path \'{}\' for '
'band structure'.format(kpath_filename, labels))
for line in linelist[1:]:
x = np.asarray(line.split()[:-1])
x = x.astype(float)
kpts_interpolate.append(x)
kpts_interpolate = np.asarray(kpts_interpolate)
return kpts_interpolate, labels, label_idx
def read_all_wannier90_data(n_spin_blocks, dim_corr_shells, w90_seed, add_lambda, bloch_basis):
"""
Reads in all the wannier90 data using the functions read_wannier90_hr_data
@ -690,9 +758,12 @@ def read_all_wannier90_data(n_spin_blocks, dim_corr_shells, w90_seed, add_lambda
Number of bands
k_mesh_from_umat : np.ndarray[n_k, 3] of float
The k points as used in wannier for consistency. None if not bloch_basis
centres: np.ndarray[n_spin_blocks, 3, 3] of float or None
Centres of wannier functions
"""
spin_w90name = ['_up', '_down']
wannier_hr = []
centres = []
if bloch_basis:
u_mat = []
udis_mat = []
@ -721,6 +792,11 @@ def read_all_wannier90_data(n_spin_blocks, dim_corr_shells, w90_seed, add_lambda
# U matrices, U(dis) matrices, band energies, k_mesh of U matrices
u_mat_spin, udis_mat_spin, ks_eigenvals_spin, k_mesh_from_umat = mpi.bcast(w90_results)
w90_centres_results = None
if mpi.is_master_node():
w90_centres_results = read_wannier90_centres(file_seed)
centres_spin = mpi.bcast(w90_centres_results)
mpi.report('\n... done: {} R vectors, {} WFs found'.format(n_r_spin, n_wannier_spin))
if add_lambda:
@ -763,6 +839,7 @@ def read_all_wannier90_data(n_spin_blocks, dim_corr_shells, w90_seed, add_lambda
assert np.all(r_degeneracy_spin == r_degeneracy), 'R vec. degeneracy different between spin components'
wannier_hr.append(wannier_hr_spin)
centres.append(centres_spin)
if bloch_basis:
u_mat.append(u_mat_spin)
udis_mat.append(udis_mat_spin)
@ -777,9 +854,10 @@ def read_all_wannier90_data(n_spin_blocks, dim_corr_shells, w90_seed, add_lambda
ks_eigenvals = None
k_mesh_from_umat = None
wannier_hr = np.array(wannier_hr)
centres = np.array(centres) if centres[0] is not None else None
return (wannier_hr, u_total, ks_eigenvals, r_vector, r_degeneracy,
n_wannier, n_bands, k_mesh_from_umat)
n_wannier, n_bands, k_mesh_from_umat, centres)
def build_kmesh(kmesh_size, kmesh_mode=0):

View File

@ -0,0 +1,343 @@
342
0.000000 0.000000 0.000000 1.0
0.005000 0.000000 0.000000 1.0
0.010000 0.000000 0.000000 1.0
0.015000 0.000000 0.000000 1.0
0.020000 0.000000 0.000000 1.0
0.025000 0.000000 0.000000 1.0
0.030000 0.000000 0.000000 1.0
0.035000 0.000000 0.000000 1.0
0.040000 0.000000 0.000000 1.0
0.045000 0.000000 0.000000 1.0
0.050000 0.000000 0.000000 1.0
0.055000 0.000000 0.000000 1.0
0.060000 0.000000 0.000000 1.0
0.065000 0.000000 0.000000 1.0
0.070000 0.000000 0.000000 1.0
0.075000 0.000000 0.000000 1.0
0.080000 0.000000 0.000000 1.0
0.085000 0.000000 0.000000 1.0
0.090000 0.000000 0.000000 1.0
0.095000 0.000000 0.000000 1.0
0.100000 0.000000 0.000000 1.0
0.105000 0.000000 0.000000 1.0
0.110000 0.000000 0.000000 1.0
0.115000 0.000000 0.000000 1.0
0.120000 0.000000 0.000000 1.0
0.125000 0.000000 0.000000 1.0
0.130000 0.000000 0.000000 1.0
0.135000 0.000000 0.000000 1.0
0.140000 0.000000 0.000000 1.0
0.145000 0.000000 0.000000 1.0
0.150000 0.000000 0.000000 1.0
0.155000 0.000000 0.000000 1.0
0.160000 0.000000 0.000000 1.0
0.165000 0.000000 0.000000 1.0
0.170000 0.000000 0.000000 1.0
0.175000 0.000000 0.000000 1.0
0.180000 0.000000 0.000000 1.0
0.185000 0.000000 0.000000 1.0
0.190000 0.000000 0.000000 1.0
0.195000 0.000000 0.000000 1.0
0.200000 0.000000 0.000000 1.0
0.205000 0.000000 0.000000 1.0
0.210000 0.000000 0.000000 1.0
0.215000 0.000000 0.000000 1.0
0.220000 0.000000 0.000000 1.0
0.225000 0.000000 0.000000 1.0
0.230000 0.000000 0.000000 1.0
0.235000 0.000000 0.000000 1.0
0.240000 0.000000 0.000000 1.0
0.245000 0.000000 0.000000 1.0
0.250000 0.000000 0.000000 1.0
0.255000 0.000000 0.000000 1.0
0.260000 0.000000 0.000000 1.0
0.265000 0.000000 0.000000 1.0
0.270000 0.000000 0.000000 1.0
0.275000 0.000000 0.000000 1.0
0.280000 0.000000 0.000000 1.0
0.285000 0.000000 0.000000 1.0
0.290000 0.000000 0.000000 1.0
0.295000 0.000000 0.000000 1.0
0.300000 0.000000 0.000000 1.0
0.305000 0.000000 0.000000 1.0
0.310000 0.000000 0.000000 1.0
0.315000 0.000000 0.000000 1.0
0.320000 0.000000 0.000000 1.0
0.325000 0.000000 0.000000 1.0
0.330000 0.000000 0.000000 1.0
0.335000 0.000000 0.000000 1.0
0.340000 0.000000 0.000000 1.0
0.345000 0.000000 0.000000 1.0
0.350000 0.000000 0.000000 1.0
0.355000 0.000000 0.000000 1.0
0.360000 0.000000 0.000000 1.0
0.365000 0.000000 0.000000 1.0
0.370000 0.000000 0.000000 1.0
0.375000 0.000000 0.000000 1.0
0.380000 0.000000 0.000000 1.0
0.385000 0.000000 0.000000 1.0
0.390000 0.000000 0.000000 1.0
0.395000 0.000000 0.000000 1.0
0.400000 0.000000 0.000000 1.0
0.405000 0.000000 0.000000 1.0
0.410000 0.000000 0.000000 1.0
0.415000 0.000000 0.000000 1.0
0.420000 0.000000 0.000000 1.0
0.425000 0.000000 0.000000 1.0
0.430000 0.000000 0.000000 1.0
0.435000 0.000000 0.000000 1.0
0.440000 0.000000 0.000000 1.0
0.445000 0.000000 0.000000 1.0
0.450000 0.000000 0.000000 1.0
0.455000 0.000000 0.000000 1.0
0.460000 0.000000 0.000000 1.0
0.465000 0.000000 0.000000 1.0
0.470000 0.000000 0.000000 1.0
0.475000 0.000000 0.000000 1.0
0.480000 0.000000 0.000000 1.0
0.485000 0.000000 0.000000 1.0
0.490000 0.000000 0.000000 1.0
0.495000 0.000000 0.000000 1.0
0.500000 0.000000 0.000000 1.0
0.500000 0.005000 0.000000 1.0
0.500000 0.010000 0.000000 1.0
0.500000 0.015000 0.000000 1.0
0.500000 0.020000 0.000000 1.0
0.500000 0.025000 0.000000 1.0
0.500000 0.030000 0.000000 1.0
0.500000 0.035000 0.000000 1.0
0.500000 0.040000 0.000000 1.0
0.500000 0.045000 0.000000 1.0
0.500000 0.050000 0.000000 1.0
0.500000 0.055000 0.000000 1.0
0.500000 0.060000 0.000000 1.0
0.500000 0.065000 0.000000 1.0
0.500000 0.070000 0.000000 1.0
0.500000 0.075000 0.000000 1.0
0.500000 0.080000 0.000000 1.0
0.500000 0.085000 0.000000 1.0
0.500000 0.090000 0.000000 1.0
0.500000 0.095000 0.000000 1.0
0.500000 0.100000 0.000000 1.0
0.500000 0.105000 0.000000 1.0
0.500000 0.110000 0.000000 1.0
0.500000 0.115000 0.000000 1.0
0.500000 0.120000 0.000000 1.0
0.500000 0.125000 0.000000 1.0
0.500000 0.130000 0.000000 1.0
0.500000 0.135000 0.000000 1.0
0.500000 0.140000 0.000000 1.0
0.500000 0.145000 0.000000 1.0
0.500000 0.150000 0.000000 1.0
0.500000 0.155000 0.000000 1.0
0.500000 0.160000 0.000000 1.0
0.500000 0.165000 0.000000 1.0
0.500000 0.170000 0.000000 1.0
0.500000 0.175000 0.000000 1.0
0.500000 0.180000 0.000000 1.0
0.500000 0.185000 0.000000 1.0
0.500000 0.190000 0.000000 1.0
0.500000 0.195000 0.000000 1.0
0.500000 0.200000 0.000000 1.0
0.500000 0.205000 0.000000 1.0
0.500000 0.210000 0.000000 1.0
0.500000 0.215000 0.000000 1.0
0.500000 0.220000 0.000000 1.0
0.500000 0.225000 0.000000 1.0
0.500000 0.230000 0.000000 1.0
0.500000 0.235000 0.000000 1.0
0.500000 0.240000 0.000000 1.0
0.500000 0.245000 0.000000 1.0
0.500000 0.250000 0.000000 1.0
0.500000 0.255000 0.000000 1.0
0.500000 0.260000 0.000000 1.0
0.500000 0.265000 0.000000 1.0
0.500000 0.270000 0.000000 1.0
0.500000 0.275000 0.000000 1.0
0.500000 0.280000 0.000000 1.0
0.500000 0.285000 0.000000 1.0
0.500000 0.290000 0.000000 1.0
0.500000 0.295000 0.000000 1.0
0.500000 0.300000 0.000000 1.0
0.500000 0.305000 0.000000 1.0
0.500000 0.310000 0.000000 1.0
0.500000 0.315000 0.000000 1.0
0.500000 0.320000 0.000000 1.0
0.500000 0.325000 0.000000 1.0
0.500000 0.330000 0.000000 1.0
0.500000 0.335000 0.000000 1.0
0.500000 0.340000 0.000000 1.0
0.500000 0.345000 0.000000 1.0
0.500000 0.350000 0.000000 1.0
0.500000 0.355000 0.000000 1.0
0.500000 0.360000 0.000000 1.0
0.500000 0.365000 0.000000 1.0
0.500000 0.370000 0.000000 1.0
0.500000 0.375000 0.000000 1.0
0.500000 0.380000 0.000000 1.0
0.500000 0.385000 0.000000 1.0
0.500000 0.390000 0.000000 1.0
0.500000 0.395000 0.000000 1.0
0.500000 0.400000 0.000000 1.0
0.500000 0.405000 0.000000 1.0
0.500000 0.410000 0.000000 1.0
0.500000 0.415000 0.000000 1.0
0.500000 0.420000 0.000000 1.0
0.500000 0.425000 0.000000 1.0
0.500000 0.430000 0.000000 1.0
0.500000 0.435000 0.000000 1.0
0.500000 0.440000 0.000000 1.0
0.500000 0.445000 0.000000 1.0
0.500000 0.450000 0.000000 1.0
0.500000 0.455000 0.000000 1.0
0.500000 0.460000 0.000000 1.0
0.500000 0.465000 0.000000 1.0
0.500000 0.470000 0.000000 1.0
0.500000 0.475000 0.000000 1.0
0.500000 0.480000 0.000000 1.0
0.500000 0.485000 0.000000 1.0
0.500000 0.490000 0.000000 1.0
0.500000 0.495000 0.000000 1.0
0.500000 0.500000 0.000000 1.0
0.496454 0.496454 0.000000 1.0
0.492908 0.492908 0.000000 1.0
0.489362 0.489362 0.000000 1.0
0.485816 0.485816 0.000000 1.0
0.482270 0.482270 0.000000 1.0
0.478723 0.478723 0.000000 1.0
0.475177 0.475177 0.000000 1.0
0.471631 0.471631 0.000000 1.0
0.468085 0.468085 0.000000 1.0
0.464539 0.464539 0.000000 1.0
0.460993 0.460993 0.000000 1.0
0.457447 0.457447 0.000000 1.0
0.453901 0.453901 0.000000 1.0
0.450355 0.450355 0.000000 1.0
0.446809 0.446809 0.000000 1.0
0.443262 0.443262 0.000000 1.0
0.439716 0.439716 0.000000 1.0
0.436170 0.436170 0.000000 1.0
0.432624 0.432624 0.000000 1.0
0.429078 0.429078 0.000000 1.0
0.425532 0.425532 0.000000 1.0
0.421986 0.421986 0.000000 1.0
0.418440 0.418440 0.000000 1.0
0.414894 0.414894 0.000000 1.0
0.411348 0.411348 0.000000 1.0
0.407801 0.407801 0.000000 1.0
0.404255 0.404255 0.000000 1.0
0.400709 0.400709 0.000000 1.0
0.397163 0.397163 0.000000 1.0
0.393617 0.393617 0.000000 1.0
0.390071 0.390071 0.000000 1.0
0.386525 0.386525 0.000000 1.0
0.382979 0.382979 0.000000 1.0
0.379433 0.379433 0.000000 1.0
0.375887 0.375887 0.000000 1.0
0.372340 0.372340 0.000000 1.0
0.368794 0.368794 0.000000 1.0
0.365248 0.365248 0.000000 1.0
0.361702 0.361702 0.000000 1.0
0.358156 0.358156 0.000000 1.0
0.354610 0.354610 0.000000 1.0
0.351064 0.351064 0.000000 1.0
0.347518 0.347518 0.000000 1.0
0.343972 0.343972 0.000000 1.0
0.340426 0.340426 0.000000 1.0
0.336879 0.336879 0.000000 1.0
0.333333 0.333333 0.000000 1.0
0.329787 0.329787 0.000000 1.0
0.326241 0.326241 0.000000 1.0
0.322695 0.322695 0.000000 1.0
0.319149 0.319149 0.000000 1.0
0.315603 0.315603 0.000000 1.0
0.312057 0.312057 0.000000 1.0
0.308511 0.308511 0.000000 1.0
0.304965 0.304965 0.000000 1.0
0.301418 0.301418 0.000000 1.0
0.297872 0.297872 0.000000 1.0
0.294326 0.294326 0.000000 1.0
0.290780 0.290780 0.000000 1.0
0.287234 0.287234 0.000000 1.0
0.283688 0.283688 0.000000 1.0
0.280142 0.280142 0.000000 1.0
0.276596 0.276596 0.000000 1.0
0.273050 0.273050 0.000000 1.0
0.269504 0.269504 0.000000 1.0
0.265957 0.265957 0.000000 1.0
0.262411 0.262411 0.000000 1.0
0.258865 0.258865 0.000000 1.0
0.255319 0.255319 0.000000 1.0
0.251773 0.251773 0.000000 1.0
0.248227 0.248227 0.000000 1.0
0.244681 0.244681 0.000000 1.0
0.241135 0.241135 0.000000 1.0
0.237589 0.237589 0.000000 1.0
0.234043 0.234043 0.000000 1.0
0.230496 0.230496 0.000000 1.0
0.226950 0.226950 0.000000 1.0
0.223404 0.223404 0.000000 1.0
0.219858 0.219858 0.000000 1.0
0.216312 0.216312 0.000000 1.0
0.212766 0.212766 0.000000 1.0
0.209220 0.209220 0.000000 1.0
0.205674 0.205674 0.000000 1.0
0.202128 0.202128 0.000000 1.0
0.198582 0.198582 0.000000 1.0
0.195035 0.195035 0.000000 1.0
0.191489 0.191489 0.000000 1.0
0.187943 0.187943 0.000000 1.0
0.184397 0.184397 0.000000 1.0
0.180851 0.180851 0.000000 1.0
0.177305 0.177305 0.000000 1.0
0.173759 0.173759 0.000000 1.0
0.170213 0.170213 0.000000 1.0
0.166667 0.166667 0.000000 1.0
0.163121 0.163121 0.000000 1.0
0.159574 0.159574 0.000000 1.0
0.156028 0.156028 0.000000 1.0
0.152482 0.152482 0.000000 1.0
0.148936 0.148936 0.000000 1.0
0.145390 0.145390 0.000000 1.0
0.141844 0.141844 0.000000 1.0
0.138298 0.138298 0.000000 1.0
0.134752 0.134752 0.000000 1.0
0.131206 0.131206 0.000000 1.0
0.127660 0.127660 0.000000 1.0
0.124113 0.124113 0.000000 1.0
0.120567 0.120567 0.000000 1.0
0.117021 0.117021 0.000000 1.0
0.113475 0.113475 0.000000 1.0
0.109929 0.109929 0.000000 1.0
0.106383 0.106383 0.000000 1.0
0.102837 0.102837 0.000000 1.0
0.099291 0.099291 0.000000 1.0
0.095745 0.095745 0.000000 1.0
0.092199 0.092199 0.000000 1.0
0.088652 0.088652 0.000000 1.0
0.085106 0.085106 0.000000 1.0
0.081560 0.081560 0.000000 1.0
0.078014 0.078014 0.000000 1.0
0.074468 0.074468 0.000000 1.0
0.070922 0.070922 0.000000 1.0
0.067376 0.067376 0.000000 1.0
0.063830 0.063830 0.000000 1.0
0.060284 0.060284 0.000000 1.0
0.056738 0.056738 0.000000 1.0
0.053191 0.053191 0.000000 1.0
0.049645 0.049645 0.000000 1.0
0.046099 0.046099 0.000000 1.0
0.042553 0.042553 0.000000 1.0
0.039007 0.039007 0.000000 1.0
0.035461 0.035461 0.000000 1.0
0.031915 0.031915 0.000000 1.0
0.028369 0.028369 0.000000 1.0
0.024823 0.024823 0.000000 1.0
0.021277 0.021277 0.000000 1.0
0.017730 0.017730 0.000000 1.0
0.014184 0.014184 0.000000 1.0
0.010638 0.010638 0.000000 1.0
0.007092 0.007092 0.000000 1.0
0.003546 0.003546 0.000000 1.0
0.000000 0.000000 0.000000 1.0

View File

@ -0,0 +1,4 @@
G 1 0.0000000000 0.0000000000 0.0000000000 0.0000000000
X 101 0.8140161212 0.5000000000 0.0000000000 0.0000000000
M 201 1.6280322423 0.5000000000 0.5000000000 0.0000000000
G 342 2.7792248809 0.0000000000 0.0000000000 0.0000000000