예제 #1
0
파일: views.py 프로젝트: GiggleLiu/apps
def majorana4mps(spaceconfig,ket_even,ket_odd,theta=0,ordering=None):
    '''
    Get wave function of majorana fermion from ground states of even and odd parity.

    Parameters:
        :spaceconfig: <SuperSpaceConfig>, the configuration of Hilbert space.
        :ket_even/ket_odd: <MPS>, the state of even and odd parities.
        :theta: float, the relative phase factor of two vectors.
        :ordering: '<-'/'->', the ordering of fermionic operators.

    Return:
        tuple of (pl1,pl2), the wave functions of majorana fermions.
    '''
    pl1,pl2=[],[]
    cl,cl2=[],[]
    nsite=ket_even.nsite
    if ordering is None: ordering=arange(nsite)
    for i in xrange(ket_even.nsite):
        print 'Calculating %s-th Site'%i
        bra_even=ket_even.tobra(labels=[ket_odd.labels[0],ket_even.labels[1]+"'"])
        bra_odd=ket_odd.tobra(labels=[ket_odd.labels[0],ket_odd.labels[1]+"'"])
        p1,p2=0,0
        for spin in xrange(spaceconfig.nspin):
            ci=get_opC(i,spaceconfig,index=spaceconfig.c2ind(spinindex=spin),ordering=ordering,dag=True)
            c01=get_expect(ci,ket=ket_odd,bra=bra_even)
            c10=get_expect(ci,ket=ket_even,bra=bra_odd)
            ph1=exp(1j*theta)*c10+exp(-1j*theta)*c01
            ph2=1j*(exp(1j*theta)*c10-exp(-1j*theta)*c01)
            p1=p1+ph1*conj(ph1)
            p2=p2+ph2*conj(ph2)
            cl.append(c01)
            cl2.append(c10)
        pl1.append(p1)
        pl2.append(p2)
    return pl1,pl2,cl,cl2
예제 #2
0
파일: views.py 프로젝트: GiggleLiu/apps
 def measure1(siteindex):
     if which=='RHO':
         op=opunit_N(spaceconfig,index=None,siteindex=siteindex)
     else:
         raise NotImplementedError()
     if isinstance(op,OpCollection):
         m=sum([get_expect(opi,ket=ket) for opi in op.ops])
     else:
         m=get_expect(op,ket=ket)#,bra=ket.tobra(labels=ket.labels))
     print 'Get %s for site %s = %s @RANK: %s'%(which,siteindex,m.item(),RANK)
     return m
예제 #3
0
파일: views.py 프로젝트: GiggleLiu/apps
 def measure1(siteindex):
     if which=='SDW':   #cj+ sx cj ~ (-1)^j*m
         op=opunit_S(which='x',spaceconfig=spaceconfig,siteindex=siteindex)
     elif which=='sPDW':   #cjup+ cjdn+ ~ (-1)^j*G
         cup_d=opunit_C(dag=True,index=0,spaceconfig=spaceconfig,siteindex=siteindex)
         cdn_d=opunit_C(dag=True,index=1,spaceconfig=spaceconfig,siteindex=siteindex)
         cup_0=opunit_C(dag=False,index=0,spaceconfig=spaceconfig,siteindex=anchor)
         cdn_0=opunit_C(dag=False,index=1,spaceconfig=spaceconfig,siteindex=anchor)
         op=(cup_0*cdn_0)*(cup_d*cdn_d)
         if isinstance(op,OpString):
             op.compactify()
     elif which=='bSDW':   #cj+ sx cj+1 + h.c. ~ (-1)^j*M
         opi=get_bsdw_op(spaceconfig,siteindex,nsite=nsite)
         op0=get_bsdw_op(spaceconfig,siteindex=anchor,nsite=nsite)
         op=(op0*opi).compactify()
         op.insert_Zs(spaceconfig)
     elif which=='bSDW1':
         op=get_bsdw_op2(spaceconfig,siteindex,nsite=nsite)
         op.insert_Zs(spaceconfig)
     elif which=='TX':  #<S_z^2> - <S_z>^2
         op_sz=opunit_S(which='z',spaceconfig=spaceconfig,siteindex=siteindex)
         op=op_sz*op_sz
     elif which=='CDW':
         op_n=opunit_N(spaceconfig,index=None,siteindex=siteindex)
         op_n0=opunit_N(spaceconfig,index=None,siteindex=anchor)
         op=op_n*op_n0
     elif which=='RHO':
         op=opunit_N(spaceconfig,index=None,siteindex=siteindex)
     elif which=='triplet': #cj+ sx isy (cj+1+)^t
         cup_d=opunit_C(dag=True,index=0,spaceconfig=spaceconfig,siteindex=siteindex)
         cup_dp=opunit_C(dag=True,index=0,spaceconfig=spaceconfig,siteindex=siteindex+1)
         op=cup_d*cup_dp
         #raise NotImplementedError()
     elif which=='Sx':
         op=opunit_S(which='x',spaceconfig=spaceconfig,siteindex=siteindex)
     elif which=='SxSx0':
         op_Sx=opunit_S(which='x',spaceconfig=spaceconfig,siteindex=siteindex)
         op_Sx=opunit_S(which='x',spaceconfig=spaceconfig,siteindex=anchor)
         op=op_Sx*op_Sx
     elif which=='DBL':
         op_n=opunit_N(spaceconfig,index=0,siteindex=siteindex)*opunit_N(spaceconfig,index=1,siteindex=siteindex)
         op_n0=opunit_N(spaceconfig,index=0,siteindex=nsite/2)*opunit_N(spaceconfig,index=1,siteindex=anchor)
         op=op_n*op_n0
     else:
         raise NotImplementedError()
     if isinstance(op,OpCollection):
         m=sum([get_expect(opi,ket=ket) for opi in op.ops])
     else:
         m=get_expect(op,ket=ket)#,bra=ket.tobra(labels=ket.labels))
     print 'Get %s for site %s = %s @RANK: %s'%(which,siteindex,m,RANK)
     return m
예제 #4
0
파일: views.py 프로젝트: GiggleLiu/apps
    def measure1(i):
        print 'Measuring Majorana fermion at site %s'%i
        bra_even=ket_even.tobra(labels=[ket_odd.labels[0],ket_even.labels[1]+"'"])
        bra_odd=ket_odd.tobra(labels=[ket_odd.labels[0],ket_odd.labels[1]+"'"])

        signl=[]
        si=opunit_S(spaceconfig,which='+',siteindex=i)
        for j in xrange(i):
            spi=copy.copy(sp)
            spi.siteindex=j
            signl.append(spi)
        si=prod(signl+[si])
        c01=get_expect(si,ket=ket_odd,bra=bra_even)
        c10=get_expect(si,ket=ket_even,bra=bra_odd)
        ph1=exp(1j*theta)*c10+exp(-1j*theta)*c01
        ph2=1j*(exp(1j*theta)*c10-exp(-1j*theta)*c01)
        p1=ph1
        p2=ph2
        return p1,p2,c01,c10
예제 #5
0
def test_loc_observe():
    nsite = 10
    (E, mps), info = get_spec(nsite, trunc_steps=[], return_vecs=True)
    model = info['model']
    sx = opunit_Sx(spaceconfig=model.spaceconfig)
    sz = opunit_Sz(spaceconfig=model.spaceconfig)
    sy = opunit_Sy(spaceconfig=model.spaceconfig)
    # measure Sx(i)
    ion()
    for isite in range(nsite):
        res = get_expect(sz.as_site(isite), mps)[0, 0].diagonal()
        # res=fft.fft(res)
        plot(res)
        pdb.set_trace()