-
Notifications
You must be signed in to change notification settings - Fork 1
/
compiledFunctions.f90
211 lines (167 loc) · 5.76 KB
/
compiledFunctions.f90
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!! HELIUM !!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine helium_test_function(N, r, alpha, psi)
implicit none
INTEGER(8), INTENT(IN) :: N
REAL(8), DIMENSION(N,6), INTENT(IN) :: r
REAL(8), INTENT(IN) :: alpha
REAL(8), DIMENSION(N) :: r1
REAL(8), DIMENSION(N) :: r2
REAL(8), DIMENSION(N) :: r12
REAL(8), DIMENSION(N), INTENT(OUT) :: psi
r1 = sqrt(sum(r(:,1:3)**2,2))
r2 = sqrt(sum(r(:,4:6)**2,2))
r12 = sqrt(sum((r(:,1:3)-r(:,4:6))*(r(:,1:3)-r(:,4:6)),2))
psi = exp(-2*(r1+r2) + r12/(2*(1 + alpha*r12)))
end subroutine helium_test_function
subroutine helium_local_energy(N, r, alpha, E)
implicit none
INTEGER(8), INTENT(IN) :: N
REAL(8), DIMENSION(N,6), INTENT(IN) :: r
REAL(8), INTENT(IN) :: alpha
REAL(8), DIMENSION(N) :: r1
REAL(8), DIMENSION(N) :: r2
REAL(8), DIMENSION(N) :: r12
REAL(8), DIMENSION(N) :: r12special
REAL(8), DIMENSION(N), INTENT(OUT) :: E
r1 = sqrt(sum(r(:,1:3)**2,2))
r2 = sqrt(sum(r(:,4:6)**2,2))
r12 = sqrt(sum((r(:,1:3)-r(:,4:6))*(r(:,1:3)-r(:,4:6)),2))
r12special = sum((r(:,1:3)/spread(r1,2,3) - r(:,4:6)/spread(r2,2,3))* &
(r(:,1:3)-r(:,4:6)),2)/r12
E = (-4 + r12special/(1 + alpha*r12)**2 - 1/(r12*(1 + alpha*r12)**3) -&
1/(4*(1 + alpha*r12)**4) + 1/r12)
end subroutine helium_local_energy
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!! HYDROGEN !!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine hydrogen_local_energy(N, v_r, beta, s, a, E, steep_descent_beta)
implicit none
!INPUT
INTEGER(8), INTENT(IN) :: N
REAL(8), DIMENSION(N,6), INTENT(IN) :: v_r
REAL(8), INTENT(IN) :: beta
REAL(8), INTENT(IN) :: s
REAL(8), INTENT(IN) :: a
!OUTPUT
REAL(8), DIMENSION(N), INTENT(OUT) :: E
REAL(8), DIMENSION(N), INTENT(OUT) :: steep_descent_beta
!DUMMYS
!POSITIONS
REAL(8), DIMENSION(N,3) :: v_r1
REAL(8), DIMENSION(N,3) :: v_r2
REAL(8), DIMENSION(N,3) :: v_h
REAL(8), DIMENSION(N,3) :: v_r1L
REAL(8), DIMENSION(N,3) :: v_r1R
REAL(8), DIMENSION(N,3) :: v_r2L
REAL(8), DIMENSION(N,3) :: v_r2R
REAL(8), DIMENSION(N,3) :: v_r12
REAL(8), DIMENSION(N,3) :: v_special
!DISTANCES
REAL(8), DIMENSION(N) :: r1
REAL(8), DIMENSION(N) :: r2
REAL(8), DIMENSION(N) :: r1L
REAL(8), DIMENSION(N) :: r1R
REAL(8), DIMENSION(N) :: r2L
REAL(8), DIMENSION(N) :: r2R
REAL(8), DIMENSION(N) :: r12
REAL(8), DIMENSION(N) :: special
!INTERMEDIATE EXPRESSIONS
REAL(8), DIMENSION(N) :: phi1
REAL(8), DIMENSION(N) :: phi2
REAL(8), DIMENSION(N) :: phi1L
REAL(8), DIMENSION(N) :: phi1R
REAL(8), DIMENSION(N) :: phi2L
REAL(8), DIMENSION(N) :: phi2R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
v_r1 = v_r(:, 1:3)
v_r2 = v_r(:, 4:6)
v_h = spread((/ s/2.0_8, 0.0_8, 0.0_8 /),1,N)
v_r1L = v_r1 + v_h
v_r1R = v_r1 - v_h
v_r2L = v_r2 + v_h
v_r2R = v_r2 - v_h
v_r12 = v_r1 - v_r2
r1 = sqrt(sum(v_r1**2,2))
r2 = sqrt(sum(v_r2**2,2))
r1L = sqrt(sum(v_r1L**2,2))
r1R = sqrt(sum(v_r1R**2,2))
r2L = sqrt(sum(v_r2L**2,2))
r2R = sqrt(sum(v_r2R**2,2))
r12 = sqrt(sum(v_r12**2,2))
phi1L = exp(-r1L/a)
phi1R = exp(-r1R/a)
phi2L = exp(-r2L/a)
phi2R = exp(-r2R/a)
phi1 = phi1L + phi1R
phi2 = phi2L + phi2R
v_special = spread(phi1L/r1L/phi1,2,3) *v_r1L + spread(phi1R/r1R/phi1,2,3) *v_r1R &
- spread(phi2L/r2L/phi2,2,3) *v_r2L - spread(phi2R/r2R/phi2,2,3) *v_r2R
special = sum(v_special*v_r12,2)/(r12*2*a*(1+beta*r12)**2)
E = -1/a**2 + &
1/(a*phi1) * (phi1L/r1L + phi1R/r1R) + &
1/(a*phi2) * (phi2L/r2L + phi2R/r2R) + &
-(1/r1L + 1/r1R + 1/r2L + 1/r2R) + &
1/r12 + &
special + &
-((4*beta + 1)*r12 + 4)/(4*(1+beta*r12)**4 * r12)
steep_descent_beta = - r12**2 /(2 * (1 + beta*r12)**2 ) &
* phi1 * phi2 * exp(r12/(2* (1 + beta*r12)))
end subroutine hydrogen_local_energy
subroutine hydrogen_test_function(N, v_r, beta, s, a, psi)
implicit none
!INPUT
INTEGER(8), INTENT(IN) :: N
REAL(8), DIMENSION(N,6), INTENT(IN) :: v_r
REAL(8), INTENT(IN) :: beta
REAL(8), INTENT(IN) :: s
REAL(8), INTENT(IN) :: a
!OUTPUT
REAL(8), DIMENSION(N), INTENT(OUT) :: psi
!DUMMYS
!POSITIONS
REAL(8), DIMENSION(N,3) :: v_r1
REAL(8), DIMENSION(N,3) :: v_r2
REAL(8), DIMENSION(N,3) :: v_h
REAL(8), DIMENSION(N,3) :: v_r1L
REAL(8), DIMENSION(N,3) :: v_r1R
REAL(8), DIMENSION(N,3) :: v_r2L
REAL(8), DIMENSION(N,3) :: v_r2R
REAL(8), DIMENSION(N,3) :: v_r12
!DISTANCES
REAL(8), DIMENSION(N) :: r1
REAL(8), DIMENSION(N) :: r2
REAL(8), DIMENSION(N) :: r1L
REAL(8), DIMENSION(N) :: r1R
REAL(8), DIMENSION(N) :: r2L
REAL(8), DIMENSION(N) :: r2R
REAL(8), DIMENSION(N) :: r12
!INTERMEDIATE EXPRESSIONS
REAL(8), DIMENSION(N) :: phi1L
REAL(8), DIMENSION(N) :: phi1R
REAL(8), DIMENSION(N) :: phi2L
REAL(8), DIMENSION(N) :: phi2R
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
v_r1 = v_r(:, 1:3)
v_r2 = v_r(:, 4:6)
v_h = spread((/ s/2.0_8, 0.0_8, 0.0_8 /),1,N)
v_r1L = v_r1 + v_h
v_r1R = v_r1 - v_h
v_r2L = v_r2 + v_h
v_r2R = v_r2 - v_h
v_r12 = v_r1 - v_r2
r1 = sqrt(sum(v_r1**2,2))
r2 = sqrt(sum(v_r2**2,2))
r1L = sqrt(sum(v_r1L**2,2))
r1R = sqrt(sum(v_r1R**2,2))
r2L = sqrt(sum(v_r2L**2,2))
r2R = sqrt(sum(v_r2R**2,2))
r12 = sqrt(sum(v_r12**2,2))
phi1L = exp(-r1L/a)
phi1R = exp(-r1R/a)
phi2L = exp(-r2L/a)
phi2R = exp(-r2R/a)
psi = (phi1L + phi1R)* (phi2L + phi2R)* &
exp(r12/(2* (1 + beta*r12)))
end subroutine hydrogen_test_function