Time-dependent quintuple wellΒΆ

Demonstrates deeptime.data.time_dependent_quintuple_well(). The potential wells slowly oscillate around the origin.

 9 import matplotlib.pyplot as plt
10 import numpy as np
11 from matplotlib import animation
12
13 from deeptime.data import time_dependent_quintuple_well
14
15 random_state = np.random.RandomState(33)
16
17 cmap = plt.cm.viridis
18
19 system = time_dependent_quintuple_well(h=1e-4, n_steps=100, beta=5)
20 x = np.arange(-2.5, 2.5, 0.1)
21 y = np.arange(-2.5, 2.5, 0.1)
22 xy = np.meshgrid(x, y)
23
24 x0 = random_state.uniform(-2.5, 2.5, size=(100, 2))
25 trajs = system.trajectory(0., x0, length=500)
26
27 l = []
28 for t in np.arange(0., 20., 0.01):
29     V = system.potential(t, np.dstack(xy).reshape(-1, 2)).reshape(xy[0].shape)
30     l.append(V)
31 l = np.stack(l)
32
33 vmin = np.min(l)
34 vmax = np.max(l)
35
36 fig, ax = plt.subplots()
37 ax.set_xlim([np.min(xy[0]), np.max(xy[0])])
38 ax.set_ylim([np.min(xy[1]), np.max(xy[1])])
39 handle = ax.contourf(*xy, l[0], vmin=vmin, vmax=vmax, cmap=cmap, levels=1000)
40 scatter_handle = ax.scatter(*trajs[:, 0].T, color='red', zorder=100)
41 handles = [scatter_handle, handle]
42
43
44 def update(i):
45     out = [scatter_handle]
46     handles[0].set_offsets(trajs[:, i])
47     for tp in handles[1].collections:
48         tp.remove()
49     handles[1] = ax.contourf(*xy, l[i], vmin=vmin, vmax=vmax, cmap=cmap)
50     out += handles[1].collections
51     return out
52
53
54 ani = animation.FuncAnimation(fig, update, interval=50, blit=True, repeat=True, frames=trajs.shape[1])
55 plt.show()

Total running time of the script: ( 0 minutes 53.573 seconds)

Estimated memory usage: 63 MB