Skip to content

Commit c8fd1e4

Browse files
committed
update new vasp h5 interface to new structure
1 parent 4b7f63d commit c8fd1e4

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

python/triqs_dft_tools/converters/plovasp/vaspio.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ class VaspData:
7474
def __init__(self, vasp_dir, read_all=True, efermi_required=True):
7575
self.vasp_dir = vasp_dir
7676

77-
# NEW vasptriqs.h5
78-
vasptriqs = os.path.isfile(os.path.join(vasp_dir, 'vasptriqs.h5'))
79-
if vasptriqs:
80-
log.warning("Reading from vasptriqs.h5")
81-
h5path = os.path.join(vasp_dir, 'vasptriqs.h5')
77+
# read from vaspout.h5 if possible
78+
vasph5 = os.path.isfile(os.path.join(vasp_dir, 'vaspout.h5'))
79+
if vasph5:
80+
log.warning("Reading from vaspout.h5")
81+
h5path = os.path.join(vasp_dir, 'vaspout.h5')
8282
self.plocar = h5Plocar(h5path)
8383
self.poscar = h5Poscar(h5path)
8484
self.kpoints = h5Kpoints(h5path)
@@ -669,7 +669,7 @@ def __init__(self, h5path):
669669
# self.q_cart = None
670670

671671
with HDFArchive(h5path, 'a') as archive:
672-
struct = archive['triqs']['structure']
672+
struct = archive['results/positions']
673673
ascale = struct['scale']
674674
self.a_brav = struct['lattice_vectors']
675675
self.nions = struct['number_ion_types']
@@ -715,8 +715,8 @@ def __init__(self, h5path):
715715

716716
# h5path = './vasptriqs.h5'
717717
with HDFArchive(h5path, 'a') as archive:
718-
kpoints = archive['triqs']['kpoints']
719-
self.nktot = kpoints['num_kpoints']
718+
kpoints = archive['results/electron_eigenvalues']
719+
self.nktot = kpoints['kpoints']
720720
self.kpts = kpoints['kpoint_coords']
721721
self.kwghts = kpoints['kpoints_symmetry_weight']
722722
try:
@@ -736,8 +736,8 @@ class h5Eigenval:
736736

737737
def __init__(self, h5path):
738738
with HDFArchive(h5path, 'a') as archive:
739-
self.eigs = archive['triqs']['eigenvalues']
740-
self.ferw = archive['triqs']['fermi_weights']
739+
self.eigs = archive['results/electron_eigenvalues']['eigenvalues']
740+
self.ferw = archive['results/electron_eigenvalues']['fermiweights']
741741
# TODO Change the format in VASP to have [kpoints, bands, spin]
742742
self.eigs = np.transpose(self.eigs, (1, 2, 0))
743743
self.ferw = np.transpose(self.ferw, (1, 2, 0))
@@ -747,15 +747,15 @@ class h5Doscar:
747747

748748
def __init__(self, h5path):
749749
with HDFArchive(h5path, 'a') as archive:
750-
self.efermi = archive['triqs']['efermi']
750+
self.efermi = archive['results/electron_dos']['efermi']
751751

752752

753753
class h5Plocar():
754754

755755
def __init__(self, h5path):
756756
with HDFArchive(h5path, 'a') as archive:
757-
plo = np.array(archive['triqs']['plo'])
758-
self.nc_flag = int(archive['triqs']['noncoll'])
757+
plo = np.array(archive['results/locproj']['data'])
758+
self.nc_flag = int(archive['results/locproj/parameters']['lnoncollinear'])
759759

760760
self.nproj = plo.shape[0]
761761
self.ncdij = plo.shape[1]
@@ -791,13 +791,13 @@ def lm_to_l_m(lm):
791791
self.proj_params = [{} for i in range(self.nproj)]
792792
with HDFArchive(h5path, 'a') as archive:
793793
for it in range(self.nproj):
794-
projectors = archive['triqs']['plo_parameters'][str(it + 1)]
795-
self.proj_params[it]['label'] = projectors['ang_type']
796-
self.proj_params[it]['isite'] = projectors['site']
797-
self.proj_params[it]['coord'] = projectors['coordinates']
794+
projectors = archive['results/locproj']['parameters']
795+
self.proj_params[it]['label'] = projectors['ang_type'][it]
796+
self.proj_params[it]['isite'] = projectors['site'][it]
797+
self.proj_params[it]['coord'] = projectors['coordinates'][it]
798798

799799
for it in range(self.nproj):
800-
lm = orb_labels.index(self.proj_params[it]['label'])
800+
lm = orb_labels.index(self.proj_params[it]['label'].strip())
801801
l, m = lm_to_l_m(lm)
802802
self.proj_params[it]['l'] = l
803803
if self.nc_flag == True:

python/triqs_dft_tools/sumk_dft.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,8 @@ def calc_density_correction(self, filename=None, dm_type=None, spinave=False, kp
22042204
if dm_type == 'wien2k':
22052205
filename = 'dens_mat.dat'
22062206
elif dm_type == 'vasp':
2207-
filename = 'GAMMA'
2207+
# use new h5 interface to vasp by default, if not wanted specify dm_type='vasp' + filename='GAMMA'
2208+
filename = 'vaspgamma.h5'
22082209
elif dm_type == 'elk':
22092210
filename = 'DMATDMFT.OUT'
22102211
elif dm_type == 'qe':
@@ -2353,12 +2354,10 @@ def calc_density_correction(self, filename=None, dm_type=None, spinave=False, kp
23532354
assert self.SP == 0, "Spin-polarized density matrix is not implemented"
23542355

23552356
if mpi.is_master_node():
2356-
if os.path.isfile('vasptriqs.h5'):
2357-
with HDFArchive('vasptriqs.h5', 'a') as vasp_h5:
2358-
if 'triqs' not in vasp_h5:
2359-
vasp_h5.create_group('triqs')
2360-
vasp_h5['triqs']['band_window'] = band_window
2361-
vasp_h5['triqs']['deltaN'] = deltaN
2357+
if filename == 'vaspgamma.h5':
2358+
with HDFArchive('vaspgamma.h5', 'w') as vasp_h5:
2359+
vasp_h5['band_window'] = band_window
2360+
vasp_h5['deltaN'] = deltaN
23622361
else:
23632362
with open(filename, 'w') as f:
23642363
f.write(" %i -1 ! Number of k-points, default number of bands\n" % len(kpts_to_write))

0 commit comments

Comments
 (0)