Skip to content

ASE backend: avoid duplicate sampling updates within a single MD timestep#376

Open
Songze1019 wants to merge 1 commit intoSSAGESLabs:mainfrom
Songze1019:fix/ase-backend
Open

ASE backend: avoid duplicate sampling updates within a single MD timestep#376
Songze1019 wants to merge 1 commit intoSSAGESLabs:mainfrom
Songze1019:fix/ase-backend

Conversation

@Songze1019
Copy link

Problem

In the ASE backend, Sampler.get_forces() may be called multiple times within a single MD timestep.
Previously, each call triggered:

  • snapshot refresh
  • method_update(...)
  • callback logging
    For metadynamics, this caused state.ncalls to advance faster than actual MD steps, leading to over-frequent hill deposition and mismatched hill step indexing.

Root Cause

pysages/backends/ase.py used force-call frequency as the effective update clock.
In ASE/Langevin workflows, force calls can occur multiple times per timestep.

Fix

In pysages/backends/ase.py, gate method updates by ASE MD timestep:

  • track self._last_update_timestep
  • run snapshot/update/callback only when timestep changes
  • still return forces + bias for every force request
    This preserves force application while preventing duplicate state advancement in the same timestep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant