Beispiel #1
0
 def get_Ising(self, h, J=1.):
     '''Get the hamiltonian.'''
     #the hamiltonian for Ising model
     Sz = opunit_Sz(spaceconfig=SpinSpaceConfig([1, 2]))
     Sx = opunit_Sx(spaceconfig=SpinSpaceConfig([1, 2]))
     H = -J * Sz.as_site(0) * Sz.as_site(1) + h * Sx.as_site(0)
     return H
Beispiel #2
0
    def __init__(self,J,Jz,h,nsite,J2=0,J2z=None):
        self.spaceconfig=SpinSpaceConfig([2,1])
        I=OpUnitI(hndim=2)
        scfg=SpinSpaceConfig([2,1])
        Sx=opunit_Sx(spaceconfig=scfg)
        Sy=opunit_Sy(spaceconfig=scfg)
        Sz=opunit_Sz(spaceconfig=scfg)

        #with second nearest hopping terms.
        if J2==0:
            self.H_serial2=None
            return
        elif J2z==None:
            J2z=J2
        SL=[]
        for i in xrange(nsite):
            Sxi,Syi,Szi=copy.copy(Sx),copy.copy(Sy),copy.copy(Sz)
            Sxi.siteindex=i
            Syi.siteindex=i
            Szi.siteindex=i
            SL.append(array([Sxi,Syi,sqrt(J2z/J2)*Szi]))
        ops=[]
        for i in xrange(nsite-1):
            ops.append(J*SL[i].dot(SL[i+1]))
            if i<nsite-2 and J2z!=0:
                ops.append(J2*SL[i].dot(SL[i+2]))

        mpc=sum(ops)
        self.H_serial=mpc
Beispiel #3
0
    def __init__(self, J, Jz, h, nsite, J2=0, J2z=None):
        self.spaceconfig = SpinSpaceConfig([1, 2])
        I = OpUnitI(hndim=2)
        scfg = SpinSpaceConfig([1, 2])
        Sx = opunit_Sx(spaceconfig=scfg)
        Sy = opunit_Sy(spaceconfig=scfg)
        Sz = opunit_Sz(spaceconfig=scfg)

        #with second nearest hopping terms.
        if J2 == 0:
            self.H_serial2 = None
            return
        elif J2z == None:
            J2z = J2
        SL = []
        for i in xrange(nsite):
            Sxi, Syi, Szi = copy.copy(Sx), copy.copy(Sy), copy.copy(Sz)
            Sxi.siteindex = i
            Syi.siteindex = i
            Szi.siteindex = i
            SL.append(array([Sxi, Syi, sqrt(J2z / J2) * Szi]))
        ops = []
        for i in xrange(nsite - 1):
            ops.append(J * SL[i].dot(SL[i + 1]))
            if i < nsite - 2 and J2z != 0:
                ops.append(J2 * SL[i].dot(SL[i + 2]))

        mpc = sum(ops)
        self.H_serial = mpc
Beispiel #4
0
    def __init__(self,J1,J2,K,Jp,nsite,impurity_site=None):
        self.spaceconfig=SpinSpaceConfig([2,1])
        if impurity_site is None:
            impurity_site=nsite/2  #nsite/2 and nsite/2-1
        self.impurity_site=impurity_site
        self.J1,self.J2,self.K,self.Jp=J1,J2,K,Jp
        I=OpUnitI(hndim=self.spaceconfig.hndim)
        Sx=opunit_Sx(spaceconfig=self.spaceconfig)
        Sy=opunit_Sy(spaceconfig=self.spaceconfig)
        Sz=opunit_Sz(spaceconfig=self.spaceconfig)
        SL=[]
        for i in xrange(nsite):
            Sxi,Syi,Szi=copy.deepcopy(Sx),copy.deepcopy(Sy),copy.deepcopy(Sz)
            Sxi.siteindex=i
            Syi.siteindex=i
            Szi.siteindex=i
            SL.append(array([Sxi,Syi,Szi]))
        ops=[]
        for i in xrange(nsite-1):
            factor1=J1
            if i==impurity_site or i==impurity_site-2:
                factor1*=Jp
            elif i==impurity_site-1:
                factor1*=K
            ops.append(factor1*SL[i].dot(SL[i+1]))
            if i<nsite-2 and i!=impurity_site-1 and i!=impurity_site-2:
                factor2=J2
                if i==impurity_site-3 or i==impurity_site:
                    factor2*=Jp
                ops.append(factor2*SL[i].dot(SL[i+2]))

        mpc=sum(ops)
        self.H_serial=mpc
