-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaussian.f90
executable file
·247 lines (135 loc) · 5.76 KB
/
gaussian.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
module gauss_integration
use constant
use basic
use gamma_func
contains
function overlap(a,RA,Ia,b,RB,Ib)
implicit none
! calculate the overlap function for gauss function, center at Ra and rb
! a for exp{-a*(r-Ra)^2}
! Ia means (0,0,0) for s type function,(1,0,0) for px-type
! the prefactor always 1
real*8,intent(in)::a,b,Ra(3),Rb(3)
integer,intent(in)::Ia(3),Ib(3)
integer::i
real*8:: Rp(3),I1(3),overlap,K
K=exp(-(a*b)/(a+b)*length(Ra-Rb))
Rp=(b/(a+b))*Rb+(a/(a+b))*Ra
do i=1,3
if ((Ia(i).eq.0).and.(Ib(i).eq.0)) then
I1(i)= sqrt(Pi/(a+b))
end if
if ((Ia(i).eq.1).and.(Ib(i).eq.1)) then
I1(i)=sqrt(Pi)/(2*(a+b)**(1.5_8))+(Rp(i)-Ra(i))*(Rp(i)-Rb(i))*sqrt(Pi/(a+b))
end if
if ((Ia(i).eq.1).and.(Ib(i).eq.0)) then
I1(i)=(Rp(i)-Ra(i))*sqrt(Pi/(a+b))
end if
if ((Ia(i).eq.0).and.(Ib(i).eq.1)) then
I1(i)=(Rp(i)-Rb(i))*sqrt(Pi/(a+b))
end if
end do
overlap=K*I1(1)*I1(2)*I1(3)
end function
function overlap_v2(a,RA,Ia,b,RB,Ib)
implicit none
! calculate the overlap function for gauss function, center at Ra and rb,at one direction
! a for exp{-a*(r-Ra)^2}
! Ia means (0,0,0) for s type function,(1,0,0) for px-type
! the prefactor always 1
real*8,intent(in)::a,b,Ra,Rb
integer,intent(in)::Ia,Ib
real*8:: Rp,I,overlap_v2,K
K=exp(-(a*b)/(a+b)*(Ra-Rb)**2)
Rp=(b/(a+b))*Rb+(a/(a+b))*Ra
if ((Ia.eq.0).and.(Ib.eq.0)) then
I= sqrt(Pi/(a+b))
end if
if ((Ia.eq.1).and.(Ib.eq.1)) then
I=sqrt(Pi)/(2*(a+b)**(1.5_8))+(Rp-Ra)*(Rp-Rb)*sqrt(Pi/(a+b))
end if
if ((Ia.eq.1).and.(Ib.eq.0)) then
I=(Rp-Ra)*sqrt(Pi/(a+b))
end if
if ((Ia.eq.0).and.(Ib.eq.1)) then
I=(Rp-Rb)*sqrt(Pi/(a+b))
end if
overlap_v2=K*I
end function
function kinetic(a,RA,Ia,b,RB,Ib)
implicit none
! calculate the kinetic function for gauss function, center at Ra and rb
! a for exp{-a*(r-Ra)^2}
! Ia means (0,0,0) for s type function,(1,0,0) for px-type
! the prefactor always 1
real*8,intent(in)::a,b,Ra(3),Rb(3)
integer,intent(in)::Ia(3),Ib(3)
integer::i
real*8:: Rp(3),I1(3),kinetic,K,S(3),aa
K=exp(-(a*b)/(a+b)*length(Ra-Rb))
Rp=(b/(a+b))*Rb+(a/(a+b))*Ra
S(1)=overlap_v2(a,Ra(2),Ia(2),b,Rb(2),Ib(2))*overlap_v2(a,Ra(3),Ia(3),b,Rb(3),Ib(3))
S(2)=overlap_v2(a,Ra(3),Ia(3),b,Rb(3),Ib(3))*overlap_v2(a,Ra(1),Ia(1),b,Rb(1),Ib(1))
S(3)=overlap_v2(a,Ra(2),Ia(2),b,Rb(2),Ib(2))*overlap_v2(a,Ra(1),Ia(1),b,Rb(1),Ib(1))
do i=1,3
if ((Ia(i).eq.0).and.(Ib(i).eq.0)) then
I1(i)=-2*b*overlap_v2(a,ra(i),0,b,rb(i),0)+4*b**2*K*(sqrt(Pi)/(2*(a+b)**(1.5_8))+(Rp(i)-Rb(i))**2*sqrt(Pi/(a+b)))
end if
if ((Ia(i).eq.1).and.(Ib(i).eq.1)) then
aa=3*sqrt(Pi)/(4*(a+b)**(2.5_8))+3*(rp(i)-rb(i))*(2*rp(i)-rb(i)-ra(i))*sqrt(Pi)/(2*(a+b)**(1.5_8))
aa=aa+(rp(i)-ra(i))*(rp(i)-rb(i))**3*sqrt(Pi/(a+b))
I1(i)=-6*b*overlap_v2(a,ra(i),1,b,rb(i),1)+4*b**2*K*aa
end if
if ((Ia(i).eq.1).and.(Ib(i).eq.0)) then
aa=(3*rp(i)-2*rb(i)-ra(i))*sqrt(Pi)/(2*(a+b)**(1.5_8))+(rp(i)-ra(i))*(rp(i)-rb(i))**2*sqrt(Pi/(a+b))
I1(i)=-2*b*overlap_v2(a,ra(i),1,b,rb(i),0)+4*b**2*K*aa
end if
if ((Ia(i).eq.0).and.(Ib(i).eq.1)) then
aa=3*(rp(i)-rb(i))*sqrt(Pi)/(2*(a+b)**(1.5_8))+(rp(i)-rb(i))**3*sqrt(Pi/(a+b))
I1(i)=-6*b*overlap_v2(a,ra(i),0,b,rb(i),1)+4*b**2*K*aa
end if
end do
kinetic=-0.5*(I1(1)*S(1)+I1(2)*S(2)+I1(3)*S(3))
end function
function e_attract(a,RA,Ia,b,RB,Ib,Rc)
implicit none
! calculate the eletron attract function for gauss function, center at Ra and rb,towards rc
! a for exp{-a*(r-Ra)^2}
! Ia means (0,0,0) for s type function,(1,0,0) for px-type
! the prefactor always 1
real*8,intent(in)::a,b,Ra(3),Rb(3),Rc(3)
integer,intent(in)::Ia(3),Ib(3)
integer::i,sum1,sum2
real*8:: Rp(3),e_attract,K,a1,a2
K=exp(-(a*b)/(a+b)*length(Ra-Rb))
Rp=(b/(a+b))*Rb+(a/(a+b))*Ra
sum1=ia(1)+ia(2)+ia(3)
sum2=ib(1)+ib(2)+ib(3)
if ((sum1.eq.0).and.(sum2.eq.0)) then
e_attract=K*2*Pi/(a+b)*F_func(0,(a+b)*length(Rp-Rc))
end if
if ((sum1.eq.1).and.(sum2.eq.0)) then
do i=1,3
if(ia(i).eq.1) then
sum1=ia(i)
end if
end do
a1=2*a*(rc(sum1)-rp(sum1))*F_func(1,(a+b)*length(rp-rc))
a2=2*a*b/(a+b)*(ra(sum1)-rb(sum1))*F_func(0,(a+b)*length(rp-rc))
e_attract=Pi/(a*(a+b))*(a1-a2)*K
end if
if ((sum1.eq.0).and.(sum2.eq.1)) then
do i=1,3
if(ib(i).eq.1) then
sum1=ib(i)
end if
end do
a1=2*b*(rc(sum1)-rp(sum1))*F_func(1,(a+b)*length(rp-rc))
a2=2*a*b/(a+b)*(-ra(sum1)+rb(sum1))*F_func(0,(a+b)*length(rp-rc))
e_attract=Pi/(a*(a+b))*(a1-a2)*K
end if
if ((sum1.eq.1).and.(sum2.eq.1)) then
e_attract=K*2*Pi/(a+b)*F_func(0,(a+b)*length(Rp-Rc))
end if
end function
end module