Skip to content

Commit 0a366f2

Browse files
committed
Sample all discrete flip states, not just nearest neighbours.
1 parent c5839c9 commit 0a366f2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/somd2/runner/_samplers/_terminal_flip.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,12 @@ def move(self, context):
455455
)
456456
e_old = state.getPotentialEnergy().value_in_unit(_omm_unit.kilojoule_per_mole)
457457

458-
# Random sign gives a symmetric proposal (detailed balance).
459-
signed_angle = float(_np.random.choice([-1, 1])) * angle
460-
self._rotate(context, group_idx, signed_angle)
458+
# Pick uniformly from the n-1 non-current states, where n = 360 / angle.
459+
# For 180° (n=2) this is equivalent to a random sign; for higher
460+
# symmetry orders it correctly samples any non-current state in one move.
461+
n = round(360.0 / angle)
462+
step = int(_np.random.randint(1, n))
463+
self._rotate(context, group_idx, step * angle)
461464

462465
# Evaluate the energy of the proposed configuration.
463466
e_new = (

0 commit comments

Comments
 (0)