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
|
function deriv(r,x,x2,spin,i,imin,imax)
c deriv calculates the derivative of x with respect to r, at
c position r(i).
c input r : radial coordinate (array)
c input x : function to be derivated (array)
c input x2 : second derivative of x (array)
c input spin : -1 if spin-down, 1 if spin-up, 0 otherwise
c input i : counter, i.e. current position = r(i)
c input imin : min value of i
c input imax : max value of i
implicit logical (a-z)
double precision deriv,r,x,x2
double precision h,d,dforw,dback,dforup,dfordn,dbacup,dbacdn
integer spin,i,imin,imax
dimension r(561),x(2,561),x2(2,561)
if (i.eq.imin) then
h = (r(i+1)-r(i))/2.d0
if (spin.eq.-1) then
d = x(2,i)
call splint(r,x,x2,-1,imin,imax,r(i)+h,dforw)
elseif (spin.eq.1) then
d = x(1,i)
call splint(r,x,x2,1,imin,imax,r(i)+h,dforw)
else
d = (x(1,i) + x(2,i))
call splint(r,x,x2,1,imin,imax,r(i)+h,dforup)
call splint(r,x,x2,-1,imin,imax,r(i)+h,dfordn)
dforw = dforup + dfordn
endif
deriv = (dforw-d)/h
elseif (i.eq.imax) then
h = (r(i)-r(i-1))/2.d0
if (spin.eq.-1) then
call splint(r,x,x2,-1,imin,imax,r(i)-h,dback)
d = x(2,i)
elseif (spin.eq.1) then
call splint(r,x,x2,1,imin,imax,r(i)-h,dback)
d = x(1,i)
else
call splint(r,x,x2,1,imin,imax,r(i)-h,dbacup)
call splint(r,x,x2,-1,imin,imax,r(i)-h,dbacdn)
dback = dbacup + dbacdn
d = x(1,i) + x(2,i)
endif
deriv = (d-dback)/h
else
h = (r(i)-r(i-1))/2.d0
if (spin.eq.-1) then
call splint(r,x,x2,-1,imin,imax,r(i)+h,dforw)
call splint(r,x,x2,-1,imin,imax,r(i)-h,dback)
elseif (spin.eq.1) then
call splint(r,x,x2,1,imin,imax,r(i)+h,dforw)
call splint(r,x,x2,1,imin,imax,r(i)-h,dback)
else
call splint(r,x,x2,-1,imin,imax,r(i)+h,dfordn)
call splint(r,x,x2,-1,imin,imax,r(i)-h,dbacdn)
call splint(r,x,x2,1,imin,imax,r(i)+h,dforup)
call splint(r,x,x2,1,imin,imax,r(i)-h,dbacup)
dback = dbacup + dbacdn
dforw = dforup + dfordn
endif
deriv = (dforw-dback)/(2.d0*h)
endif
return
end
|