Skip to content

Commit

Permalink
[feat] Vasp CSC read dft energy from h5 if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
the-hampel committed Jul 10, 2024
1 parent 6026267 commit 017d013
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions python/solid_dmft/dft_managers/vasp_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 017d013

Please sign in to comment.