-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathadv_tutorial_setup.py
More file actions
83 lines (59 loc) · 2.34 KB
/
Copy pathadv_tutorial_setup.py
File metadata and controls
83 lines (59 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
import openpathsampling as paths
from openpathsampling.engines import toy as toys
import numpy as np
pes = (
toys.OuterWalls(sigma=[1.0, 1.0], x0=[0.0, 0.0])
+ toys.Gaussian(A=-1.0, alpha=[12.0, 5.0], x0=[-0.6, 0.0])
+ toys.Gaussian(A=-1.0, alpha=[12.0, 5.0], x0=[0.6, 0.0])
)
topology = toys.Topology(n_spatial=2, masses=[1.0, 1.0], pes=pes)
integ = toys.LangevinBAOABIntegrator(dt=0.02, temperature=0.1, gamma=2.5)
options = {
'integ': integ,
'n_frames_max': 5000,
'n_steps_per_frame': 1
}
engine = toys.Engine(options, topology).named("toy_engine")
cv = paths.CoordinateFunctionCV("x", lambda snap: snap.xyz[0][0])
state_A = paths.CVDefinedVolume(cv, float("-inf"), -0.6).named("A")
state_B = paths.CVDefinedVolume(cv, 0.6, float("inf")).named("B")
snap = toys.Snapshot(velocities=np.array([[0.0, 0.0]]),
coordinates=np.array([[0.0, 0.0]]),
engine=engine)
randomizer = paths.RandomVelocities(beta=10.0, engine=engine)
committor_storage = paths.Storage("toy_committor.nc", mode='w')
committor = paths.CommittorSimulation(
storage=committor_storage,
engine=engine,
states=[state_A, state_B],
randomizer=randomizer,
initial_snapshots=[snap],
direction=1
)
committor.run(10)
committor_storage.close()
committor_storage = paths.Storage("toy_committor.nc", mode='r')
spa = paths.ShootingPointAnalysis(committor_storage.steps, [state_A, state_B])
end_A = [step for step in committor_storage.steps if state_A(step.change.canonical.trials[0][-1])]
end_B = [step for step in committor_storage.steps if state_B(step.change.canonical.trials[0][-1])]
part_A = end_A[-1].change.canonical.trials[0].trajectory.reversed
part_B = end_B[-1].change.canonical.trials[0].trajectory
traj = part_A + part_B[1:]
equil_network = paths.TPSNetwork(state_A, state_B)
scheme = paths.OneWayShootingMoveScheme(network=equil_network, engine=engine)
init_conds = scheme.initial_conditions_from_trajectories(traj)
sim = paths.PathSampling(
storage=None,
move_scheme=scheme,
sample_set=init_conds
)
sim.run_until_decorrelated()
sim.run(100)
setup_nc = paths.Storage("2_state_toy.nc", mode='w')
setup_nc.tags['initial_conditions'] = sim.sample_set
#setup_nc.save(sim.sample_set[0].trajectory)
setup_nc.save(state_A)
setup_nc.save(state_B)
setup_nc.save(engine)
setup_nc.close()