Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.

* Please add an item to this CHANGELOG for any new features or bug fixes when creating a PR.

* Run each ``Dynamics.run()`` block through to the next frame or energy save rather than
in fixed blocks of 50 steps, which cost a force evaluation and a GPU sync each. The 50
step blocks are kept when a progress bar is shown, since they only exist to update it.

`2026.2.0 <https://github.com/openbiosim/sire/compare/2026.1.0...2026.2.0>`__ - September 2026
----------------------------------------------------------------------------------------------

Expand Down
7 changes: 7 additions & 0 deletions src/sire/base/_progressbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from ..legacy.Base import ProgressBar as _ProgressBar

_cached_in_notebook = None
_is_silent = False


def _in_notebook():
Expand Down Expand Up @@ -113,4 +114,10 @@ def set_theme(theme):

@staticmethod
def set_silent():
global _is_silent
_is_silent = True
_ProgressBar.set_silent()

@staticmethod
def is_silent():
return _is_silent
38 changes: 17 additions & 21 deletions src/sire/mol/_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,35 +1405,31 @@ class NeedsMinimiseError(Exception):

with ThreadPoolExecutor() as pool:
while completed < steps_to_run:
block_size = 50
# Each block ends at the next frame or energy save, or the end
# of the run. Shorter blocks are only needed to update the
# progress bar, and cost a GPU sync each.
block_size = steps_to_run - completed
if not ProgressBar.is_silent():
block_size = min(block_size, 50)

steps_till_frame = self._next_save_frame - (
completed + nsteps_before_run
)
if steps_till_frame <= 0 or (
steps_till_frame <= block_size
and steps_till_frame <= steps_to_run - completed
):
save_frame = True
self._next_save_frame += frame_frequency_steps
if frame_frequency_steps < block_size:
block_size = frame_frequency_steps
else:
save_frame = False

steps_till_energy = self._next_save_energy - (
completed + nsteps_before_run
)
if steps_till_energy <= 0 or (
steps_till_energy <= block_size
and steps_till_energy <= steps_to_run - completed
):
save_energy = True
if 0 < steps_till_frame < block_size:
block_size = steps_till_frame
if 0 < steps_till_energy < block_size:
block_size = steps_till_energy

save_frame = steps_till_frame <= block_size
if save_frame:
self._next_save_frame += frame_frequency_steps

save_energy = steps_till_energy <= block_size
if save_energy:
self._next_save_energy += energy_frequency_steps
if energy_frequency_steps < block_size:
block_size = energy_frequency_steps
else:
save_energy = False

# save the last frame if we're about to exit and the user
# has requested it
Expand Down
Loading