def atom(Z=82,alpha=0.3,iter=20,relat=2,rmin=0.00625,rmax=20.,inc=1.0247, grid=None,eps=1e-5): if grid == None: r = radial.create_log_grid(Z,rmin,rmax,inc) else: r = grid #def atom(Z=82,alpha=0.3,iter=20,relat=2,rmin=0.00625,rmax=20.,k0=1.0247): # r=radial.create_hyperbolic_grid(Z,rmin,rmax,k0) print "radial grid points: %d"%len(r) if relat == -1: r=radial.create_hyperbolic_grid(Z,k0=2000) #start with a uniform density density = ones(len(r),"d") density = Z/radial.integrate(density*r*r, r) * density Vxc=radial.getVxc(density,r,relat) Vh=radial.getVh(density,r,Z) pot = Vxc+Vh def F(pot): return KSiteration_potential(pot,r,Z,relat,eps=eps)-pot pot=solvers.excitingmixing(F,pot,iter=iter,alpha=alpha) #pot=solvers.broyden2(F,pot,iter=iter,alpha=alpha) #pot=solvers.broyden3(F,pot,iter=iter,alpha=alpha) v=array([-Z/x for x in r]) u=v+pot x=radial.KS_solve(u,r,Z,relat=relat,eps=eps) return (x[0][:Z], x[1])
def KSiteration_potential(potential,r,Z,relat=2,eps=1e-5): v=array([-Z/x for x in r]) u=v + potential density=radial.KS_construct_density(radial.KS_solve(u,r,Z,relat=relat,eps=eps),r,Z) Vxc=radial.getVxc(density,r,relat) Vh=radial.getVh(density,r,Z) # print totalenergy(r,u,v,Vh,Vxc,density,energies) return Vxc+Vh