In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import openpathsampling as paths
import ops_piggybacker as oink
In [2]:
from openpathsampling.tests.test_helpers import make_1d_traj
traj1 = make_1d_traj([-0.9, 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 8.1, 9.1, 10.1])
traj2 = make_1d_traj([-0.8, 1.2])
traj3 = make_1d_traj([5.3, 8.3, 11.3])
traj4 = make_1d_traj([-0.6, 1.4, 3.4, 5.4, 7.4])
traj5 = make_1d_traj([-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5])
The input to the pseudo-simulator is a list of data related to the move. For one-way shooting, you need the following information with each move:
0
)+1
, backward is -1
)The moves
object below is a list of tuples of that information, in the order listed above. This is what you need to create from your previous simulation.
In [3]:
moves = [
(0, traj2, 3, True, -1),
(0, traj3, 4, True, +1),
(0, traj4, 6, False, -1),
(0, traj5, 6, True, -1)
]
From here, you've already done everything that needs to be done to reshape your already-run simulation. Now you just need to create the fake OPS simulations.
In [4]:
# volumes
cv = paths.FunctionCV("x", lambda snap: snap.xyz[0][0])
left_state = paths.CVDefinedVolume(cv, float("-inf"), 0.0)
right_state = paths.CVDefinedVolume(cv, 10.0, float("inf"))
In [5]:
# network
network = paths.TPSNetwork(left_state, right_state)
ensemble = network.sampling_ensembles[0] # the only one
In [6]:
initial_conditions = paths.SampleSet([
paths.Sample(replica=0,
trajectory=traj1,
ensemble=ensemble)
])
In [7]:
shoot = oink.ShootingStub(ensemble, pre_joined=False)
In [8]:
sim = oink.ShootingPseudoSimulator(storage=paths.Storage('one_way.nc', 'w'),
initial_conditions=initial_conditions,
mover=shoot,
network=network)
In [9]:
sim.run(moves)
In [10]:
sim.storage.close()
In [11]:
analysis_file = paths.AnalysisStorage("one_way.nc")
In [12]:
scheme = analysis_file.schemes[0]
scheme.move_summary(analysis_file.steps)
In [13]:
import openpathsampling.visualize as ops_vis
from IPython.display import SVG
history = ops_vis.PathTree(
analysis_file.steps,
ops_vis.ReplicaEvolution(replica=0)
)
# switch to the "boxcar" look for the trajectories
history.options.movers['default']['new'] = 'single'
history.options.css['horizontal_gap'] = True
SVG(history.svg())
Out[13]:
In [14]:
path_lengths = [len(step.active[0].trajectory) for step in analysis_file.steps]
plt.hist(path_lengths, alpha=0.5);
In [15]:
cv_x = analysis_file.cvs['x']
# load the active trajectory as storage.steps[step_num].active[replica_id]
plt.plot(cv_x(analysis_file.steps[2].active[0]), 'o-');
In [ ]: