Skip to content

Commit 55f0af4

Browse files
authored
Merge pull request #128 from OpenBioSim/fix_velocity_randomisation
Make repex velocity randomisation optional
2 parents f8077cd + 7a39b32 commit 55f0af4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/somd2/config/_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def __init__(
134134
opencl_platform_index=0,
135135
oversubscription_factor=1,
136136
replica_exchange=False,
137+
randomise_velocities=False,
137138
perturbed_system=None,
138139
gcmc=False,
139140
gcmc_frequency=None,
@@ -363,6 +364,9 @@ def __init__(
363364
Whether to run replica exchange simulation. Currently this can only be used when
364365
GPU resources are available.
365366
367+
randomise_velocities: bool
368+
Whether to randomise velocities at the start of each replica exchange cycle.
369+
366370
perturbed_system: str
367371
The path to a stream file containing a Sire system for the equilibrated perturbed
368372
end state (lambda = 1). This will be used as the starting conformation all lambda
@@ -539,6 +543,7 @@ def __init__(
539543
self.opencl_platform_index = opencl_platform_index
540544
self.oversubscription_factor = oversubscription_factor
541545
self.replica_exchange = replica_exchange
546+
self.randomise_velocities = randomise_velocities
542547
self.perturbed_system = perturbed_system
543548
self.gcmc = gcmc
544549
self.gcmc_frequency = gcmc_frequency
@@ -1645,6 +1650,16 @@ def replica_exchange(self, replica_exchange):
16451650
raise ValueError("'replica_exchange' must be of type 'bool'")
16461651
self._replica_exchange = replica_exchange
16471652

1653+
@property
1654+
def randomise_velocities(self):
1655+
return self._randomise_velocities
1656+
1657+
@randomise_velocities.setter
1658+
def randomise_velocities(self, randomise_velocities):
1659+
if not isinstance(randomise_velocities, bool):
1660+
raise ValueError("'randomise_velocities' must be of type 'bool'")
1661+
self._randomise_velocities = randomise_velocities
1662+
16481663
@property
16491664
def perturbed_system(self):
16501665
return self._perturbed_system

src/somd2/runner/_repex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,8 @@ def _run_block(
12401240
_logger.info(f"Running dynamics at {_lam_sym} = {lam:.5f}")
12411241

12421242
# Draw new velocities from the Maxwell-Boltzmann distribution.
1243-
dynamics.randomise_velocities()
1243+
if self._config.randomise_velocities:
1244+
dynamics.randomise_velocities()
12441245

12451246
# Run the dynamics.
12461247
dynamics.run(

0 commit comments

Comments
 (0)