subroutine potential(n,h,nz,q,den,rv,ecoul,etxc,eexc, x v0,v0p,a,b,c,d,itype) c calculate veff for density functional theory from electron density c nz is nuclear charge c den(n) is electron density * (4*pi*r**2) c rv(n) is returned as veff * r c q is total electron charge c ecoul and etxc are coulomb and exchange-correlation contributions c to the total energy c eexc is the total exchange energy (int(den*exc)) c v0=v(0) c v0p=dv/dr(0) c a(n), b(n), c(n), d(n) are work arrays c if itype=15 (gga case) need to calculate additional functions: c gd=abs(grad(density))/density c ggd=laplacian(density)/density c gggd=grad(density)*grad(abs(grad(density)))/density**2 c for r