Skip to content

Commit

Permalink
Merge pull request #894 from dwhswenson/update_run_until_decorrelated
Browse files Browse the repository at this point in the history
`run_until_decorrelated` should account for time reversibility
  • Loading branch information
dwhswenson committed Jan 29, 2020
2 parents 99603ea + b5fdc86 commit eeb6665
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
11 changes: 9 additions & 2 deletions openpathsampling/pathsimulators/path_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def run_until(self, n_steps):
n_steps_to_run = n_steps - self.step
self.run(n_steps_to_run)

def run_until_decorrelated(self):
def run_until_decorrelated(self, time_reversal=True):
"""Run until all trajectories are decorrelated.
This runs until all the replicas in ``self.sample_set`` have
Expand All @@ -204,7 +204,8 @@ def run_until_decorrelated(self):
self.output_stream = open(os.devnull, 'w')

def n_correlated(sample_set, originals):
return sum([originals[r].is_correlated(sample_set[r])
return sum([originals[r].is_correlated(sample_set[r],
time_reversal)
for r in originals])

original_output_stream.write("Decorrelating trajectories....\n")
Expand All @@ -220,6 +221,12 @@ def n_correlated(sample_set, originals):
self.run(1)
to_decorrelate = n_correlated(self.sample_set, originals)

paths.tools.refresh_output(
"Step {}: All trajectories decorrelated!\n".format(self.step+1),
refresh=False,
output_stream=original_output_stream
)

self.output_stream = original_output_stream

def run(self, n_steps):
Expand Down
25 changes: 19 additions & 6 deletions openpathsampling/tests/test_pathsimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,22 @@ def setup(self):
pes=pes)
self.engine = paths.engines.toy.Engine(options={'integ': integ},
topology=topology)
network = paths.TPSNetwork(self.state_A, self.state_B)

interfaces = paths.VolumeInterfaceSet(self.cv, float("-inf"),
[0.0, 0.1, 0.2])
network = paths.MISTISNetwork([
(self.state_A, interfaces, self.state_B)
])
init_traj = make_1d_traj([-0.1, 0.2, 0.5, 0.8, 1.1])
scheme = paths.OneWayShootingMoveScheme(
network=network,
selector=paths.UniformSelector(),
engine=self.engine
)
scheme = paths.MoveScheme(network)
scheme.append([
paths.strategies.OneWayShootingStrategy(
selector=paths.UniformSelector(),
engine=self.engine
),
paths.strategies.PathReversalStrategy(),
paths.strategies.OrganizeByMoveGroupStrategy()
])
init_cond = scheme.initial_conditions_from_trajectories(init_traj)
self.sim = PathSampling(storage=None, move_scheme=scheme,
sample_set=init_cond)
Expand All @@ -680,3 +689,7 @@ def all_snaps(sample_set):
self.sim.run_until_decorrelated()
final_snaps = all_snaps(self.sim.sample_set)
assert initial_snaps & final_snaps == set([])
# test time reversal
init_xyz = set(s.xyz.tostring() for s in initial_snaps)
final_xyz = set(s.xyz.tostring() for s in final_snaps)
assert init_xyz & final_xyz == set([])

0 comments on commit eeb6665

Please sign in to comment.