From 162b4dad6b87670082951e346a6a60f717efb3c2 Mon Sep 17 00:00:00 2001 From: Alvin Noe Ladines Date: Fri, 19 Apr 2024 11:20:02 +0200 Subject: [PATCH] Update writing of hdf5 data --- atomisticparsers/gromacs/parser.py | 39 ++++-------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) diff --git a/atomisticparsers/gromacs/parser.py b/atomisticparsers/gromacs/parser.py index 9be1bf08..7ea851e5 100644 --- a/atomisticparsers/gromacs/parser.py +++ b/atomisticparsers/gromacs/parser.py @@ -55,7 +55,6 @@ ) from atomisticparsers.utils import MDAnalysisParser, MDParser from nomad.atomutils import get_bond_list_from_model_contributions -from nomad.parsing.parser import to_hdf5 re_float = r"[-+]?\d+\.*\d*(?:[Ee][-+]\d+)?" re_n = r"[\n\r]" @@ -1447,44 +1446,16 @@ def parse_workflow(self): self.parse_md_workflow(dict(method=method, results=results)) - if flag_fe: - filename = os.path.join( - os.path.dirname(self.mainfile.split("/raw/")[-1]), - f"{os.path.basename(self.mainfile)}.archive.hdf5", - ) - if not os.path.isfile( - os.path.join(os.path.dirname(self.mainfile), filename) - ): - if self.archive.m_context: - with self.archive.m_context.raw_file(filename, "wb") as f: - pass + if flag_fe and self.archive.m_context: sec_fe_parameters = ( self.archive.workflow2.method.free_energy_calculation_parameters[0] ) sec_fe = self.archive.workflow2.results.free_energy_calculations[0] sec_fe.method_ref = sec_fe_parameters - if self.archive.m_context: - with self.archive.m_context.raw_file(filename, "r+b") as f: - sec_fe.value_total_energy_magnitude = to_hdf5( - columns[:, 0], - f, - f"{sec_fe.m_path()}/value_total_energy_magnitude", - ) - sec_fe.value_total_energy_derivative_magnitude = to_hdf5( - columns[:, 1], - f, - f"{sec_fe.m_path()}/value_total_energy_derivative_magnitude", - ) - sec_fe.value_total_energy_differences_magnitude = to_hdf5( - columns[:, 2:-1], - f, - f"{sec_fe.m_path()}/value_total_energy_differences_magnitude", - ) - sec_fe.value_PV_energy_magnitude = to_hdf5( - columns[:, -1], - f, - f"{sec_fe.m_path()}/value_PV_energy_magnitude", - ) + sec_fe.value_total_energy_magnitude = columns[:, 0] + sec_fe.value_total_energy_derivative_magnitude = columns[:, 1] + sec_fe.value_total_energy_differences_magnitude = columns[:, 2:-1] + sec_fe.value_PV_energy_magnitude = columns[:, -1] def parse_input(self): sec_run = self.archive.run[-1]