Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new upcoming VASP hdf5 support capability #262

Open
wants to merge 9 commits into
base: unstable
Choose a base branch
from
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ jobs:
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
TRIQS_BRANCH: ${{ github.event_name == 'pull_request' && github.base_ref || github.ref_name }}
run: |
git clone https://github.com/TRIQS/triqs --branch unstable
git clone https://github.com/TRIQS/triqs --branch $TRIQS_BRANCH
mkdir triqs/build && cd triqs/build
cmake .. -DBuild_Tests=OFF -DCMAKE_INSTALL_PREFIX=$HOME/install
make -j1 install VERBOSE=1
Expand Down
18 changes: 6 additions & 12 deletions python/triqs_dft_tools/converters/plovasp/elstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,11 @@ def __init__(self, vasp_data):

# FIXME: Reading from EIGENVAL is obsolete and should be
# removed completely.
# if not vasp_data.eigenval.eigs is None:
if False:
if vasp_data.eigenval.eigs is not None:
print("eigvals from EIGENVAL")
self.eigvals = vasp_data.eigenval.eigs
self.ferw = vasp_data.eigenval.ferw.transpose((2, 0, 1))

nk_eig = vasp_data.eigenval.nktot
assert nk_eig == self.nktot, "PLOCAR is inconsistent with EIGENVAL (number of k-points)"

# Check that the number of band is the same in PROJCAR and EIGENVAL
assert nb_plo == self.nband, "PLOCAR is inconsistent with EIGENVAL (number of bands)"
self.efermi = vasp_data.doscar.efermi
else:
print("eigvals from LOCPROJ")
self.eigvals = vasp_data.plocar.eigs
Expand Down Expand Up @@ -151,7 +145,7 @@ def debug_density_matrix(self):

# Spin factor
sp_fac = 2.0 if ns == 1 and self.nc_flag == False else 1.0

if self.nc_flag == False:
den_mat = np.zeros((ns, nproj, nproj), dtype=float)
overlap = np.zeros((ns, nproj, nproj), dtype=float)
Expand Down Expand Up @@ -184,9 +178,9 @@ def debug_density_matrix(self):
out += " "
out += ''.join(map("{0:12.7f}".format, dov))
print(out)



else:
print("!! WARNING !! Non Collinear Routine")
den_mat = np.zeros((ns, nproj, nproj), dtype=float)
Expand Down
44 changes: 23 additions & 21 deletions python/triqs_dft_tools/converters/plovasp/sc_dmft.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,26 @@ def is_vasp_running(vasp_pid):
pid_exists = mpi.bcast(pid_exists)
return pid_exists


def get_dft_energy():
"""
Reads energy from the last line of OSZICAR.
Reads DFT energy from the last line of Vasp's OSZICAR or from vasptriqs.h5
"""
with open('OSZICAR', 'r') as f:
nextline = f.readline()
while nextline.strip():
line = nextline
nextline = f.readline()
# print "OSZICAR: ", line[:-1]
h5_energy = False
if os.path.isfile('vaspout.h5'):
with HDFArchive('vaspout.h5', 'r') as h5:
if 'oszicar' in h5['intermediate/ion_dynamics']:
dft_energy = h5['intermediate/ion_dynamics/oszicar'][-1,1]
h5_energy = True

try:
# as backup use OSZICAR file
if not h5_energy:
with open('OSZICAR', 'r') as file:
nextline = file.readline()
while nextline.strip():
line = nextline
nextline = file.readline()
dft_energy = float(line.split()[2])
except ValueError:
print("Cannot read energy from OSZICAR, setting it to zero")
dft_energy = 0.0

return dft_energy

Expand All @@ -98,9 +102,8 @@ class bcolors:
YELLOW = '\033[93m'
RED = '\033[91m'
ENDC = '\033[0m'
#

# Main self-consistent cycle
#
def run_all(vasp_pid, dmft_cycle, cfg_file, n_iter, n_iter_dft, vasp_version):
"""
"""
Expand All @@ -117,15 +120,14 @@ def run_all(vasp_pid, dmft_cycle, cfg_file, n_iter, n_iter_dft, vasp_version):
mpi.barrier()
while is_vasp_lock_present():
time.sleep(1)
# if debug: print bcolors.YELLOW + " waiting: rank %s"%(mpi.rank) + bcolors.ENDC
if debug: print(bcolors.YELLOW + " waiting: rank %s"%(mpi.rank) + bcolors.ENDC)
if not is_vasp_running(vasp_pid):
mpi.report(" VASP stopped")
vasp_running = False
break

# Tell VASP to stop if the maximum number of iterations is reached


# Tell VASP to stop if the maximum number of iterations is reached

if debug: print(bcolors.MAGENTA + "rank %s"%(mpi.rank) + bcolors.ENDC)
err = 0
exc = None
Expand Down Expand Up @@ -161,7 +163,7 @@ def run_all(vasp_pid, dmft_cycle, cfg_file, n_iter, n_iter_dft, vasp_version):
# electron.F around line 644
iter_dft = 0

if vasp_version == 'standard':
if vasp_version == 'standard' or vasp_version == 'ncl':
copyfile(src='GAMMA',dst='GAMMA_recent')
while iter_dft < n_iter_dft:
# insert recalculation of GAMMA here
Expand Down Expand Up @@ -190,7 +192,7 @@ def run_all(vasp_pid, dmft_cycle, cfg_file, n_iter, n_iter_dft, vasp_version):
vasp_running = False
break
iter_dft += 1
if vasp_version == 'standard':
if vasp_version == 'standard' or vasp_version == 'ncl':
copyfile(src='GAMMA_recent',dst='GAMMA')
iter += 1
if iter == n_iter:
Expand Down Expand Up @@ -253,8 +255,8 @@ def main():
except KeyError:
vasp_version = 'standard'

if vasp_version != 'standard' and vasp_version != 'no_gamma_write':
raise Exception('vasp_version has to be standard or no_gamma_write')
#if vasp_version != 'standard' and vasp_version != 'no_gamma_write':
# raise Exception('vasp_version has to be standard or no_gamma_write')

# if len(sys.argv) > 1:
# vasp_path = sys.argv[1]
Expand Down
Loading
Loading