From 017d013a90bf99e6a7b6c904c4b91cf672a9c350 Mon Sep 17 00:00:00 2001 From: Alexander Hampel Date: Wed, 10 Jul 2024 14:19:14 -0400 Subject: [PATCH] [feat] Vasp CSC read dft energy from h5 if possible --- python/solid_dmft/dft_managers/vasp_manager.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/python/solid_dmft/dft_managers/vasp_manager.py b/python/solid_dmft/dft_managers/vasp_manager.py index dccd7f09..3e764b2f 100644 --- a/python/solid_dmft/dft_managers/vasp_manager.py +++ b/python/solid_dmft/dft_managers/vasp_manager.py @@ -37,6 +37,7 @@ import numpy as np import triqs.utility.mpi as mpi +from h5 import HDFArchive from solid_dmft.dft_managers import mpi_helpers @@ -171,14 +172,18 @@ def run_charge_update(): def read_dft_energy(): """ - Reads DFT energy from the last line of Vasp's OSZICAR. + Reads DFT energy from the last line of Vasp's vasptriqs.h5 or from OSZICAR. """ - with open('OSZICAR', 'r') as file: - nextline = file.readline() - while nextline.strip(): - line = nextline + if os.path.isfile('vasptriqs.h5'): + with HDFArchive('vasptriqs.h5', 'r') as h5: + dft_energy = h5['triqs/etotal'] + else: + with open('OSZICAR', 'r') as file: nextline = file.readline() - dft_energy = float(line.split()[2]) + while nextline.strip(): + line = nextline + nextline = file.readline() + dft_energy = float(line.split()[2]) return dft_energy