def get_sigma_eig(self,wlist=None,interp='spline',kk_method='mac'): ''' kk-relation to get (index1,index2) component of Sigma, we ignored pi factor here, for we will get U*FG^{-1}. For reference: * Initial version: J. Phys.: Condens. Matter 10.8365. * The matrix version: PRB 79.214518 wlist: the frequency space. interp: interpolation method. * `spline` * `pchip` kk_method: method to calculate kk-relation(Appl. Spectrosc. 42.952). * `mac` -> using Maclaurin-method. * `fft` -> using Successive Double Fourier Transformation method. ''' nband=self.nband print 'Interpolating A(w),B(w) to get self-energy Sigma(w).' t0=time.time() wl,Alist,Blist=self.data if not wlist is None: if interp=='pchip': interpolator=pchip_interpolate elif interp=='spline': interpolator=matrix_spline else: raise Exception('Undefined interpolation method @get_sigma.') Alist=interpolator(wl,Alist,wlist) Blist=interpolator(wl,Blist,wlist) else: wlist=wl Gilist=-pi*Alist Filist=-pi*Blist Gievals,Gievecs=eigh_sorted(Gilist) #Fievals,Fievecs=eig_sorted(Filist) if kk_method=='fft': Grevals=kk_fft(Gievals,'i2r',expand=1.5) Frlist=kk_fft(Filist,'i2r',expand=1.5) elif kk_method=='mac': Grevals=kk(Gievals,'i2r',wlist=wlist) Frlist=kk(Filist,'i2r',wlist=wlist) else: raise Exception('Undefined calculation method for kk-relation!') #Slist=self.U*array([(Br+1j*Bi).dot(inv(Ar+1j*Ai)) for Ar,Ai,Br,Bi in zip(Arlist,Alist,Brlist,Blist)]) #Srlist=(swapaxes(Slist.conj(),1,2)+Slist)/2. #Silist=(swapaxes(Slist.conj(),1,2)-Slist)*(-1j/2.) Gevals=Grevals+1j*Gievals #Fevals=Frevals+1j*Fievals invG=eigen_combine(1./Gevals,Gievecs) F=Frlist+1j*Filist #why here is a minus sign?! S=-self.U*bcast_dot(F,invG) t1=time.time() print 'Elapse -> %s'%(t1-t0) return S,invG,F
def measure(self,scale,dmmanagers,threadz=False,**kwargs): ''' measure an operator(overload). scale: the EScale instance. tdmanager: the timeline manager, and instance TDManager. threadz: multi-threading over z. **kwargs: * FDM: wmin(-1),wmax(1),smearing_method(gaussian), b(0.5), tol(0 if zero temperature else 1e-12), nw(50) * RDM: smearing_method(log_gaussian), b(0.4) ''' AL=[];BL=[] ntask=(scale.nz-1)/SIZE+1 for i in xrange(scale.nz): if threadz: if i/ntask==RANK: print 'Measuring Sigma on core %s with Hamiltonian size %s.'%(RANK,dmmanagers[i].H.N) w,A,B=self.get_expect(scale,dmmanagers[i],**kwargs) AL.append(A) BL.append(B) else: w,A,B=self.get_expect(scale,dmmanagers[i],**kwargs) AL.append(A) BL.append(B) if threadz: AL=COMM.gather(AL,root=0) BL=COMM.gather(BL,root=0) if RANK==0: AL=concatenate(AL,axis=0) BL=concatenate(BL,axis=0) w,A,B=w,mean(AL,axis=0),mean(BL,axis=0) A,B=COMM.bcast(A,root=0),COMM.bcast(B,root=0) else: A,B=mean(AL,axis=0),mean(BL,axis=0) print 'Fixing Occational Negative Eigenvalues of A.' aevals,aevecs=eigh(A) amin=aevals.min() if amin<0: print 'Fixing Negative spectrum up to %s'%amin aevals[aevals<0]=0 Alist=eigen_combine(aevals,aevecs) self.data=w,A,B
def load_data(self,filename,fix_neg=False): ''' load data. filename: the filename. fix_neg: fix negative eigenvalues of A of True. ''' f=open(filename,'r') self.data=pickle.load(f) if fix_neg: print 'Fixing Occational Negative Eigenvalues of A.' Alist=self.data[1] aevals,aevecs=eigh(Alist) amin=aevals.min() if amin<0: print 'Fixing Negative spectrum up to %s'%amin aevals[aevals<0]=0 self.data=self.data[0],eigen_combine(aevals,aevecs),self.data[2] f.close()