Definition: "The gentlest ascent dynamics (Weinan and Zhou, 2011)
Application: "Atomistic simulations of rare events using gentlest ascent dynamics" (Samanta and Weinan, 2011)
Background:
Notes on Weinan and Zhou, 2011
Notes on Samanta and Weinan 2011
Next steps and generalization:
Implementation
(Based on MATLAB implementation: http://web.math.princeton.edu/string/gad/)
In [55]:
import numpy as np
import numpy.random as npr
import pylab as pl
%matplotlib inline
In [56]:
dt = 0.01
T = 100
ndim=2
X = np.zeros((T,ndim))
X[0] = [0.45,-0.45]
direction = -np.array([0.87,0.07])
normalize = lambda vec : vec / np.sqrt(sum(vec**2))
direction = normalize(direction)
V = np.zeros((T,ndim))
In [57]:
from numpy import pi, sin, cos
In [58]:
def force(x):
return np.array((-pi*cos(pi*x[0])*sin(pi*x[1]),
-pi*sin(pi*x[0])*cos(pi*x[1])))
In [59]:
force(X[0])
Out[59]:
In [60]:
def hessian(x):
return pi**2 * np.array([[-sin(pi*x[0])*sin(pi*x[1]),
cos(pi*x[0])*cos(pi*x[1])],
[cos(pi*x[0])*cos(pi*x[1]),
-sin(pi*x[0])*sin(pi*x[1])]])
In [61]:
hessian(X[0])
Out[61]:
In [68]:
for b in range(10):
#direction = npr.randn(2)
#direction = normalize(direction)
for i in range(T-1):
F = force(X[i])# + npr.randn(ndim)*0.01
H = hessian(X[i]).T# + npr.randn(ndim,ndim)*0.01
c1 = direction.dot(F)
X[i+1] = X[i] + F*dt - 2*dt*c1.dot(direction)
direction = normalize(direction - dt*H.dot(direction))
pl.plot(X[:,0],X[:,1])
In [69]:
c1
Out[69]:
In [70]:
direction
Out[70]:
In [41]:
normalize(direction)
Out[41]:
MD-GAD
In [ ]: