From be1d900dca41b2bc5448be0d646c22baaede8d9a Mon Sep 17 00:00:00 2001 From: Jing Yang Date: Tue, 25 Jun 2024 15:23:21 +0200 Subject: [PATCH 1/4] parse ediel_sol from OUTCAR --- pyiron_atomistics/vasp/base.py | 2 +- pyiron_atomistics/vasp/parser/outcar.py | 29 +++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/pyiron_atomistics/vasp/base.py b/pyiron_atomistics/vasp/base.py index a3e915418..72de6b490 100644 --- a/pyiron_atomistics/vasp/base.py +++ b/pyiron_atomistics/vasp/base.py @@ -2077,7 +2077,7 @@ 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"] log_dict["cells"] = self.vp_new.vasprun_dict["cells"] diff --git a/pyiron_atomistics/vasp/parser/outcar.py b/pyiron_atomistics/vasp/parser/outcar.py index 4d573f56b..be2e8079f 100644 --- a/pyiron_atomistics/vasp/parser/outcar.py +++ b/pyiron_atomistics/vasp/parser/outcar.py @@ -52,6 +52,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) @@ -96,6 +97,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 @@ -479,6 +481,33 @@ 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): """ From 714b95d9a0634d8246331adfae547da82c15de74 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 26 Jun 2024 13:42:56 +0200 Subject: [PATCH 2/4] parse ediel_sol from OUTCAR --- pyiron_atomistics/vasp/output.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyiron_atomistics/vasp/output.py b/pyiron_atomistics/vasp/output.py index 2ade8bfeb..b2ab74fb7 100644 --- a/pyiron_atomistics/vasp/output.py +++ b/pyiron_atomistics/vasp/output.py @@ -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"] From ca290260582a4840f0a7076a1c685edd0b3a9f8d Mon Sep 17 00:00:00 2001 From: pyiron-runner Date: Wed, 26 Jun 2024 11:55:51 +0000 Subject: [PATCH 3/4] Format black --- pyiron_atomistics/vasp/parser/outcar.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyiron_atomistics/vasp/parser/outcar.py b/pyiron_atomistics/vasp/parser/outcar.py index 3f3d4d565..69670517a 100644 --- a/pyiron_atomistics/vasp/parser/outcar.py +++ b/pyiron_atomistics/vasp/parser/outcar.py @@ -509,9 +509,7 @@ def get_ediel_sol_from_line(line): filename=filename, trigger="Solvation Ediel_sol = ", ) - return np.array( - [get_ediel_sol_from_line(lines[j]) for j in trigger_indices] - ) + 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): From 0ea63e6252ee08a78b071442a6e363ec4e9029e0 Mon Sep 17 00:00:00 2001 From: Jan Janssen Date: Wed, 26 Jun 2024 15:55:01 +0200 Subject: [PATCH 4/4] Add unit test --- tests/vasp/test_outcar.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/vasp/test_outcar.py b/tests/vasp/test_outcar.py index 73aa993e1..cfb5c747b 100644 --- a/tests/vasp/test_outcar.py +++ b/tests/vasp/test_outcar.py @@ -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,