From def9309abe2537ae48aae41aedfdb7d78f733125 Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Wed, 16 Oct 2024 16:59:29 +0100 Subject: [PATCH] Fix frame clearing for trajectory chunking. --- src/somd2/runner/_dynamics.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/somd2/runner/_dynamics.py b/src/somd2/runner/_dynamics.py index 6e401d9..3a88172 100644 --- a/src/somd2/runner/_dynamics.py +++ b/src/somd2/runner/_dynamics.py @@ -126,6 +126,7 @@ def __init__( self._config.restart, ) + self._num_frames = 0 self._nrg_sample = 0 self._nrg_file = "energy_components.txt" @@ -489,11 +490,11 @@ def generate_lam_vals(lambda_base, increment): + f"{x}.dcd" ) sr.save( - self._system.trajectory(), traj_filename, format=["DCD"] + self._system.trajectory()[self._num_frames :], + traj_filename, + format=["DCD"], ) - - # Delete the trajectory from memory. - self._system.delete_all_frames() + self._num_frames = self._system.num_frames() # Stream the checkpoint to file. sr.stream.save(self._system, str(checkpoint_file)) @@ -557,11 +558,11 @@ def generate_lam_vals(lambda_base, increment): + f"{x}.dcd" ) sr.save( - self._system.trajectory(), traj_filename, format=["DCD"] + self._system.trajectory()[self._num_frames :], + traj_filename, + format=["DCD"], ) - - # Delete the trajectory from memory. - self._system.delete_all_frames() + self._num_frames = self._system.num_frames() _logger.info( f"Finished block {x+1} of {self._current_block + num_blocks + int(rem > 0)} " @@ -622,9 +623,7 @@ def generate_lam_vals(lambda_base, increment): self._config.output_directory / self._filenames["trajectory"] ) sr.save(system.trajectory(), traj_filename, format=["DCD"]) - - # Delete the trajectory from memory. - self._system.delete_all_frames() + self._num_frames = system.num_frames() # Now remove the chunked trajectory files. for chunk in traj_chunks: