summaryrefslogtreecommitdiff
path: root/src/labat/resten.f
diff options
context:
space:
mode:
Diffstat (limited to 'src/labat/resten.f')
-rw-r--r--src/labat/resten.f634
1 files changed, 634 insertions, 0 deletions
diff --git a/src/labat/resten.f b/src/labat/resten.f
new file mode 100644
index 0000000..8314dad
--- /dev/null
+++ b/src/labat/resten.f
@@ -0,0 +1,634 @@
1c *********************************************************************
2 subroutine scheq(zz,en,lambda,nofl,kkk,mess,scf,thresh,iflag,npr
3 1,de)
4 implicit double precision (a-h,o-z)
5c subroutine scheq
6c compute energy eigenvalue and wave function
7c originally written by sherwood skillman
8c rca laboratories, princeton, new jersey, spring 1961
9c modified by frank herman, summer 1961
10c further modified by richard kortum and paul kelly, lockheed
11c research laboratories, palo alto, california, summer 1962
12c further modified by r.m. nieminen, otaniemi,spring 1978
13c and last but not least modified by m.p. winter 1979
14 dimension qq(561),p(5),q(5),t(5),d(5)
15 common/sc/gr(561),r(561),snlo(561),nbl
16 common/pot/v(561)
17 imp=1
18 nb1=nbl+1
19 nmb=nb1/5
20 if (de.lt.1.d-10)imp=0
21 if(imp.eq.1)de=dmax1(de,-e/500.d0)
22 eg=0.d0
23 z=zz
24 lam=lambda
25 nn=nofl
26 mesh=mess
27 c=scf
28 i0=0
29 many = 150
30 iflag=0
31 73 e=en
32 morev=0
33 lessv=0
34 emore=0.0d0
35 eless=0.0d0
36 more=0
37 less=0
38 mp=0
39 nprint=0
40 lamm=lam-1
41 lamp=lam+1
42 xlp=lamp
43 ndcr=nn-lamp
44 b=lam*lamp
45 oc=r(2)
46 h=oc
47 hsq=h*h
48 b3=(v(3)-v(2))/h-z/hsq
49 y=h+h
50 flps=4*lam+6
51 slpt=6*lam+12
52 elpt=8*lam+20
53 a1=-z/xlp
54 ysq=y*y
55 b1=-z-z
56 ab1=a1*b1
57 ab3=a1*b3
58c raise h and y to lam+1
59 htl=h
60 ytl=y
61 if(lam)77,1102,1100
62 1100 do 1101 i=1,lam
63 htl=htl*h
64 1101 ytl=ytl*y
65 1102 h1=hsq
66 bohs=b/hsq
67 boh=b1/h
68 bth=b3*h
69 bq3=bohs+boh+bth
70 bq4=bohs/4.d0+boh/2.d0+bth+bth
71 epl=8+lam
72 fpl=5+lam
73 xifc=c*.21701389d-4
74c start outward integration
75 10 nprint=nprint+1
76 eps =e-eg
77 eg =e
78 if(many-nprint) 900,75,75
79900 if(mp.eq.2)go to 300
80 write (6,901)nn,lam ,z
81 call flush(6)
82 901 format (21h no convergence on,i4,i1,f4.0)
83 iflag=1
84 en=0.d0
85 npr=nprint
86 return
87 77 nstop=7
88 777 write(66,770) nstop
89 770 format(' error in scheq',i6)
90 en=0.d0
91 iflag=1
92 npr=nprint
93 return
94 75 do 11 i=1,mesh
95 11 snlo(i)=0.0d0
96 if(nprint-1) 77,500,529
97 500 continue
98 do 502 i= 4,mesh
99 qq(i) = v(i)+b/(r(i)*r(i))-e
100 502 continue
101 516 m= mesh
102 do 520 i=4,mesh
103 if(qq(m)) 519,520,520
104 519 ik=m+1
105 go to 525
106 520 m=m-1
107 write(66,562)lam,qq(m+1),e
108562 format(/' l: ',i5,' q: ',g15.6,' e: ',g15.6/)
109 521 nstop =521
110c q is everywhere positive
111 go to 777
112 525 if(mesh-ik) 526,526,535
113 526 eps = qq(mesh-nbl)
114 e = e+eps
115 529 continue
116 do 530 i=4,mesh
117 530 qq(i) = qq(i)-eps
118 go to 516
119 535 continue
120 14 ncross=0
121 sig=1.0d0
122 h=oc
123 y=h+h
124c b= lam*(lam+1)
125c b1= -2.d0*z
126 b2=3.0d0*z/h-e+2.0d0*v(2)-v(3)
127c b3=(v(3)-v(2))/h -z/hsq
128c a1= -z/(lam+1)
129 a2=(ab1+b2)/flps
130c a2=(a1*b1+b2)/(4*lam+6)
131 a3=(a2*b1+a1*b2+b3)/slpt
132c a3=(a2*b1+a1*b2+b3)/(6*lam+12)
133 a4=(a3*b1+a2*b2+ab3)/elpt
134c a4=(a3*b1+a2*b2+a1*b3)/(8*lam+20)
135 p(3)=(1.0d0+h*(a1+h*(a2+h*(a3+h*a4))))*htl
136c p(3)=(1.0d0+a1*h+a2*h**2+a3*h**3+a4*h**4)*h**(xl+1.0d0)
137 p(4)=(1.0d0+y*(a1+y*(a2+y*(a3+y*a4))))*ytl
138c p(4)=(1.0d0+a1*y+a2*y**2+a3*y**3+a4*y**4)*y**(xl+1.0d0)
139 q(3)=bq3+b2
140c q(3)=(b+b1*h+b2*h**2+b3*h**3)/h**2
141 q(4)=bq4+b2
142c q(4)=(b+b1*y+b2*y**2+b3*y**3)/y**2
143 snlo(2)=p(3)
144 snlo(3)=p(4)
145 i=3
146 dx=oc
147 h1=h**2
148 h2=h1/12.0d0
149 t(3)=p(3)*(1.0d0-h2*q(3))
150 t(4)=p(4)*(1.0d0-h2*q(4))
151 d(4)=t(4)-t(3)
152 ncount=3
153 nint=2
154 15 i=i+1
155c if end of mesh is reached, modify trial eigenvalue
156 if(i-mesh) 16,3,3
157 3 if(ndcr-ncross) 32,33,33
158c return to begininning of outward integration if necessary
159 16 q(5) =qq(i)
160 if(ik-i) 29,29,21
161 21 d(5)=d(4)+h1*q(4)*p(4)
162 t(5)=d(5)+t(4)
163 if(1.0d0-abs (h2*q(5))) 3,3,501
164 501 p(5)=t(5)/(1.0d0-h2*q(5))
165 snlo(i) = p(5)
166 if(sig) 211,77,212
167 211 if(p(5)) 23,23,22
168 212 if(p(5)) 22,23,23
169 22 ncross=ncross+1
170c count changes in sign
171 sig=-sig
172 23 ncount=ncount+1
173 if(7-ncount)77,24,25
174 24 ncount=2
175 25 nint=nint+1
176 if(nbl-nint)77,26,27
177 26 dx=dx+dx
178 h=dx
179 h1=h**2
180 h2=h1/12.0d0
181 nint=0
182 t(5)=p(5)*(1.0d0-h2*q(5))
183 t(3)=p(3)*(1.0d0-h2*q(3))
184 d(5)=t(5)-t(3)
185 27 do 28 k=1,4
186 p(k)=p(k+1)
187 t(k)=t(k+1)
188 d(k)=d(k+1)
189 28 q(k)=q(k+1)
190 go to 15
191 29 if(ncount-2)77,30,21
192 30 if(nint-4)21,21,31
193c matching radius has been reached going out
194c if ndcr not equal to ncross,modify trial eigenvalue
195 31 eigen=e
196 if(ndcr-ncross) 32,35,33
197 32 more=1
198 mp=0
199c too many crossings, increase absf(e)
200 morev=morev+1
201 if(morev-1) 50,53,52
202 50 nstop=50
203 go to 777
204 52 if(e -emore) 53,54,54
205 53 emore=e
206 54 if (less) 55,56,64
207 55 nstop=55
208 go to 777
209 56 e=1.25d0*eg
210 go to 10
211 33 less=1
212 mp=0
213c too few crossings, decrease abs (e)
214 lessv=lessv+1
215 if(lessv-1) 57,60,59
216 57 nstop=57
217 go to 777
218 59 if(eless- e) 60,61,61
219 60 eless=e
220 61 if(more) 62,63,64
221 62 nstop=62
222 go to 777
223 63 e=0.75d0*eg
224 go to 10
225 64 e=0.5d0*(emore+eless)
226 go to 10
227 35 if(abs (snlo(i-1))-abs (snlo(i-2))) 351,354,354
228c check to see that wave is in the damped region (absolute value
229c decreasing and signs alike)
230 351 if (p(5)) 352,21 ,353
231 352 if(snlo(i-2)) 401,21,21
232 353 if(snlo(i-2)) 21,21,401
233 354 if(1.0d+25 -abs (p(5)))33,33,21
234c large absolute value of p in what should be the damped region
235c indicates too few peaks, decrease absf(e)
236c now ndcr = ncross and matching radius lies in damped region
237 401 imatch=i-2
238 xmatch=r(i-2)
239 ppout=(t(4)-t(2)-0.5d0*(p(4)-p(2)))/h
240 s2=ppout/p(3)
241c integration is by 8 applications of newton-cotes closed
242c quadrature for five intervals on each block
243c xifc =(5*h(block 1)/288)/2 ,h(1) =0.0025*scale factor
244 sum1=0.0d0
245 xif=xifc
246 i=1
247 value=0.0d0
248 36 mm=nmb
249 sum2=0.0d0
250 xif=xif+xif
251 37 y=value
252 value=snlo(i+5)**2
253 sum2=sum2+19.d0*(value+y)+75.d0*(snlo(i+4)**2+snlo(i+1)**2)
254 1 +50.0d0*(snlo(i+2)**2+snlo(i+3)**2)
255 i=i+5
256 if (imatch-i) 77,39,371
257 371 mm=mm-1
258 if(mm)77,38,37
259 38 sum1=sum2*xif+sum1
260 go to 36
261 39 sum1= sum1+sum2*xif
262 40 s1=sum1/p(3)**2
263 pmatch=p(3)
264 if(nn-1)77,41,42
265 41 xinw=epl* xmatch
266c for n =1, start inward integration at(8+lam)*xmatch or x max
267 go to 421
268 42 xinw=fpl*xmatch
269c for n not=1, start at (5+lam)*xmatch or x max (end of mesh)
270 421 do 44 i= nb1,mesh,nbl
271 if(xinw-r(i)) 43,43,44
272 43 kkk =i
273 go to 45
274 44 continue
275 kkk =mesh
276 45 i =kkk
277 dx =r(i-1)-r(i)
278 h =dx
279 xif=0.17361111d-1*dx
280 hsq=h*h
281 hsq12=hsq/12.0d0
282 q(3)= qq(i)
283 p(3)= exp (-r(i)*sqrt (q(3)))
284 402 sum3=p(3)/q(3)
285 i=i-1
286 q(4) =qq(i)
287 404 p(4)=exp (-r(i)*sqrt (q(4)))
288 if (abs (p(4))-1.0d-35) 4041,4041,405
289 4041 kkk=kkk -nbl
290 if(kkk -imatch) 4042,4042,45
291 4042 write (5,4043)z ,nn,lam,kkk
292 4043 format (6hoat z=,f6.0,6h nl =,i3,i1,7h kkk =,i5,22h is less tha
293 1n imatch =,i5,44h inward integration will be tried at kkk+nbl)
294 kkk =kkk +nbl
295 p(4) = 1.5d-35
296 p(3) = 1.0d-35
297 405 if(pmatch)102,77,103
298 102 p(3)=-p(3)
299 p(4)=-p(4)
300 103 snlo(i+1)=p(3)
301 snlo(i)=p(4)
302 t(3)=p(3)*(1.0d0-hsq12 *q(3))
303 t(4)=p(4)*(1.0d0-hsq12*q(4))
304 d(4)=t(4)-t(3)
305 104 do 106 m=2,nbl
306 i=i-1
307 q(5) =qq(i)
308 d(5)=hsq*q(4)*p(4)+d(4)
309 t(5)=d(5)+t(4)
310 p(5)=t(5)/(1.0d0-hsq12*q(5))
311 if(i-imatch+1)77,200,105
312 105 snlo(i)=p(5)
313 do 106 k=1,4
314 p(k)=p(k+1)
315 t(k)=t(k+1)
316 d(k)=d(k+1)
317 106 q(k)=q(k+1)
318 q(5) =qq(i-2)
319 d(5)=hsq*q(4)*p(4)+d(4)
320 t(5)=d(5)+t(4)
321 p(5)=t(5)/(1.0d0-hsq12*q(5))
322 p(5)=1.09375d0*p(4)+0.2734375d0*p(5)-0.546875d0*p(3)+0.21875d0*
323 1 p(2)-0.0390625d0*p(1)
324 i=i-1
325 dx=dx/2.0d0
326 q(5) =qq(i)
327 h=dx
328 hsq=h*h
329 hsq12=hsq/12.0d0
330 t(5)=p(5)*(1.0d0-hsq12*q(5))
331 t(4)=p(4)*(1.0d0-hsq12*q(4))
332 d(5)=t(5)-t(4)
333 snlo(i)=p(5)
334 do 107 l=1,4
335 p(l)=p(l+1)
336 t(l)=t(l+1)
337 d(l)=d(l+1)
338 107 q(l)=q(l+1)
339 go to 104
340c matching radius has been reached coming in
341 200 k=kkk
342 value=snlo(k)**2
343 go to 202
344 2001 continue
345 201 sum3=sum3+xif*sum4
346 xif =xif*0.5d0
347 202 mm=nmb
348 sum4 =0.0d0
349 203 y=value
350 value=snlo(k-5)**2
351 sum4=sum4+19.d0*(value+y)+75.d0*(snlo(k-1)**2+snlo(k-4)**2)
352 1+50.0d0*(snlo(k-2)**2+snlo(k-3)**2)
353 k=k-5
354 if(k-imatch) 77,2031,2030
355 2030 mm=mm-1
356 if(mm) 77,2001,203
357 2031 sum3=sum3+xif*sum4
358 204 s3=sum3/p(4)**2
359 ppin=(t(5)-t(3)-0.5d0*(p(5)-p(3)))/h
360 s4=ppin/p(4)
361 fe=s4-s2
362 if(abs(fe).lt.1.d-08)go to 300
363c write(66,4711)mp,nprint,e,fe
364 ml=more*less
3654711 format(' mp',i2,' iter: ',i4,' e: ',e12.6,' fe: ',e12.6)
366 if(mp.eq.2)go to 9120
367 if(mp.eq.1)go to 9100
368 mp=1
369 if(imp.eq.0)de=-e/10.d0
370 de=dmin1(de,-e/10.d0)
371 if(i0.gt.0)de=de/5**i0
372 i0=i0+1
373 if(ml.gt.0)de=abs(emore-eless)/10.d0
374 if(e.gt.-1.d-35)de=1.d-7
375 eold=e
376 feold=fe
377 if(fe.gt.0)e=e-de
378 if(fe.lt.0)e=e+de
379 go to 10
3809100 if(fe*feold.lt.0)go to 9110
381 if(fe.gt.0.d0.and.imp.eq.0) de=-e/10.d0
382 if(i0.gt.1.and.ml.gt.0)de=abs(emore-eless)/10.d0
383 eold=e
384 feold=fe
3859101 if(fe.lt.0d0)e=e+de
386 if(fe.gt.0d0)e=e-de
387 go to 10
3889110 continue
3899111 mp=2
390 fe1=feold
391 fe2=fe
392 e1=eold
393 e2=e
394 eold=e
395 go to 9130
3969120 if(fe1*fe.lt.0d0)e2=e
397 if(fe1*fe.lt.0d0)fe2=fe
398 if(fe2*fe.lt.0d0)e1=e
399 if(fe2*fe.lt.0d0)fe1=fe
400 eold=e
4016174 format(' e1: ',e12.6,' fe1: ',e12.6,' e2: ',e12.6,
402 j' fe2: ',e12.6)
4039130 e=(e1*fe2-e2*fe1)/(fe2-fe1)
404 if(abs((e2-e1)/e).lt.thresh)go to 300
405 if(abs((e-eold)/e).lt.1d-06)go to 300
406 go to 10
407 300 pop=pmatch/p(4)
408 do 302 j=imatch,kkk
409 302 snlo(j)=snlo(j)*pop
410 sum1=0.0d0
411 j=1
412 xif=xifc
413 value=0.0d0
414 303 mm=nmb
415 xif=xif+xif
416 sum2=0.0d0
417 304 y=value
418 value=snlo(j+5)**2
419 sum2=sum2+19.d0*(value+y)+75.d0*(snlo(j+4)**2+snlo(j+1)**2)
420 1+50.d0*(snlo(j+2)**2+snlo(j+3)**2)
421 j=j+5
422 mm=mm-1
423 if(mm)77,305,304
424 305 sum1=sum1+xif*sum2
425 if(kkk-j)77,307,303
426 307 c1=sqrt (sum1)
427 if(snlo(3))308,77,310
428 308 c1=-c1
429c
430c include tail
431c
432 310 tail=snlo(mesh)**2/(2.d0*sqrt(abs(e)))
433 c1=c1+tail
434 do 311 i=1,kkk
435 311 snlo(i)=snlo(i)/c1
436 en=e
437 if(abs(en).lt.1.d-6) iflag=1
438 npr=nprint
439 return
440 end
441c **********************************************************************
442 subroutine simpsh(ff,s)
443 implicit double precision (a-h,o-z)
444c integrates the matrix ff on the herman-skillman mesh
445 common/mess/wj(301),dx,nblock,jblock
446 common/sc/gr(561),r(561),snlo(561),nbl
447 dimension ff(561)
448 nb1=nbl+1
449 s=0.d0
450 deltax=dx
451 do 10 j=1,jblock
452 do 11 jk=1,nb1
453 i=(j-1)*nbl+jk
454 11 s=s+ff(i)*wj(jk)*deltax
455 10 deltax=2.d0*deltax
456 return
457 end
458c **********************************************************************
459 subroutine scrhs(roo,u,z,q,n)
460 implicit double precision (a-h,o-z)
461c evaluates the screened poisson integral
462c in the herman-skillman mesh
463 dimension roo(561),u(561),ss(561),apu(561)
464 common/sc/gr(561),r(561),snlo(561),nbl
465 pi=4.d0*atan(1.d0)
466 c=4.d0*pi
467 do 11 i=1,n
468 11 ss(i)=-c*roo(i)*r(i)-q**2*u(i)
469 do 20 i=1,n
470 do 30 j=1,n
471 aa=gr(i)/gr(j)
472 if(j.gt.i) aa=1.d0/aa
473 ab=gr(i)*gr(j)
474 30 apu(j)=(aa-ab)*ss(j)
475 call simpsh(apu,s)
476 20 u(i)=-s/(2.d0*q)-z*gr(i)
477 return
478 end
479c **********************************************************************
480 function exc(r,s,ixc)
481 implicit double precision (a-h,o-z)
482c ceperley alder perdew zunger
483c or von barth hedin
484 data gp,bp1,bp2,gf,bf1,bf2/-.1423d0,1.0529d0,.3334d0,-.0843d0,
485 j1.3981d0,.2611d0/
486 data ap,bp,cp,dp,af,bf,cf,df/.0311d0,-.048d0,.002d0,-.0116d0,
487 j.01555d0,-.0269d0,.0007d0,-.0048d0/
488 if(r.lt.1.d-25)go to 100
489 pi=4.d0*atan(1.d0)
490 if(s.gt.0.99999999d0)s=0.99999999d0
491 if(s.lt.-0.99999999d0)s=-0.99999999d0
492 sinv=(4.d0*pi*r/3.d0)**(1.d0/3.d0)
493 rs=1.d0/sinv
494 if(ixc.eq.1)go to 200
495 if(rs.lt.1.d0)go to 10
496 srs=sqrt(rs)
497 excp=gp/(1.d0+bp1*srs+bp2*rs)
498 excf=gf/(1.d0+bf1*srs+bf2*rs)
499 go to 20
50010 aa=log(rs)
501 excp=ap*aa+bp+cp*rs*aa+dp*rs
502 excf=af*aa+bf+cf*rs*aa+df*rs
50320 f=((1.d0+s)**(4.d0/3.d0)+(1.d0-s)**(4.d0/3.d0)-2.d0)/
504 1 (2.d0**(4.d0/3.d0)-2.d0)
505 excf=excf-.5772521d0/rs
506 excp=excp-.4581653d0/rs
507 exc=excp+f*(excf-excp)
508 return
509100 exc=0.d0
510 return
511200 x=s/2.d0+0.5d0
512 d43=4.d0/3.d0
513 rsf=rs/75.d0
514 rsf2=rsf*rsf
515 rsf3=rsf2*rsf
516 rsp=rs/30.d0
517 rsp2=rsp*rsp
518 rsp3=rsp2*rsp
519 fcf=(1.d0+rsf3)*log(1.d0+1.d0/rsf)+0.5d0*rsf-rsf2-1.d0/3.d0
520 fcp=(1.d0+rsp3)*log(1.d0+1.d0/rsp)+0.5d0*rsp-rsp2-1.d0/3.d0
521 epscp=-.0504d0*fcp
522 epscf=-.0254d0*fcf
523 epsxp=-.91633059d0/rs
524 cny=5.1297628d0*(epscf-epscp)
525 aa=.5d0**(1.d0/3.d0)
526 if(x.lt..000001d0) x=.000001d0
527 if(x.gt..999999d0) x=.999999d0
528 fx=(x**d43+(1.d0-x)**d43-aa)/(1.d0-aa)
529 exc=epsxp+epscp+fx*(cny+4.d0/3.d0*epsxp)/5.1297628d0
530 exc=exc/2.d0
531 return
532 end
533c **********************************************************************
534 function uxc(r,s,ispin,ixc)
535 implicit double precision (a-h,o-z)
536c ceperley alder perdew zunger
537 data gp,bp1,bp2,gf,bf1,bf2/-.1423d0,1.0529d0,.3334d0,-.0843d0,
538 j1.3981d0,.2611d0/
539 data ap,bp,cp,dp,af,bf,cf,df/.0311d0,-.048d0,.002d0,-.0116d0,
540 j.01555d0,-.0269d0,.0007d0,-.0048d0/
541 if(r.lt.1.d-35)go to 100
542 pi=4.d0*atan(1.d0)
543 sinv=(4.d0*pi*r/3.d0)**(1.d0/3.d0)
544 rs=1.d0/sinv
545 if(ixc.eq.1)go to 200
546 if(rs.lt.1.d0)go to 10
547 srs=sqrt(rs)
548 excp=gp/(1.d0+bp1*srs+bp2*rs)
549 excf=gf/(1.d0+bf1*srs+bf2*rs)
550 uxcp=excp*(1.d0+7.d0/6.d0*bp1*srs+4.d0/3.d0*bp2*rs)
551 j/(1.d0+bp1*srs+bp2*rs)
552 uxcf=excf*(1.d0+7.d0/6.d0*bf1*srs+4.d0/3.d0*bf2*rs)
553 j/(1.d0+bf1*srs+bf2*rs)
554 go to 20
55510 aa=log(rs)
556 excp=ap*aa+bp+cp*rs*aa+dp*rs
557 excf=af*aa+bf+cf*rs*aa+df*rs
558 uxcp=ap*aa+(bp-ap/3.d0)+2.d0/3.d0*cp*rs*aa+(2.d0*dp-cp)*rs/3.d0
559 uxcf=af*aa+(bf-af/3.d0)+2.d0/3.d0*cf*rs*aa+(2.d0*df-cf)*rs/3.d0
56020 f=((1.d0+s)**(4.d0/3.d0)+(1.d0-s)**(4.d0/3.d0)-2.d0)/
561 j (2.d0**(4.d0/3.d0)-2.d0)
562 ddf=4.d0/3.d0*((1.d0+s)**(1.d0/3.d0)-(1.d0-s)**(1.d0/3.d0))
563 j /(2.d0**(4.d0/3.d0)-2.d0)
564 uxc=uxcp+f*(uxcf-uxcp)+(excf-excp)*(3.d0-2.d0*ispin-s)*ddf
565 j -.6108871d0/rs*(1.d0+(3.d0-2.d0*ispin)*s)**(1.d0/3.d0)
566 return
567100 uxc=0.d0
568 return
569200 x=s/2.d0+0.5d0
570 d43=4.d0/3.d0
571 xx=0.5d0-s/2.d0
572 rsf=rs/75.d0
573 rsf2=rsf*rsf
574 rsf3=rsf2*rsf
575 rsp=rs/30.d0
576 rsp2=rsp*rsp
577 rsp3=rsp2*rsp
578 fcf=(1.d0+rsf3)*log(1.d0+1.d0/rsf)+0.5d0*rsf-rsf2-1.d0/3.d0
579 fcp=(1.d0+rsp3)*log(1.d0+1.d0/rsp)+0.5d0*rsp-rsp2-1.d0/3.d0
580 epscp=-.0504d0*fcp
581 epscf=-.0254d0*fcf
582 epsxp=-.91633059d0/rs
583 cny=5.1297628d0*(epscf-epscp)
584 aa=.5d0**(1.d0/3.d0)
585 if(x.lt..000001d0) x=.000001d0
586 if(xx.lt..000001d0) xx=.000001d0
587 if(x.gt..999999d0) x=.999999d0
588 if(xx.gt..999999d0) xx=.999999d0
589 ars=-1.22177412d0/rs+cny
590 brs=-0.0504d0*log(1.d0+30.d0/rs)-cny
591 trx1=(2.d0*x)**(1.d0/3.d0)
592 trx2=(2.d0*xx)**(1.d0/3.d0)
593 if(ispin.eq.1)vxc=ars*trx1+brs
594 if(ispin.eq.2)vxc=ars*trx2+brs
595 uxc=vxc/2.d0
596 return
597 end
598c ************************************************************
599 subroutine schrhs(v,k,l,ukl)
600 implicit double precision (a-h,o-z)
601c integrates the radial schrodinger equation
602c on the herman-skillman mesh
603 double precision k
604 dimension v(561),ukl(561),y(561)
605 common/mess/wj(301),dx,nblock,jblock
606 common/sc/gr(561),r(561),snlo(561),nbl
607 sd(i)=(2.d0*v(i)-k**2+l*(l+1)/r(i)**2)*ukl(i)
608 sdd(i)=(2.d0*v(i)-k**2+l*(l+1)/r(i)**2)*y(i)
609c initial values have been stored at ukl(1)...ukl(4)
610 nb1=nbl+1
611 hh=dx
612 do 10 i=5,nb1
613 ukl(i)=ukl(i-1)+ukl(i-3)-ukl(i-4)
614 1+hh**2/4.d0*(5.d0*sd(i-1)+2.d0*sd(i-2)+5.d0*sd(i-3))
615 10 ukl(i)=2.d0*ukl(i-1)-ukl(i-2)+
616 1hh**2/12.d0*(sd(i)+10.d0*sd(i-1)+sd(i-2))
617c set initial values for the next block
618 do 20 j=2,jblock
619 hh=2.d0*hh
620 jj=(j-1)*nbl
621 y(jj+1)=ukl(jj+1)
622 y(jj)=ukl(jj-1)
623 y(jj-1)=ukl(jj-3)
624 y(jj-2)=ukl(jj-5)
625 do 30 jk=2,nb1
626 i=jj+jk
627 y(i)=y(i-1)+y(i-3)-y(i-4)+
628 1hh**2/4.d0*(5.d0*sdd(i-1)+2.d0*sdd(i-2)+5.d0*sdd(i-3))
629 y(i)=2.d0*y(i-1)-y(i-2)+
630 1hh**2/12.d0*(sdd(i)+10.d0*sdd(i-1)+sdd(i-2))
631 30 ukl(i)=y(i)
632 20 continue
633 return
634 end