Skip to content

Commit

Permalink
Fix frame clearing for trajectory chunking.
Browse files Browse the repository at this point in the history
  • Loading branch information
lohedges committed Oct 16, 2024
1 parent 4665bcb commit def9309
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/somd2/runner/_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def __init__(
self._config.restart,
)

self._num_frames = 0
self._nrg_sample = 0
self._nrg_file = "energy_components.txt"

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)} "
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit def9309

Please sign in to comment.