Skip to content

Commit

Permalink
Merge pull request #557 from pyiron/energy_components
Browse files Browse the repository at this point in the history
VASP Outcar: Get energy components
  • Loading branch information
jan-janssen authored Aug 15, 2022
2 parents 332e742 + 2309414 commit dee6fa9
Show file tree
Hide file tree
Showing 2 changed files with 501 additions and 0 deletions.
64 changes: 64 additions & 0 deletions pyiron_atomistics/vasp/outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def from_file(self, filename="OUTCAR"):
filename=filename, lines=lines
)
elastic_constants = self.get_elastic_constants(filename=filename, lines=lines)
energy_components = self.get_energy_components(filename=filename, lines=lines)
cpu_time = self.get_cpu_time(filename=filename, lines=lines)
user_time = self.get_user_time(filename=filename, lines=lines)
system_time = self.get_system_time(filename=filename, lines=lines)
Expand Down Expand Up @@ -114,6 +115,7 @@ def from_file(self, filename="OUTCAR"):
self.parse_dict["vbm_list"] = vbm_list
self.parse_dict["cbm_list"] = cbm_list
self.parse_dict["elastic_constants"] = elastic_constants
self.parse_dict["energy_components"] = energy_components
self.parse_dict["resources"] = {
"cpu_time": cpu_time,
"user_time": user_time,
Expand Down Expand Up @@ -155,6 +157,7 @@ def to_hdf_minimal(self, hdf, group_name="outcar"):
"irreducible_kpoints",
"irreducible_kpoint_weights",
"number_plane_waves",
"energy_components",
"resources",
]
with hdf.open(group_name) as hdf5_output:
Expand Down Expand Up @@ -1086,6 +1089,67 @@ def _get_cells_praser(lines, trigger_indices):
warnings.warn("Unable to parse the cells from the OUTCAR file")
return

@staticmethod
def get_energy_components(filename="OUTCAR", lines=None):
"""
Gets the individual components of the free energy energy for every electronic step from the OUTCAR file
alpha Z PSCENC = -0.19957337
Ewald energy TEWEN = -73.03212173
-Hartree energ DENC = -0.10933240
-exchange EXHF = 0.00000000
-V(xc)+E(xc) XCENC = -26.17018410
PAW double counting = 168.82497547 -136.88269783
entropy T*S EENTRO = -0.00827174
eigenvalues EBANDS = 10.35379785
atomic energy EATOM = 53.53616173
Solvation Ediel_sol = 0.00000000
Args:
filename (str): Filename of the OUTCAR file to parse
lines (list/None): lines read from the file
Returns:
numpy.ndarray: A 1xM array of the total energies in $eV$
where M is the number of time steps
"""
ind_ionic_lst, lines = _get_trigger(
trigger="FREE ENERGIE OF THE ION-ELECTRON SYSTEM (eV)",
filename=filename,
lines=lines,
return_lines=True,
)
ind_elec_lst = _get_trigger(
trigger="Free energy of the ion-electron system (eV)",
filename=None,
lines=lines,
return_lines=False,
)
ind_combo_lst = _split_indices(
ind_ionic_lst=ind_ionic_lst, ind_elec_lst=ind_elec_lst
)
try:
return [
np.array(
[
np.hstack(
[
float(lines[ind + i].split()[-1])
if i != 7
else [
float(lines[ind_lst[-1] + 7].split()[-2]),
float(lines[ind_lst[-1] + 7].split()[-1]),
]
for i in range(2, 12)
]
)
for ind in ind_lst
]
).T
for ind_lst in ind_combo_lst
]
except ValueError:
return []


def _clean_line(line):
return line.replace("-", " -")
Expand Down
Loading

0 comments on commit dee6fa9

Please sign in to comment.