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
|
*
* $Id: integrate_e_stress_ray.F 22503 2012-05-20 06:58:57Z d3y133 $
*
* ************************************
* * *
* * integrate_e_stress_ray *
* * *
* ************************************
subroutine integrate_e_stress_ray(version,rlocal,
> nrho,drho,lmax,locp,nmax,
> n_extra,n_expansion,zv,
> vp,wp,rho,f,cs,sn,
> nray,G_ray,dvl_ray,dvnl_ray,
> semicore,rho_sc_r,rho_sc_k_ray,
> ierr)
implicit none
integer version
double precision rlocal
integer nrho
double precision drho
integer lmax
integer locp
integer nmax
integer n_extra,n_expansion(0:lmax)
double precision zv
double precision vp(nrho,0:lmax)
double precision wp(nrho,0:(lmax+n_extra))
double precision rho(nrho)
double precision f(nrho)
double precision cs(nrho)
double precision sn(nrho)
integer nray
double precision G_ray(nray)
double precision dvl_ray(nray)
double precision dvnl_ray(nray,2,0:(lmax+n_extra))
logical semicore
double precision rho_sc_r(nrho,2)
double precision rho_sc_k_ray(nray)
integer ierr
#include "errquit.fh"
* *** local variables ****
integer np,taskid,MASTER
parameter (MASTER=0)
integer task_count
integer k1,i,l,n,nb
double precision pi,twopi,forpi
double precision p0,p1,p2,p3
double precision a,q
integer indx(5,0:3)
* **** external functions ****
double precision dsum,simp,util_erf
external dsum,simp,util_erf
* **** set up indx(n,l) --> to wp ****
nb = lmax+1
do l=0,lmax
indx(1,l) = l
do n=2,n_expansion(l)
indx(n,l) = nb
nb = nb+1
end do
end do
call Parallel_np(np)
call Parallel_taskid(taskid)
if (version.ne.3) then
call errquit('integrate_stress_ray - unit cell is aperiodic',0,
> INPUT_ERR)
ierr=1
return
end if
if (lmax.gt.3) THEN
call errquit('integrate_stress_ray - lmax > f',0,
> INPUT_ERR)
ierr=1
return
end if
if ((nrho/2)*2.eq.nrho) then
call errquit('integrate_stress_ray - psp grid not odd',0,
> INPUT_ERR)
ierr=2
return
end if
pi=4.0d0*datan(1.0d0)
twopi=2.0d0*pi
forpi=4.0d0*pi
p0=dsqrt(forpi)
p1=dsqrt(3.0d0*forpi)
p2=dsqrt(15.0d0*forpi)
p3=dsqrt(105.0d0*forpi)
*====================== Fourier transformation ======================
call dcopy(nray,0.0d0,0,dvl_ray,1)
call dcopy(2*(lmax+1+n_extra)*nray,0.0d0,0,dvnl_ray,1)
call dcopy(nray,0.0d0,0,rho_sc_k_ray,1)
task_count = -1
DO 700 k1=2,nray
task_count = task_count + 1
if (mod(task_count,np).ne.taskid) go to 700
q=G_ray(k1)
do i=1,nrho
cs(i)=dcos(q*rho(i))
sn(i)=dsin(q*rho(i))
end do
GO TO (500,400,300,200), lmax+1
*:::::::::::::::::::::::::::::: f-wave ::::::::::::::::::::::::::::::
200 CONTINUE
if (locp.ne.3) then
do n=1,n_expansion(3)
F(1)=0.0d0
do i=2,nrho
A=sn(i)/(q*rho(i))
A=15.0d0*(A-cs(i))/(q*rho(i))**2 - 6*A + cs(i)
f(i)=A*wp(i,indx(n,3))*vp(i,3)
end do
dvnl_ray(k1,1,indx(n,3))=p3*SIMP(nrho,F,drho)/q
F(1)=0.0d0
do i=2,nrho
A= -60.0d0*sn(i)/(rho(i)**3 * q**5)
> + 60.0d0*cs(i)/(rho(i)**2 * q**4)
> + 27.0d0*sn(i)/(rho(i) * q**3)
> - 7.0d0*cs(i)/(q**2)
> - rho(i)*sn(i)/q
f(i)=A*wp(i,indx(n,3))*vp(i,3)
end do
dvnl_ray(k1,2,indx(n,3))=p3*SIMP(nrho,F,drho)
end do
end if
*:::::::::::::::::::::::::::::: d-wave ::::::::::::::::::::::::::::::
300 CONTINUE
if (locp.ne.2) then
do n=1,n_expansion(2)
F(1)=0.0d0
DO i=2,nrho
A=3.0d0*(sn(i)/(q*rho(i))-cs(i))/(q*rho(i))-sn(i)
f(i)=A*wp(i,indx(n,2))*vp(i,2)
END DO
dvnl_ray(k1,1,indx(n,2))=p2*SIMP(nrho,F,drho)/q
F(1)=0.0d0
DO i=2,nrho
A= -9.0d0*sn(i)/(rho(i)**2 * q**4)
> + 9.0d0*cs(i)/(rho(i) * q**3)
> + 4.0d0*sn(i)/(q**2)
> - rho(i)*cs(i)/q
f(i)=A*wp(i,indx(n,2))*vp(i,2)
END DO
dvnl_ray(k1,2,indx(n,2))=p2*SIMP(nrho,F,drho)
end do
end if
*:::::::::::::::::::::::::::::: p-wave ::::::::::::::::::::::::::::::
400 CONTINUE
if (locp.ne.1) then
do n=1,n_expansion(1)
F(1)=0.0d0
DO i=2,nrho
f(i)=(sn(i)/(q*rho(i)) - cs(i)) * wp(i,indx(n,1))*vp(i,1)
END DO
dvnl_ray(k1,1,indx(n,1))=p1*SIMP(nrho,F,drho)/q
F(1)=0.0d0
DO i=2,nrho
f(i)=wp(i,indx(n,1))*vp(i,1)* ( -2.0d0*sn(i)/(rho(i)* q**3)
> + 2.0d0*cs(i)/(q**2)
> + rho(i)*sn(i)/q)
END DO
dvnl_ray(k1,2,indx(n,1))=p1*SIMP(nrho,F,drho)
end do
end if
*:::::::::::::::::::::::::::::: s-wave :::::::::::::::::::::::::::::::
500 CONTINUE
if (locp.ne.0) then
do n=1,n_expansion(0)
DO i=1,nrho
f(i)=wp(i,indx(n,0))*vp(i,0) * ( -sn(i)/(q**2)
> + rho(i)*cs(i)/q)
END DO
dvnl_ray(k1,1,indx(n,0)) = p0*SIMP(nrho,F,drho)
end do
end if
*:::::::::::::::::::::::::::::: local :::::::::::::::::::::::::::::::
600 CONTINUE
do i=1,nrho
f(i)=rho(i)*vp(i,locp)*(rho(i)*cs(i)-sn(i)/q)
end do
dvl_ray(k1)= SIMP(nrho,f,drho)*forpi/q
> + zv*forpi/(q*q)*(2.0d0*cs(nrho)/q + rho(nrho)*sn(nrho))
*::::::::::::::::::::: semicore density :::::::::::::::::::::::::::::::
if (semicore) then
do i=1,nrho
f(i)=rho(i)*dsqrt(rho_sc_r(i,1))*(rho(i)*cs(i)-sn(i)/q)
end do
rho_sc_k_ray(k1)= SIMP(nrho,f,drho)*forpi/q
end if
700 CONTINUE
call Parallel_Vector_SumAll(nray,rho_sc_k_ray)
call Parallel_Vector_SumAll(nray,dvl_ray)
call Parallel_Vector_Sumall(2*(lmax+1+n_extra)*nray,dvnl_ray)
*::::::::::::::::::::::::::::::: G=0 ::::::::::::::::::::::::::::::::
dvl_ray(1) = 0.0d0
rho_sc_k_ray(1) = 0.0d0
do l=0,lmax
do n=1,n_expansion(l)
dvnl_ray(1,1,indx(n,l))=0.0d0
dvnl_ray(1,2,indx(n,l))=0.0d0
end do
end do
ierr=0
return
end
|