mirror of
https://github.com/triqs/dft_tools
synced 2024-10-31 11:13:46 +01:00
update new vasp h5 interface to new structure
This commit is contained in:
parent
692bc85c9e
commit
44d791d90d
@ -74,11 +74,11 @@ class VaspData:
|
|||||||
def __init__(self, vasp_dir, read_all=True, efermi_required=True):
|
def __init__(self, vasp_dir, read_all=True, efermi_required=True):
|
||||||
self.vasp_dir = vasp_dir
|
self.vasp_dir = vasp_dir
|
||||||
|
|
||||||
# NEW vasptriqs.h5
|
# read from vaspout.h5 if possible
|
||||||
vasptriqs = os.path.isfile(os.path.join(vasp_dir, 'vasptriqs.h5'))
|
vasph5 = os.path.isfile(os.path.join(vasp_dir, 'vaspout.h5'))
|
||||||
if vasptriqs:
|
if vasph5:
|
||||||
log.warning("Reading from vasptriqs.h5")
|
log.warning("Reading from vaspout.h5")
|
||||||
h5path = os.path.join(vasp_dir, 'vasptriqs.h5')
|
h5path = os.path.join(vasp_dir, 'vaspout.h5')
|
||||||
self.plocar = h5Plocar(h5path)
|
self.plocar = h5Plocar(h5path)
|
||||||
self.poscar = h5Poscar(h5path)
|
self.poscar = h5Poscar(h5path)
|
||||||
self.kpoints = h5Kpoints(h5path)
|
self.kpoints = h5Kpoints(h5path)
|
||||||
@ -669,7 +669,7 @@ class h5Poscar:
|
|||||||
# self.q_cart = None
|
# self.q_cart = None
|
||||||
|
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
struct = archive['triqs']['structure']
|
struct = archive['results/positions']
|
||||||
ascale = struct['scale']
|
ascale = struct['scale']
|
||||||
self.a_brav = struct['lattice_vectors']
|
self.a_brav = struct['lattice_vectors']
|
||||||
self.nions = struct['number_ion_types']
|
self.nions = struct['number_ion_types']
|
||||||
@ -715,8 +715,8 @@ class h5Kpoints:
|
|||||||
|
|
||||||
# h5path = './vasptriqs.h5'
|
# h5path = './vasptriqs.h5'
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
kpoints = archive['triqs']['kpoints']
|
kpoints = archive['results/electron_eigenvalues']
|
||||||
self.nktot = kpoints['num_kpoints']
|
self.nktot = kpoints['kpoints']
|
||||||
self.kpts = kpoints['kpoint_coords']
|
self.kpts = kpoints['kpoint_coords']
|
||||||
self.kwghts = kpoints['kpoints_symmetry_weight']
|
self.kwghts = kpoints['kpoints_symmetry_weight']
|
||||||
try:
|
try:
|
||||||
@ -736,8 +736,8 @@ class h5Eigenval:
|
|||||||
|
|
||||||
def __init__(self, h5path):
|
def __init__(self, h5path):
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
self.eigs = archive['triqs']['eigenvalues']
|
self.eigs = archive['results/electron_eigenvalues']['eigenvalues']
|
||||||
self.ferw = archive['triqs']['fermi_weights']
|
self.ferw = archive['results/electron_eigenvalues']['fermiweights']
|
||||||
# TODO Change the format in VASP to have [kpoints, bands, spin]
|
# TODO Change the format in VASP to have [kpoints, bands, spin]
|
||||||
self.eigs = np.transpose(self.eigs, (1, 2, 0))
|
self.eigs = np.transpose(self.eigs, (1, 2, 0))
|
||||||
self.ferw = np.transpose(self.ferw, (1, 2, 0))
|
self.ferw = np.transpose(self.ferw, (1, 2, 0))
|
||||||
@ -747,15 +747,15 @@ class h5Doscar:
|
|||||||
|
|
||||||
def __init__(self, h5path):
|
def __init__(self, h5path):
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
self.efermi = archive['triqs']['efermi']
|
self.efermi = archive['results/electron_dos']['efermi']
|
||||||
|
|
||||||
|
|
||||||
class h5Plocar():
|
class h5Plocar():
|
||||||
|
|
||||||
def __init__(self, h5path):
|
def __init__(self, h5path):
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
plo = np.array(archive['triqs']['plo'])
|
plo = np.array(archive['results/locproj']['data'])
|
||||||
self.nc_flag = int(archive['triqs']['noncoll'])
|
self.nc_flag = int(archive['results/locproj/parameters']['lnoncollinear'])
|
||||||
|
|
||||||
self.nproj = plo.shape[0]
|
self.nproj = plo.shape[0]
|
||||||
self.ncdij = plo.shape[1]
|
self.ncdij = plo.shape[1]
|
||||||
@ -791,13 +791,13 @@ class h5Plocar():
|
|||||||
self.proj_params = [{} for i in range(self.nproj)]
|
self.proj_params = [{} for i in range(self.nproj)]
|
||||||
with HDFArchive(h5path, 'a') as archive:
|
with HDFArchive(h5path, 'a') as archive:
|
||||||
for it in range(self.nproj):
|
for it in range(self.nproj):
|
||||||
projectors = archive['triqs']['plo_parameters'][str(it + 1)]
|
projectors = archive['results/locproj']['parameters']
|
||||||
self.proj_params[it]['label'] = projectors['ang_type']
|
self.proj_params[it]['label'] = projectors['ang_type'][it]
|
||||||
self.proj_params[it]['isite'] = projectors['site']
|
self.proj_params[it]['isite'] = projectors['site'][it]
|
||||||
self.proj_params[it]['coord'] = projectors['coordinates']
|
self.proj_params[it]['coord'] = projectors['coordinates'][it]
|
||||||
|
|
||||||
for it in range(self.nproj):
|
for it in range(self.nproj):
|
||||||
lm = orb_labels.index(self.proj_params[it]['label'])
|
lm = orb_labels.index(self.proj_params[it]['label'].strip())
|
||||||
l, m = lm_to_l_m(lm)
|
l, m = lm_to_l_m(lm)
|
||||||
self.proj_params[it]['l'] = l
|
self.proj_params[it]['l'] = l
|
||||||
if self.nc_flag == True:
|
if self.nc_flag == True:
|
||||||
|
@ -2204,7 +2204,8 @@ class SumkDFT(object):
|
|||||||
if dm_type == 'wien2k':
|
if dm_type == 'wien2k':
|
||||||
filename = 'dens_mat.dat'
|
filename = 'dens_mat.dat'
|
||||||
elif dm_type == 'vasp':
|
elif dm_type == 'vasp':
|
||||||
filename = 'GAMMA'
|
# use new h5 interface to vasp by default, if not wanted specify dm_type='vasp' + filename='GAMMA'
|
||||||
|
filename = 'vaspgamma.h5'
|
||||||
elif dm_type == 'elk':
|
elif dm_type == 'elk':
|
||||||
filename = 'DMATDMFT.OUT'
|
filename = 'DMATDMFT.OUT'
|
||||||
elif dm_type == 'qe':
|
elif dm_type == 'qe':
|
||||||
@ -2353,12 +2354,10 @@ class SumkDFT(object):
|
|||||||
assert self.SP == 0, "Spin-polarized density matrix is not implemented"
|
assert self.SP == 0, "Spin-polarized density matrix is not implemented"
|
||||||
|
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
if os.path.isfile('vasptriqs.h5'):
|
if filename == 'vaspgamma.h5':
|
||||||
with HDFArchive('vasptriqs.h5', 'a') as vasp_h5:
|
with HDFArchive('vaspgamma.h5', 'w') as vasp_h5:
|
||||||
if 'triqs' not in vasp_h5:
|
vasp_h5['band_window'] = band_window
|
||||||
vasp_h5.create_group('triqs')
|
vasp_h5['deltaN'] = deltaN
|
||||||
vasp_h5['triqs']['band_window'] = band_window
|
|
||||||
vasp_h5['triqs']['deltaN'] = deltaN
|
|
||||||
else:
|
else:
|
||||||
with open(filename, 'w') as f:
|
with open(filename, 'w') as f:
|
||||||
f.write(" %i -1 ! Number of k-points, default number of bands\n" % len(kpts_to_write))
|
f.write(" %i -1 ! Number of k-points, default number of bands\n" % len(kpts_to_write))
|
||||||
|
Loading…
Reference in New Issue
Block a user