-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForceFields.pyx
155 lines (117 loc) · 4.02 KB
/
ForceFields.pyx
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import numpy as np
cimport numpy as np
cimport ForceFields
cimport cython
DTYPE = np.float64
cdef class Force:
cpdef int evaluate(self,np.ndarray[DTYPE_t, ndim=1] coords, np.ndarray[DTYPE_t, ndim=1] force):
return 0
cdef class RouxPanForce(Force):
"""
2-dimensional potential defined in:
Pan and Roux (2008) Building Markov state models along pathways to determine free energies and rates of transitions
J. Chem. Phys. 129, 064107; doi:10.1063/1.2959573
"""
@cython.boundscheck(False)
@cython.wraparound(False)
cpdef int evaluate(self,np.ndarray[DTYPE_t, ndim=1] coords, np.ndarray[DTYPE_t, ndim=1] force):
cdef double x,y,x2,y2,t1,t2,t3,fx,fy
x = coords[0]
y = coords[1]
x2 = x**2
y2 = y**2
t1 = exp(-y2 - (1 - x)**2)
t2 = exp(-y2 - (1 + x)**2)
t3 = exp(-(8.0/25)*(x2 + y2 + 20.0*(x + y)**2))
fx = -3.0*(2.0 - 2.0*x)*t1 \
+ 3.0*(2 + 2*x)*t2 \
- 15.0*(8.0/25)*(2*x + 20.0*(2*x + 2*y))*t3 \
+ 4*(32.0/625)*x**3
fy = 6.0*y*t1 \
+ 6.0*y*t2 \
-15.0*(8.0/25)*(2*y + 20.0*(2*x + 2*y))*t3 \
+ 4*(32.0/625)*y**3 \
-4.0*(2.0/5)*exp(-2.0 - 4.0*y)
force[0] = -fx
force[1] = -fy
return 0
cdef class MuellerForce(Force):
"""
2-dimensional potential defined in:
Muller, K., and Brown, L.D. 1979. Location of saddle points and minimum energy paths by a constrained simplex
optimization procedure. Theoret. Chem. Acta 53, 75-93.
"""
@cython.boundscheck(False)
@cython.wraparound(False)
cpdef int evaluate(self,np.ndarray[DTYPE_t, ndim=1] coords, np.ndarray[DTYPE_t, ndim=1] force):
cdef double x,y,fx,fy,b, xt, yt
x = coords[0]
y = coords[1]
fx = 0
fy = 0
# 0
b = -200.0*exp(-(x-1.0)**2 - 10.0*y**2)
fx += -2.0*(x-1.0)*b
fy += -20.0*y*b
# 1
b = -100.0*exp(-x**2 -10.0*(y-0.5)**2)
fx += -2.0*x*b
fy += -20.0*(y-0.5)*b
#2
xt = x+0.5
yt = y-1.5
b = -170.0*exp(-6.5*xt**2 + 11.0*xt*yt -6.5*yt**2)
fx += (-13.0*xt + 11.0*yt)*b
fy += (11.0*xt -13.0*yt)*b
#3
xt = x+1
yt = y-1
b = 15.0*exp(0.7*xt**2 + 0.6*xt*yt + 0.7*yt**2)
fx += (1.4*xt + 0.6*yt)*b
fy += (0.6*xt + 1.4*yt)*b
force[0] = -fx
force[1] = -fy
return 0
cdef class RuggedMuellerForce(Force):
"""
Rugged version of the 2-dimensional potential defined in:
Muller, K., and Brown, L.D. 1979. Location of saddle points and minimum energy paths by a constrained simplex
optimization procedure. Theoret. Chem. Acta 53, 75-93.
"""
@cython.boundscheck(False)
@cython.wraparound(False)
cpdef int evaluate(self,np.ndarray[DTYPE_t, ndim=1] coords, np.ndarray[DTYPE_t, ndim=1] force):
cdef double x,y,fx,fy,b,xt,yt
cdef double twopik,a
twopik = 5.0*6.283185307179586
a = 9.0
x = coords[0]
y = coords[1]
fx = 0
fy = 0
# 0
b = -200.0*exp(-(x-1.0)**2 - 10.0*y**2)
fx += -2.0*(x-1.0)*b
fy += -20.0*y*b
# 1
b = -100.0*exp(-x**2 -10.0*(y-0.5)**2)
fx += -2.0*x*b
fy += -20.0*(y-0.5)*b
#2
xt = x+0.5
yt = y-1.5
b = -170.0*exp(-6.5*xt**2 + 11.0*xt*yt -6.5*yt**2)
fx += (-13.0*xt + 11.0*yt)*b
fy += (11.0*xt -13.0*yt)*b
#3
xt = x+1
yt = y-1
b = 15.0*exp(0.7*xt**2 + 0.6*xt*yt + 0.7*yt**2)
fx += (1.4*xt + 0.6*yt)*b
fy += (0.6*xt + 1.4*yt)*b
# rugged terms
fx += a*twopik*cos(twopik*x)*sin(twopik*y)
fy += a*twopik*sin(twopik*x)*cos(twopik*y)
force[0] = -fx
force[1] = -fy
return 0