Beispiel #5
0
 def get_Haldane(self, D, J=1.):
     '''Get the hamiltonian.'''
     #the hamiltonian for Ising model
     Sx = opunit_Sx(spaceconfig=SpinSpaceConfig([1, 3]))
     Sy = opunit_Sy(spaceconfig=SpinSpaceConfig([1, 3]))
     Sz = opunit_Sz(spaceconfig=SpinSpaceConfig([1, 3]))
     H = J * (
         Sz.as_site(0) * Sz.as_site(1) + Sx.as_site(0) * Sx.as_site(1) +
         Sy.as_site(0) * Sy.as_site(1)) + D * Sz.as_site(0) * Sz.as_site(0)
     return H
Beispiel #6
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()
Beispiel #7
0
 def __init__(self, g, h, nsite, J=1):
     self.spaceconfig = SpinSpaceConfig([2, 1])
     self.J, self.g, self.h, self.nsite = J, g, h, nsite
     scfg = self.spaceconfig
     I = OpUnitI(hndim=scfg.hndim)
     Sx = opunit_Sx(spaceconfig=scfg) * 2
     Sz = opunit_Sz(spaceconfig=scfg) * 2
     opc = 0
     for i in range(nsite):
         hi = h - J if i == 0 or i == nsite - 1 else h
         opc = opc + (hi * Sz.as_site(i) + g * Sx.as_site(i))
         if i != nsite - 1:
             opc = opc + J * Sz.as_site(i) * Sz.as_site(i + 1)
     self.opc = opc
Beispiel #8
0
 def __init__(self, J, Jz, h, nsite):
     self.spaceconfig = SpinSpaceConfig([1, 2])
     I = OpUnitI(hndim=2)
     scfg = SpinSpaceConfig([1, 2])
     Sz = opunit_Sz(spaceconfig=scfg)
     Sp = opunit_Sp(spaceconfig=scfg)
     Sm = opunit_Sm(spaceconfig=scfg)
     wi = zeros((5, 5), dtype='O')
     wi[:, 0], wi[4, 1:] = (I, Sp, Sm, Sz,
                            -h * Sz), (J / 2. * Sm, J / 2. * Sp, Jz * Sz, I)
     WL = [copy.deepcopy(wi) for i in xrange(nsite)]
     WL[0] = WL[0][4:]
     WL[-1] = WL[-1][:, :1]
     self.H_serial = WL2OPC(WL)
Beispiel #9
0
 def __init__(self,J,Jz,h,nsite):
     self.spaceconfig=SpinSpaceConfig([2,1])
     I=OpUnitI(hndim=2)
     scfg=SpinSpaceConfig([2,1])
     Sz=opunit_Sz(spaceconfig=scfg)
     Sp=opunit_Sp(spaceconfig=scfg)
     Sm=opunit_Sm(spaceconfig=scfg)
     wi=zeros((5,5),dtype='O')
     wi[:,0],wi[4,1:]=(I,Sp,Sm,Sz,-h*Sz),(J/2.*Sm,J/2.*Sp,Jz*Sz,I)
     WL=[copy.deepcopy(wi) for i in xrange(nsite)]
     WL[0]=WL[0][4:]
     WL[-1]=WL[-1][:,:1]
     self.H=MPO(WL)
     mpc=self.H.serialize()
     mpc.compactify()
     self.H_serial=mpc
