def ldos_defect(h,v,e=0.0,delta=0.001,n=1): """Calculates the LDOS of a cell with a defect, writting the n neighring cells""" raise # still not finished import green # number of repetitions rep = 2*n +1 # calculate pristine green function g,selfe = green.supercell_selfenergy(h,e=e,delta=delta,nk=100,nsuper=rep) # now calculate defected green function ez = e + 1j*delta # complex energy emat = np.matrix(np.identity(len(g)))*ez # E +i\delta import supercell pintra = supercell.intra_super2d(h,n=rep) # pristine vintra = supercell.intra_super2d(h,n=rep,central=v) # defective selfe = emat - pintra - g.I # dyson euqation, get selfenergy gv = (emat - vintra -selfe).I # Green function of a vacancy, with selfener return
emat = np.matrix(np.identity(len(g))) * (e + delta * 1j) # E +i\delta return g, selfe #g1 = renor_dos(e) # compute kpoints in parallel #diag1 = [g1[i,i] for i in range(len(g1))] #g = g.supercell(nrep) import time t0 = time.clock() # renormalization method g1, selfe1 = renor_dos(e) # compute kpoints in parallel t1 = time.clock() # bloch method g2, selfe2, ins = green.supercell_selfenergy(h2, e=e, delta=delta, nk=300, nsuper=ncell) t2 = time.clock() print "Error in intracell = ", np.max(np.abs(ins - h1.intra)) print "Renorm = ", t1 - t0, " Bloch = ", t2 - t1 print "Error in bulk green = ", np.max(np.abs(g1 - g2)) print "Error in selfenergy = ", np.max(np.abs(selfe1 - selfe2)) t1s += [t1 - t0] t2s += [t2 - t1] import pylab as py py.plot(ns, t1s, marker="o") py.plot(ns, t2s, marker="o")
#g1 = renor_dos(e) # compute kpoints in parallel #diag1 = [g1[i,i] for i in range(len(g1))] #g = g.supercell(nrep) import time t0 = time.clock() # renormalization method g1,selfe1 = renor_dos(e) # compute kpoints in parallel t1 = time.clock() # bloch method g2,selfe2,ins = green.supercell_selfenergy(h2,e=e,delta=delta,nk=300,nsuper=ncell) t2 = time.clock() print "Error in intracell = ",np.max(np.abs(ins-h1.intra)) print "Renorm = ",t1-t0," Bloch = ",t2-t1 print "Error in bulk green = ",np.max(np.abs(g1-g2)) print "Error in selfenergy = ",np.max(np.abs(selfe1-selfe2)) t1s += [t1-t0] t2s += [t2-t1] import pylab as py py.plot(ns,t1s,marker="o") py.plot(ns,t2s,marker="o") py.show()