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 numpy as np
|
||||
import re
|
||||
from h5 import HDFArchive
|
||||
|
||||
log = logging.getLogger('plovasp.vaspio')
|
||||
|
||||
@ -87,20 +88,17 @@ class VaspData:
|
||||
self.eigenval.ferw = None
|
||||
log.warning("Error reading from EIGENVAL, trying LOCPROJ...")
|
||||
|
||||
try:
|
||||
self.doscar.from_file(vasp_dir)
|
||||
except (IOError, StopIteration):
|
||||
if efermi_required:
|
||||
log.warning("Error reading Efermi from DOSCAR, trying LOCPROJ...")
|
||||
try:
|
||||
self.plocar.efermi
|
||||
self.doscar.efermi = self.plocar.efermi
|
||||
except NameError:
|
||||
raise Exception("Efermi cannot be read from DOSCAR or LOCPROJ")
|
||||
else:
|
||||
if efermi_required:
|
||||
try:
|
||||
with HDFArchive(vasp_dir + "vasptriqs.h5", 'r') as ar:
|
||||
self.doscar.efermi = ar['triqs/efermi']
|
||||
print(f'Fermi energy read from vasptriqs.h5: {self.doscar.efermi:.4f} eV')
|
||||
except NameError:
|
||||
raise Exception("Efermi cannot be read from vasptriqs.h5 file")
|
||||
else:
|
||||
# TODO: This a hack. Find out a way to determine ncdij without DOSCAR
|
||||
log.warning("Error reading Efermi from DOSCAR, taking from config")
|
||||
self.doscar.ncdij = self.plocar.nspin
|
||||
log.warning("Error reading Efermi from DOSCAR, taking from config")
|
||||
self.doscar.ncdij = self.plocar.nspin
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
@ -175,11 +173,6 @@ class Plocar:
|
||||
|
||||
self.nspin_band = 2 if self.ncdij == 2 else 1
|
||||
|
||||
try:
|
||||
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)
|
||||
proj_params = [{} for i in range(nproj)]
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
General SumK class and helper functions for combining ab-initio code and triqs
|
||||
"""
|
||||
|
||||
import os
|
||||
from types import *
|
||||
import numpy as np
|
||||
import triqs.utility.dichotomy as dichotomy
|
||||
@ -2332,6 +2333,14 @@ class SumkDFT(object):
|
||||
f.write(" %.14f %.14f"%(valre, valim))
|
||||
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':
|
||||
# output each k-point density matrix for Elk
|
||||
if mpi.is_master_node():
|
||||
|
Loading…
Reference in New Issue
Block a user