Beispiel #10
0
 def __init__(self,J,h,nsite):
     self.spaceconfig=SpinSpaceConfig([2,1])
     self.J,self.h,self.nsite=J,h,nsite
     I=OpUnitI(hndim=2)
     Sz=opunit_Sz(spaceconfig=self.spaceconfig)
     Sx=opunit_Sx(spaceconfig=self.spaceconfig)
     wi=zeros((3,3),dtype='O')
     wi[:,0],wi[2,1:]=(I,Sx,-h*Sz),(Sx,I)
     WL=[copy.deepcopy(wi) for i in xrange(nsite)]
     WL[0]=WL[0][2:]
     WL[-1]=WL[-1][:,:1]
     self.H=MPO(WL)
     mpc=self.H.serialize()
     mpc.compactify()
     if isinstance(mpc,(OpString,OpUnit)):
         mpc=OpCollection([mpc])
     self.H_serial=mpc
     self.qnumber='R'
Beispiel #11
0
 def __init__(self,J,Jz,D,nsite):
     self.spaceconfig=SpinSpaceConfig([3,1])
     self.J,self.Jz,self.D,self.nsite=J,Jz,D,nsite
     I=OpUnitI(hndim=self.spaceconfig.hndim)
     Sz=opunit_Sz(spaceconfig=self.spaceconfig)
     Sp=opunit_Sp(spaceconfig=self.spaceconfig)
     Sm=opunit_Sm(spaceconfig=self.spaceconfig)
     wi=zeros((5,5),dtype='O')
     wi[:,0],wi[4,1:]=(I,Sp,Sm,Sz,D*Sz*Sz),(J/2.*Sm,J/2.*Sp,Jz*Sz,I)
     WL=[copy.deepcopy(wi) for i in xrange(nsite)]
     WL[0]=WL[0][4:]
     WL[-1]=WL[-1][:,:1]
     self.H=MPO(WL)
     mpc=self.H.serialize()
     mpc.compactify()
     self.H_serial=mpc
     ion()
     cla()
     mpc.show_advanced()
     pdb.set_trace()
Beispiel #12
0
def smajorana4mps(spaceconfig,ket_even,ket_odd,theta=0):
    '''
    Get wave function of spin-majorana fermion from ground states of even and odd spin-parity.

    Parameters:
        :spaceconfig: <SuperSpaceConfig>, the configuration of Hilbert space.
        :ket_even/ket_odd: <MPS>, the state of even and odd parities.
        :theta: number, the overall state.

    Return:
        tuple of (pl1,pl2), the wave functions of majorana fermions.
    '''
    #construct spin parity operator.
    data=opunit_Sz(spaceconfig).get_data()+0.5*identity(spaceconfig.hndim)
    fill_diagonal(data,exp(1j*pi*data.diagonal()))
    sp=OpUnit(data=data,label='P')
    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
    res=mpido(func=measure1,inputlist=arange(ket_even.nsite),bcastouputmesh=True)
    res=array(res)
    return res[:,0],res[:,1],res[:,2],res[:,3]
Beispiel #13
0
    def __init__(self,J,Jz,D,nsite,periodic=False):
        self.spaceconfig=SpinSpaceConfig([3,1])
        I=OpUnitI(hndim=self.spaceconfig.hndim)
        Sx=opunit_Sx(spaceconfig=self.spaceconfig)
        Sy=opunit_Sy(spaceconfig=self.spaceconfig)
        Sz=opunit_Sz(spaceconfig=self.spaceconfig)

        SL=[]
        for i in xrange(nsite):
            Sxi,Syi,Szi=copy.copy(Sx),copy.copy(Sy),copy.copy(Sz)
            Sxi.siteindex=i
            Syi.siteindex=i
            Szi.siteindex=i
            SL.append(array([Sxi,Syi,sqrt(Jz/J)*Szi]))
        ops=[]
        for i in xrange(nsite):
            if periodic or i!=nsite-1:
                ops.append(J*SL[i%nsite].dot(SL[(i+1)%nsite]))
            ops.append(D*SL[i][2]*SL[i][2])

        mpc=sum(ops)
        mpc.compactify()
        self.H_serial=mpc