Skip to content

Commit

Permalink
Update writing of hdf5 data
Browse files Browse the repository at this point in the history
  • Loading branch information
ladinesa committed Apr 19, 2024
1 parent c6fb75e commit 162b4da
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions atomisticparsers/gromacs/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 162b4da

Please sign in to comment.