mirror of
https://github.com/triqs/dft_tools
synced 2024-12-22 12:23:41 +01:00
[vasp] read fermi from vasp h5 archive and write deltaN to vasp h5 archive
This commit is contained in:
parent
d810576024
commit
f57080a6af
@ -40,6 +40,7 @@ r"""
|
|||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import re
|
import re
|
||||||
|
from h5 import HDFArchive
|
||||||
|
|
||||||
log = logging.getLogger('plovasp.vaspio')
|
log = logging.getLogger('plovasp.vaspio')
|
||||||
|
|
||||||
@ -87,20 +88,17 @@ class VaspData:
|
|||||||
self.eigenval.ferw = None
|
self.eigenval.ferw = None
|
||||||
log.warning("Error reading from EIGENVAL, trying LOCPROJ...")
|
log.warning("Error reading from EIGENVAL, trying LOCPROJ...")
|
||||||
|
|
||||||
try:
|
if efermi_required:
|
||||||
self.doscar.from_file(vasp_dir)
|
try:
|
||||||
except (IOError, StopIteration):
|
with HDFArchive(vasp_dir + "vasptriqs.h5", 'r') as ar:
|
||||||
if efermi_required:
|
self.doscar.efermi = ar['triqs/efermi']
|
||||||
log.warning("Error reading Efermi from DOSCAR, trying LOCPROJ...")
|
print(f'Fermi energy read from vasptriqs.h5: {self.doscar.efermi:.4f} eV')
|
||||||
try:
|
except NameError:
|
||||||
self.plocar.efermi
|
raise Exception("Efermi cannot be read from vasptriqs.h5 file")
|
||||||
self.doscar.efermi = self.plocar.efermi
|
else:
|
||||||
except NameError:
|
|
||||||
raise Exception("Efermi cannot be read from DOSCAR or LOCPROJ")
|
|
||||||
else:
|
|
||||||
# TODO: This a hack. Find out a way to determine ncdij without DOSCAR
|
# TODO: This a hack. Find out a way to determine ncdij without DOSCAR
|
||||||
log.warning("Error reading Efermi from DOSCAR, taking from config")
|
log.warning("Error reading Efermi from DOSCAR, taking from config")
|
||||||
self.doscar.ncdij = self.plocar.nspin
|
self.doscar.ncdij = self.plocar.nspin
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -168,24 +166,19 @@ class Plocar:
|
|||||||
line = line.split("#")[0]
|
line = line.split("#")[0]
|
||||||
sline = line.split()
|
sline = line.split()
|
||||||
self.ncdij, nk, self.nband, nproj = list(map(int, sline[0:4]))
|
self.ncdij, nk, self.nband, nproj = list(map(int, sline[0:4]))
|
||||||
|
|
||||||
# VASP.6.
|
# VASP.6.
|
||||||
self.nspin = self.ncdij if self.ncdij < 4 else 1
|
self.nspin = self.ncdij if self.ncdij < 4 else 1
|
||||||
log.debug("ISPIN is {}".format(self.nspin))
|
log.debug("ISPIN is {}".format(self.nspin))
|
||||||
|
|
||||||
self.nspin_band = 2 if self.ncdij == 2 else 1
|
|
||||||
|
|
||||||
try:
|
self.nspin_band = 2 if self.ncdij == 2 else 1
|
||||||
self.efermi = float(sline[4])
|
|
||||||
except:
|
|
||||||
log.warning("Error reading Efermi from LOCPROJ, trying DOSCAR...")
|
|
||||||
|
|
||||||
plo = np.zeros((nproj, self.nspin, nk, self.nband), dtype=complex)
|
plo = np.zeros((nproj, self.nspin, nk, self.nband), dtype=complex)
|
||||||
proj_params = [{} for i in range(nproj)]
|
proj_params = [{} for i in range(nproj)]
|
||||||
|
|
||||||
iproj_site = 0
|
iproj_site = 0
|
||||||
is_first_read = True
|
is_first_read = True
|
||||||
|
|
||||||
# VASP.6.
|
# VASP.6.
|
||||||
if self.ncdij == 4:
|
if self.ncdij == 4:
|
||||||
self.nc_flag = 1
|
self.nc_flag = 1
|
||||||
@ -218,9 +211,9 @@ class Plocar:
|
|||||||
proj_params[ip]['m'] = m
|
proj_params[ip]['m'] = m
|
||||||
|
|
||||||
ip +=1
|
ip +=1
|
||||||
|
|
||||||
line = f.readline().strip()
|
line = f.readline().strip()
|
||||||
|
|
||||||
assert ip == nproj, "Number of projectors in the header is wrong in LOCPROJ"
|
assert ip == nproj, "Number of projectors in the header is wrong in LOCPROJ"
|
||||||
|
|
||||||
self.eigs = np.zeros((nk, self.nband, self.nspin_band))
|
self.eigs = np.zeros((nk, self.nband, self.nspin_band))
|
||||||
@ -243,7 +236,7 @@ class Plocar:
|
|||||||
line = f.readline()
|
line = f.readline()
|
||||||
sline = line.split()
|
sline = line.split()
|
||||||
ctmp = complex(float(sline[1]), float(sline[2]))
|
ctmp = complex(float(sline[1]), float(sline[2]))
|
||||||
plo[ip, ispin, ik, ib] = ctmp
|
plo[ip, ispin, ik, ib] = ctmp
|
||||||
|
|
||||||
print("Read parameters: LOCPROJ")
|
print("Read parameters: LOCPROJ")
|
||||||
for il, par in enumerate(proj_params):
|
for il, par in enumerate(proj_params):
|
||||||
@ -580,7 +573,7 @@ class Doscar:
|
|||||||
|
|
||||||
# First line: NION, NION, JOBPAR, NCDIJ
|
# First line: NION, NION, JOBPAR, NCDIJ
|
||||||
sline = next(f).split()
|
sline = next(f).split()
|
||||||
|
|
||||||
# Skip next 4 lines
|
# Skip next 4 lines
|
||||||
for _ in range(4):
|
for _ in range(4):
|
||||||
sline = next(f)
|
sline = next(f)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
General SumK class and helper functions for combining ab-initio code and triqs
|
General SumK class and helper functions for combining ab-initio code and triqs
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
from types import *
|
from types import *
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import triqs.utility.dichotomy as dichotomy
|
import triqs.utility.dichotomy as dichotomy
|
||||||
@ -2332,6 +2333,14 @@ class SumkDFT(object):
|
|||||||
f.write(" %.14f %.14f"%(valre, valim))
|
f.write(" %.14f %.14f"%(valre, valim))
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
|
if os.path.isfile('vasptriqs.h5'):
|
||||||
|
with HDFArchive('vasptriqs.h5', 'a') as vasp_h5:
|
||||||
|
if 'triqs' not in vasp_h5:
|
||||||
|
vasp_h5.create_group('triqs')
|
||||||
|
vasp_h5['triqs']['band_window'] = band_window
|
||||||
|
vasp_h5['triqs']['deltaN'] = deltaN
|
||||||
|
|
||||||
|
|
||||||
elif dm_type == 'elk':
|
elif dm_type == 'elk':
|
||||||
# output each k-point density matrix for Elk
|
# output each k-point density matrix for Elk
|
||||||
if mpi.is_master_node():
|
if mpi.is_master_node():
|
||||||
|
Loading…
Reference in New Issue
Block a user