Skip to content

Commit 86e14b0

Browse files
authored
Merge pull request #130 from OpenBioSim/fix_repex_sync
Fix repex restart state sychronisation
2 parents 1289f27 + cae3bf8 commit 86e14b0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/somd2/runner/_repex.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,15 +812,17 @@ def __init__(self, system, config):
812812
for i in range(len(self._lambda_values)):
813813
dynamics, gcmc_sampler = self._dynamics_cache.get(i)
814814

815-
# Reset the OpenMM state.
816-
dynamics.context().setState(self._dynamics_cache._openmm_states[i])
815+
# Reset the OpenMM state, applying the last replica exchange
816+
# mixing so the correct post-mix state is restored.
817+
state = self._dynamics_cache._states[i]
818+
dynamics.context().setState(self._dynamics_cache._openmm_states[state])
817819

818820
# Reset the GCMC water state.
819821
if gcmc_sampler is not None:
820822
gcmc_sampler.push()
821823
gcmc_sampler._set_water_state(
822824
dynamics.context(),
823-
states=self._dynamics_cache._gcmc_states[i],
825+
states=self._dynamics_cache._gcmc_states[state],
824826
force=True,
825827
)
826828
gcmc_sampler.pop()

0 commit comments

Comments
 (0)