Beispiel #1
0
    def reduce_k(self,Cfunc,klist):
        '''
        Get the new C+\dag C type operator(like non-interacting Hamiltonian) for specific k.

        Parameters:
            :Cfunc: function, Cfunc(k) gives the expectation matrix at k.
            :klist: ndarray(Nk,vdim), the k-space.

        Return:
            The reduced operator.
        '''
        nband=Cfunc(zeros(2)).shape[-1]
        ncell=prod(self.size)
        offsets=self.offsets.reshape([-1,self.lattice.dimension])
        slist=offsets[:,0,newaxis]*self.lattice.a[0]+offsets[:,1,newaxis]*self.lattice.a[1]
        #get the equivalent k-points.
        b=toreciprocal(self.lattice.a*self.L[:,newaxis])
        Q=(b[0]+b[1])/2.
        equivk=meshgrid_v([arange(l) for l in self.L],vecs=b).reshape([-1,b.shape[-1]])
        if self.form=='x':
            equivk=concatenate([equivk,equivk+Q])

        #calculate C matrix.
        C=ndarray([len(klist),ncell,ncell,nband,nband],dtype=complex128)
        for ik,k in enumerate(klist):
            print '@%s'%ik
            cs=[Cfunc(k+q) for q in equivk]
            for s1 in xrange(ncell):
                for s2 in xrange(ncell):
                    C[ik,s1,s2]=sum([ci*exp(1j*(k+q).dot(slist[s2]-slist[s1])) for ci,q in zip(cs,equivk)],axis=0)/prod(self.L)/(1. if self.form=='#' else 2.)
        return swapaxes(C,2,3).reshape([len(klist),ncell*nband,ncell*nband])
Beispiel #2
0
 def xmesh(self):
     '''The lattice indices of x.'''
     nblock=self.nblock
     xlist=[]
     L=self.L
     if self.form=='x':
         ia1=self.L*array([1,1.])
         ia2=self.L*array([1.,-1])
     elif self.form=='#':
         ia1=self.L*array([1.,0])
         ia2=self.L*array([0,1.])
     xmesh=meshgrid_v([arange(nblock[0]),arange(nblock[1])],(ia1,ia2))
     return int32(xmesh)
Beispiel #3
0
 def resize(self,size):
     '''resize the A region.'''
     self._size=array(size)
     globaloffset=-(self.size/2)
     globaloffset=zeros(2,dtype='int32')
     self.offsets=meshgrid_v(siteconfig=[arange(si)+offset for offset,si in zip(globaloffset,self.size)],vecs=array([(0,1),(1,0)]))