Skip to content

Commit

Permalink
Merge pull request #1465 from pyiron/solvation_energy
Browse files Browse the repository at this point in the history
parse ediel_sol from OUTCAR
  • Loading branch information
jan-janssen authored Jun 26, 2024
2 parents 17dfcfa + 0ea63e6 commit a0a3318
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyiron_atomistics/vasp/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def collect(self, directory=os.getcwd(), sorted_indices=None):
self.generic_output.dft_log_dict["cbm_list"] = self.outcar.parse_dict[
"cbm_list"
]
self.generic_output.dft_log_dict["ediel_sol"] = self.outcar.parse_dict[
"ediel_sol"
]

if vasprun_working:
log_dict["forces"] = self.vp_new.vasprun_dict["forces"]
Expand Down
27 changes: 27 additions & 0 deletions pyiron_atomistics/vasp/parser/outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def from_file(self, filename="OUTCAR"):
energies_int = self.get_energy_without_entropy(filename=filename, lines=lines)
energies_zero = self.get_energy_sigma_0(filename=filename, lines=lines)
scf_energies = self.get_all_total_energies(filename=filename, lines=lines)
ediel_sol = self.get_ediel_sol(filename=filename, lines=lines)
n_atoms = self.get_number_of_atoms(filename=filename, lines=lines)
forces = self.get_forces(filename=filename, lines=lines, n_atoms=n_atoms)
positions = self.get_positions(filename=filename, lines=lines, n_atoms=n_atoms)
Expand Down Expand Up @@ -101,6 +102,7 @@ def from_file(self, filename="OUTCAR"):
self.parse_dict["energies_int"] = energies_int
self.parse_dict["energies_zero"] = energies_zero
self.parse_dict["scf_energies"] = scf_energies
self.parse_dict["ediel_sol"] = ediel_sol
self.parse_dict["forces"] = forces
self.parse_dict["positions"] = positions
self.parse_dict["cells"] = cells
Expand Down Expand Up @@ -484,6 +486,31 @@ def get_energy_sigma_0_from_line(line):
[get_energy_sigma_0_from_line(lines[j + 4]) for j in trigger_indices]
)

@staticmethod
def get_ediel_sol(filename="OUTCAR", lines=None):
"""
Gets the ediel_sol for every ionic step from the OUTCAR file
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
"""

def get_ediel_sol_from_line(line):
return float(_clean_line(line.strip()).split()[-1])

trigger_indices, lines = _get_trigger(
lines=lines,
filename=filename,
trigger="Solvation Ediel_sol = ",
)
return np.array([get_ediel_sol_from_line(lines[j]) for j in trigger_indices])

@staticmethod
def get_all_total_energies(filename="OUTCAR", lines=None):
"""
Expand Down
19 changes: 19 additions & 0 deletions tests/vasp/test_outcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,25 @@ def test_get_memory_used(self):
memory_usage_dict[int(filename.split("/OUTCAR_")[-1])]
)

def test_get_ediel_sol(self):
ediel_sol_dict = {
1: [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
10: [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
2: [],
3: [],
4: [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
5: [],
6: [],
7: [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
8: [],
9: [0., 0., 0., 0.],
}
for filename in self.file_list:
self.assertTrue(np.all(np.isclose(
self.outcar_parser.get_ediel_sol(filename),
ediel_sol_dict[int(filename.split("/OUTCAR_")[-1])]
)))

def test_get_cpu_time(self):
cpu_time_dict = {
1: 3.543,
Expand Down

0 comments on commit a0a3318

Please sign in to comment.