From d307d35005f3d1fb72c8e037ef24174d8ab3ad1d Mon Sep 17 00:00:00 2001 From: Lester Hedges Date: Tue, 2 Dec 2025 16:15:29 +0000 Subject: [PATCH] Backport fix from PR #100. [ci skip] --- src/somd2/runner/_base.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/somd2/runner/_base.py b/src/somd2/runner/_base.py index 44eb11e..5066558 100644 --- a/src/somd2/runner/_base.py +++ b/src/somd2/runner/_base.py @@ -124,7 +124,8 @@ def __init__(self, system, config): # Flag whether frames are being saved. if ( - self._config.frame_frequency > 0 + self._config.save_trajectories + and self._config.frame_frequency > 0 and self._config.frame_frequency <= self._config.runtime ): self._save_frames = True @@ -1241,7 +1242,6 @@ def _compare_configs(config1, config2): "equilibration_timestep", "equilibration_constraints", "energy_frequency", - "save_trajectory", "frame_frequency", "save_velocities", "platform", @@ -1646,15 +1646,17 @@ def _checkpoint( _copyfile(traj_filename, f"{traj_filename}.prev") traj_chunks = [f"{traj_filename}.prev"] + traj_chunks - # Load the topology and chunked trajectory files. - mols = _sr.load([topology0] + traj_chunks) + # Make sure there are trajectory chunks to process. + if len(traj_chunks) > 0: + # Load the topology and chunked trajectory files. + mols = _sr.load([topology0] + traj_chunks) - # Save the final trajectory to a single file. - _sr.save(mols.trajectory(), traj_filename, format=["DCD"]) + # Save the final trajectory to a single file. + _sr.save(mols.trajectory(), traj_filename, format=["DCD"]) - # Now remove the chunked trajectory files. - for chunk in traj_chunks: - _Path(chunk).unlink() + # Now remove the chunked trajectory files. + for chunk in traj_chunks: + _Path(chunk).unlink() # Add config and lambda value to the system properties. system.set_property("config", self._config.as_dict(sire_compatible=True))