Esempio n. 1
0
def makeTab(chi, D):
    bdi = uni10.Bond(uni10.BD_IN, chi)
    bdi1 = uni10.Bond(uni10.BD_IN, D)
    bdo = uni10.Bond(uni10.BD_OUT, chi)
    Tem0 = uni10.UniTensor([bdi, bdi1, bdo])
    Tem0.randomize()
    Tem1 = uni10.UniTensor([bdi, bdi1, bdo])
    Tem1.randomize()

    return Tem0, Tem1
Esempio n. 2
0
    def __init__(self, physical=2, Dimension=2, Number=2, rand_fuc='rand'):
        self.N = Number
        self.D = Dimension
        self.d = physical
        self.tensor = [None] * Number
        bdi = uni10.Bond(uni10.BD_IN, self.D)
        bdo = uni10.Bond(uni10.BD_OUT, self.D)
        bdi1 = uni10.Bond(uni10.BD_IN, 1)
        bdo1 = uni10.Bond(uni10.BD_OUT, 1)
        bdi_pys = uni10.Bond(uni10.BD_IN, self.d)
        #print "Hi", bdi_pys
        A_fixed = uni10.UniTensor([bdi, bdi_pys, bdo], "A_middle")
        A_fixed.randomize()

        for i in xrange(self.N):
            if i == 0:
                A = uni10.UniTensor([bdi1, bdi_pys, bdo], "A_0")
                if rand_fuc is 'rand':
                    A.randomize()
                    self.tensor[i] = A
                    #print "Hi0A"
                elif rand_fuc is 'ortho':
                    A.orthoRand()
                    #print "Hi10"
                    self.tensor[i] = A
                elif rand_fuc is 'iden':
                    A.identity()
                    self.tensor[i] = A
                    #print "Hi20"

            elif i == ((self.N) - 1):
                A = uni10.UniTensor([bdi, bdi_pys, bdo1], "A_N")
                if rand_fuc is 'rand':
                    A.randomize()
                    self.tensor[i] = A
                elif rand_fuc is 'ortho':
                    A.orthoRand()
                    self.tensor[i] = A
                elif rand_fuc is 'iden':
                    #print "HIIIIIIIIIIIIIII"
                    A.identity()
                    self.tensor[i] = A
            else:
                A = uni10.UniTensor([bdi, bdi_pys, bdo], "A_middle")
                if rand_fuc is 'rand':
                    A.randomize()
                    self.tensor[i] = A
                elif rand_fuc is 'ortho':
                    A.orthoRand()
                    self.tensor[i] = A
                elif rand_fuc is 'randuni':
                    self.tensor[i] = copy.copy(A_fixed)
                elif rand_fuc is 'iden':
                    A.identity()
                    self.tensor[i] = A
Esempio n. 3
0
def makec1(chi, D):
    bdi = uni10.Bond(uni10.BD_IN, chi)
    bdo = uni10.Bond(uni10.BD_OUT, chi)

    Tem0 = uni10.UniTensor([bdi, bdo])
    Tem0.randomize()
    Tem1 = uni10.UniTensor([bdi, bdo])
    Tem1.randomize()
    Tem2 = uni10.UniTensor([bdi, bdo])
    Tem2.randomize()
    Tem3 = uni10.UniTensor([bdi, bdo])
    Tem3.randomize()

    return Tem0, Tem1, Tem2, Tem3
Esempio n. 4
0
def inv(svd):
 bdi=uni10.Bond(uni10.BD_IN, svd.col())
 bdo=uni10.Bond(uni10.BD_OUT, svd.row())
 Landa=uni10.UniTensor([bdi,bdo])
 Landa.putBlock(svd)
 Landa=basic.inverse(Landa)
 return Landa
Esempio n. 5
0
def  test_energy_lr(N_uni, l, l_d, r, r_d, q,qq,U,E1, E2, E3, E4, E5,E6,a_u,b_u):
 U.setLabel([-20,-40,20,40])
 Iden=uni10.UniTensor(U.bond())
 Bond_val=U.bond()[0].dim()*U.bond()[1].dim()
 matrix_Iden=uni10.Matrix(Bond_val, Bond_val)
 matrix_Iden.identity()
 Iden.putBlock(matrix_Iden)
 Iden.setLabel([-20,-40,20,40])

 
 a_u.setLabel([20,13,1,2,3])
 a_d=copy.copy(a_u)
 a_d.setLabel([-20,-13,-1,-2,-3])

 b_u.setLabel([40,2,4,5,6])
 b_d=copy.copy(b_u)
 b_d.setLabel([-40,-2,-4,-5,-6])

 B=(((r*r_d)*U)*(l*l_d))*(N_uni)
 A=(((r*r_d)*Iden)*(l*l_d))*(N_uni)
 print 'E=', B[0]/A[0]
 
 
 a_ut=q*r
 a_ut.permute([20,4,5,3,2],3)
 print a_ut.similar(a_u),distance_two(a_u.getBlock(),a_ut.getBlock()) 
 
 b_ut=qq*l
 b_ut.permute([40,3,4,5,6],3)
 
 print b_ut.similar(b_u), distance_two(b_u.getBlock(),b_ut.getBlock())
Esempio n. 6
0
def pauli4body():
    '''
    Tensors for 4-body Pauli strings. 
    '''
    bond_dim = 2
    iden = matIden()
    sx = matSx()
    sy = matSy()
    sz = matSz()
    bdi = uni10.Bond(uni10.BD_IN, bond_dim)
    bdo = uni10.Bond(uni10.BD_OUT, bond_dim)

    pauli1b = [iden, sx, sy, sz]
    pauli4b = []
    pauli2b = []
    l2b = 16
    for i in xrange(4):
        for j in xrange(4):
            mat = uni10.otimes(pauli1b[i], pauli1b[j])
            pauli2b.append(mat)
    for i in xrange(l2b):
        for j in xrange(l2b):
            mat = uni10.otimes(pauli2b[i], pauli2b[j])
            P = uni10.UniTensor([bdi, bdi, bdi, bdi, bdo, bdo, bdo, bdo])
            P.putBlock(mat)
            pauli4b.append(P)

    return pauli4b
Esempio n. 7
0
def pauli6body():
    '''
    Tensors for 6-body Pauli strings. 
    '''
    bond_dim = 2
    iden = matIden()
    sx = matSx()
    sy = matSy()
    sz = matSz()
    bdi = uni10.Bond(uni10.BD_IN, bond_dim)
    bdo = uni10.Bond(uni10.BD_OUT, bond_dim)

    pauli1b = [iden, sx, sy, sz]
    pauli6b = []
    bonds = [bdi] * 6 + [bdo] * 6
    pauli3b = []

    for i in xrange(4):
        for j in xrange(4):
            for k in xrange(4):
                mat = uni10.otimes(uni10.otimes(pauli1b[i], pauli1b[j]),
                                   pauli1b[k])
                pauli3b.append(mat)
    l3b = 64
    for i in xrange(l3b):
        for j in xrange(l3b):
            mat = uni10.otimes(pauli3b[i], pauli3b[j])
            P = uni10.UniTensor(bonds)
            P.putBlock(mat)
            pauli6b.append(P)

    return pauli6b
Esempio n. 8
0
def intialize_unitary_list(L, L_lay, d, delta):
    U_list = []
    bdi_spin = uni10.Bond(uni10.BD_IN, d)
    bdo_spin = uni10.Bond(uni10.BD_OUT, d)
    Svd = []
    matrix_random = uni10.Matrix(d * d, d * d)
    for i in xrange(d * d):
        for j in xrange(d * d):
            if (i == j):
                matrix_random[i * d * d + j] = 1.0
            else:
                matrix_random[i * d * d + j] = 0.0
    #matrix_random.setIdentity()
    for i in xrange(L / 2):
        U_list.append([])
    for i in xrange(L / 2):
        for j in xrange(len(L_lay)):
            U_uni10 = uni10.UniTensor([bdi_spin, bdi_spin, bdo_spin, bdo_spin],
                                      "Unitary_uni10")
            matrix_random1 = copy.copy(matrix_random)
            matrix_random1.randomize()
            matrix_random1 = matrix_random + (delta) * matrix_random1
            Svd = matrix_random1.svd()
            U_uni10.putBlock(Svd[0] * Svd[2])
            U_list[i].append(U_uni10)
    return U_list
Esempio n. 9
0
def setTruncation(theta, chi):
    #print theta
    LA = uni10.UniTensor(theta.bond())
    GA = uni10.UniTensor(theta.bond())
    GB = uni10.UniTensor(theta.bond())

    bond_In_list, bond_OUT_list = bond_list_dist(theta)
    #print bond_In_list,bond_OUT_list
    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd = []
    for qnum in blk_qnums:
        M_tem = theta.getBlock(qnum)
        svds[qnum] = M_tem.svd()
        #print qnum, svds[qnum][1]
        dim_svd.append(int(svds[qnum][1].col()))
    svs = []
    bidxs = []
    for bidx in xrange(len(blk_qnums)):
        svs, bidxs = sv_merge(svs, bidxs, bidx, svds[blk_qnums[bidx]][1], chi,
                              len(blk_qnums))
        #print "lol", svs, bidxs
    dims = [0] * len(blk_qnums)
    for bidx in bidxs:
        dims[bidx] += 1
    qnums = []
    for bidx in xrange(len(blk_qnums)):
        qnums += [blk_qnums[bidx]] * dims[bidx]
    bdi_mid = uni10.Bond(uni10.BD_IN, qnums)
    #print "Hi", chi, svs, qnums, bdi_mid
    #print bdi_mid
    bdo_mid = uni10.Bond(uni10.BD_OUT, qnums)
    bond_In_list.append(bdo_mid)
    GA.assign(bond_In_list)
    bond_OUT_list.insert(0, bdi_mid)
    GB.assign(bond_OUT_list)
    LA.assign([bdi_mid, bdo_mid])
    degs = bdi_mid.degeneracy()
    for qnum, dim in degs.iteritems():
        if qnum not in svds:
            raise Exception("In setTruncaton(): Fatal error.")
        svd = svds[qnum]
        GA.putBlock(qnum, svd[0].resize(svd[0].row(), dim))
        GB.putBlock(qnum, svd[2].resize(dim, svd[2].col()))
        LA.putBlock(qnum, svd[1].resize(dim, dim))
    #print LA
    return GA, GB, LA
Esempio n. 10
0
def Reload_Fullp():
    ap_u = uni10.UniTensor("Store/ap_u")
    bp_u = uni10.UniTensor("Store/bp_u")
    cp_u = uni10.UniTensor("Store/cp_u")
    dp_u = uni10.UniTensor("Store/dp_u")
    ap = uni10.UniTensor("Store/ap")
    bp = uni10.UniTensor("Store/bp")
    cp = uni10.UniTensor("Store/cp")
    dp = uni10.UniTensor("Store/dp")
    return ap_u, bp_u, cp_u, dp_u, ap, bp, cp, dp
Esempio n. 11
0
def Reload_Full():
    a_u = uni10.UniTensor("Store/a_u")
    b_u = uni10.UniTensor("Store/b_u")
    c_u = uni10.UniTensor("Store/c_u")
    d_u = uni10.UniTensor("Store/d_u")
    a = uni10.UniTensor("Store/a")
    b = uni10.UniTensor("Store/b")
    c = uni10.UniTensor("Store/c")
    d = uni10.UniTensor("Store/d")
    return a_u, b_u, c_u, d_u, a, b, c, d
Esempio n. 12
0
def final_test_distance(ap_u, bp_u, a_u, b_u,E1, E2, E3, E4, E5,E6,U,N_uni):


 U.setLabel([-20,-40,20,40])
 H1=copy.copy(U)
 H1.transpose()
 H1.setLabel([-20,-40,30,50])
  
 U.setLabel([30,50,20,40])
 H=U*H1
 H.permute([-20,-40,20,40],2)
 #H.setLabel([-20,-40,20,40]) 
 
 H1.setLabel([-20,-40,20,40]) 
 U.setLabel([-20,-40,20,40])
 
 Iden=uni10.UniTensor(U.bond())
 matrix_Iden=uni10.Matrix(U.bond()[0].dim()*U.bond()[1].dim(), U.bond()[2].dim()*U.bond()[3].dim())
 matrix_Iden.identity()
 Iden.putBlock(matrix_Iden)
 Iden.setLabel([-20,-40,20,40])
 
 
 a_u.setLabel([20,13,1,2,3])
 a_d=copy.copy(a_u)
 a_d.setLabel([-20,-13,-1,-2,-3])

 b_u.setLabel([40,2,4,5,6])
 b_d=copy.copy(b_u)
 b_d.setLabel([-40,-2,-4,-5,-6])


 ap_u.setLabel([20,13,1,2,3])
 ap_d=copy.copy(ap_u)
 ap_d.setLabel([-20,-13,-1,-2,-3])

 bp_u.setLabel([40,2,4,5,6])
 bp_d=copy.copy(bp_u)
 bp_d.setLabel([-40,-2,-4,-5,-6])
 #N=(((((E2*)*E1)*E3)*Iden)*((((E5)*E6)*E4)))

# a_u=q*r
# a_u.permute([20,4,5,3,2],3)
# a_u.setLabel([0,1,2,3,4])
# #print a_ut.similar(a_u)#,a_ut.printDiagram() 
# 
# b_u=qq*l
# b_u.permute([40,3,4,5,6],3)
# b_u.setLabel([0,1,2,3,4])
# #print b_ut.similar(b_u) 
 
 A1=(((((E2*(a_u*a_d))*E1)*E3)*H)*(((((b_u*b_d)*E5)*E6)*E4))) 
 A2=((((E2*(ap_u*ap_d))*E1)*E3)*Iden)*(((((bp_u*bp_d)*E5)*E6)*E4))
 A3=((((E2*(a_u*ap_d))*E1)*E3)*U)*(((((b_u*bp_d)*E5)*E6)*E4))
 A4=((((E2*(ap_u*a_d))*E1)*E3)*H1)*(((((bp_u*b_d)*E5)*E6)*E4))

 A=A1+A2+(-1.00)*A3+(-1.00)*A4
 return A
Esempio n. 13
0
def trgSVD(wch, T, chi):
    if wch % 2 == 0:
        T.permute([-4, -3, -1, -2], 2)
    else:
        T.permute([-1, -4, -2, -3], 2)

    svd = T.getBlock().svd()
    chi = chi if chi < svd[1].row() else svd[1].row()
    bdi_chi = uni10.Bond(uni10.BD_IN, chi)
    bdo_chi = uni10.Bond(uni10.BD_OUT, chi)
    S0 = uni10.UniTensor([T.bond(0), T.bond(1), bdo_chi])
    S1 = uni10.UniTensor([bdi_chi, T.bond(2), T.bond(3)])
    svd[1].resize(chi, chi)
    for i in xrange(chi):
        svd[1][i] = np.sqrt(svd[1][i])
    S0.putBlock(svd[0].resize(svd[0].row(), chi) * svd[1])
    S1.putBlock(svd[1] * svd[2].resize(chi, svd[2].col()))
    return S0, S1
Esempio n. 14
0
def sqt(Landa2):
    invLanda2 = uni10.UniTensor(Landa2.bond())
    invL2 = uni10.Matrix(Landa2.bond()[0].dim(), Landa2.bond()[1].dim())
    D = Landa2.bond()[0].dim()
    for i in xrange(Landa2.bond()[0].dim()):
        for j in xrange(Landa2.bond()[0].dim()):
            invL2[i * D + j] = ((Landa2[i * D + j])**(1.00 / 2.00))
    invLanda2.putBlock(invL2)
    return invLanda2
Esempio n. 15
0
def load_ulist(L, lla, outdir):
    Ulist = []
    for l in xrange(L):
        Ulist.append([])
        for i in xrange(lla):
            u = uni10.UniTensor(outdir + '/U%d%d_L%dLU%d' % (l, i, L, lla))
            Ulist[l].append(u)

    return Ulist
Esempio n. 16
0
def vec2uni(v, L):
    bond_dim = 2
    vl = list(v)
    vl10 = uni10.Matrix(2**L, 1, vl)
    bdi = uni10.Bond(uni10.BD_IN, bond_dim)
    bdo = uni10.Bond(uni10.BD_OUT, bond_dim)
    vtensor = uni10.UniTensor([bdi] * L, 'GS')
    vtensor.putBlock(vl10)
    return vtensor
Esempio n. 17
0
def inverse(Landa2):
    invLanda2 = uni10.UniTensor(Landa2.bond())
    invL2 = uni10.Matrix(Landa2.bond()[0].dim(), Landa2.bond()[1].dim())
    D = Landa2.bond()[0].dim()
    for i in xrange(Landa2.bond()[0].dim()):
        for j in xrange(Landa2.bond()[0].dim()):
            invL2[i * D + j] = 0 if ((Landa2[i * D + j].real) < 1.0e-12) else (
                1.00 / (Landa2[i * D + j].real))
    invLanda2.putBlock(invL2)
    return invLanda2
Esempio n. 18
0
def qr_parity(theta):

    #bd1=copy.copy(theta.bond(3))
    #bd1.change(uni10.BD_IN)
    bd1 = uni10.Bond(uni10.BD_IN, theta.bond(1).Qlist())

    GA = uni10.UniTensor(uni10.CTYPE, [theta.bond(0), theta.bond(1)])
    LA = uni10.UniTensor(uni10.CTYPE, [bd1, theta.bond(1)])

    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd = []
    for qnum in blk_qnums:
        svds[qnum] = theta.getBlock(qnum).qr()
        GA.putBlock(qnum, svds[qnum][0])
        LA.putBlock(qnum, svds[qnum][1])

    #    print LA
    return GA, LA
Esempio n. 19
0
def Reduction_lastbond(U_up_1, n, Letter):
 Mat=U_up_1.getBlock()
 dim0=U_up_1.bond(0).dim()
 dim1=U_up_1.bond(1).dim()
 dim2=U_up_1.bond(2).dim()
 dim3=U_up_1.bond(3).dim()
 if Letter is 'up':
  Mat1=uni10.Matrix(dim0*dim1, dim2)
  Mat1.set_zero()
  for i in xrange(dim0):
   for j in xrange(dim1):
    for m in xrange(dim2):
     Mat1[i*dim1*dim2+j*dim2+m]=U_up_1[i*dim1*dim2*dim3+j*dim2*dim3+m*dim3+n]
  bond_list=list(U_up_1.bond())
  #print list(bond_list)
  bond_list=list(bond_list)
  bond_list.pop()
  #print bond_list
  Uni_tensor=uni10.UniTensor(bond_list,U_up_1.getName())
  Uni_tensor.putBlock(Mat1)
  #print Uni_tensor.printDiagram(), n
  return Uni_tensor
 elif Letter is 'down':
  Mat1=uni10.Matrix(dim0, dim2*dim3)
  Mat1.set_zero()
  for i in xrange(dim0):
   for j in xrange(dim3):
    for m in xrange(dim2):
     Mat1[i*dim3*dim2+m*dim3+j]=U_up_1[i*dim1*dim2*dim3+n*dim2*dim3+m*dim3+j]
  bond_list=list(U_up_1.bond())
  #print list(bond_list)
  bond_list=list(bond_list)
  A=bond_list.pop()
  B=bond_list.pop()
  C=bond_list.pop()
  bond_list.append(B)
  bond_list.append(A)
  #print bond_list
  Uni_tensor=uni10.UniTensor(bond_list,U_up_1.getName())
  Uni_tensor.putBlock(Mat1)
  #print Uni_tensor.printDiagram(), n
  return Uni_tensor
Esempio n. 20
0
def get_umpo_up_1layer(Ulist,L,bond_idx,bond_dim=2):
    # Will not be called
    if (bond_idx%2 == 0):
        U = Ulist[bond_idx/2]
    else:
        bdi = uni10.Bond(uni10.BD_IN,  bond_dim)
        bdo = uni10.Bond(uni10.BD_OUT, bond_dim)
        U = uni10.UniTensor([bdi,bdi,bdo,bdo],'U0')
        I = matIden()
        U.putBlock(I)
    return U
Esempio n. 21
0
def  l_optimum_full(l, r, l_d, r_d, lp, rp, lp_d, rp_d ,N_uni,U):
 U.setLabel([-20,-40,20,40])
 H1=copy.copy(U)
 H1.transpose()
 H1.setLabel([-20,-40,20,40])
 
 Iden=uni10.UniTensor(U.bond())
 Bond_val=U.bond()[0].dim()*U.bond()[1].dim()
 matrix_Iden=uni10.Matrix(Bond_val, Bond_val)
 matrix_Iden.identity()
 Iden.putBlock(matrix_Iden)
 Iden.setLabel([-20,-40,20,40])
 A2=(((rp*rp_d)*N_uni)*Iden)
 A2.permute([2,40,3,-2,-40,-3],3)
 A2_trans=copy.copy(A2)
 A2_trans.transpose()
 A2=A2+A2_trans




 A3=((l)*U*(r*rp_d))*N_uni
 A3.permute([-2,-40,-3],0)
 A3p=((l_d)*U*(rp*r_d))*N_uni
 A3p.permute([2,40,3],0)
 A3=A3+A3p

 
 
 
 svd=A2.getBlock().svd()
 Landa=inv(svd[1])
 #print Landa.getBlock()*svd[1]
 v=copy.copy(svd[2])
 v.transpose()
 u=svd[0]
 u.transpose()
 s=Landa.getBlock()
 A2_inv=v*s*u
 A2_mat=A2.getBlock()
 #distance_iden_val=distance_iden(A2_mat,A2_inv)
 #print 'distance=', distance_iden_val  
 A=A3.getBlock()
 A=A*A2_inv
 A3.putBlock(A)
 A3.setLabel([2,40,3])
 A3.permute([2,40,3],2)


 lf=copy.copy(A3)
 lf_d=copy.copy(lf)
 lf_d.setLabel([-2,-40,-3])

 return lf, lf_d
Esempio n. 22
0
def test_u2p():
    umat = uni10.Matrix(4,4,[0.,0.,0.9,0.,0.,0.,0.,0.1,0.9,0.,0.,0.,0.,0.1,0.,0.])
    umat = uni10.Matrix(4,4,[-1., -0., -0., -1.,-0., -0., -1., -0., -0., -1., -0., -0.,-1.,-0.,-0.,1.])
    U = uni10.UniTensor([bdi,bdi,bdo,bdo],'U')
    U.putBlock(umat)
    pstr, _ = pauli2body()
    coef = []
    for i in range(len(pstr)):
        c = unitary2pauli(U,pstr[i],2)
        coef.append(c)

    print coef
Esempio n. 23
0
def  r_optimum_full(l, r, l_d, r_d, lp, rp, lp_d, rp_d ,N_uni,U):
 U.setLabel([-20,-40,20,40])
 H1=copy.copy(U)
 H1.transpose()
 H1.setLabel([-20,-40,30,50])
 #print H1, U
 Iden=uni10.UniTensor(U.bond())
 d=U.bond()[0].dim()*U.bond()[1].dim()
 matrix_Iden=uni10.Matrix(d, d)
 matrix_Iden.identity()
 Iden.putBlock(matrix_Iden)
 Iden.setLabel([-20,-40,20,40])
 A2=(((lp*lp_d)*N_uni)*Iden)
 A2.permute([3,20,1,-3,-20,-1],3)
 A2_trans=copy.copy(A2)
 A2_trans.transpose()
 A2=A2+A2_trans
 
 
 A3=((r)*U*(l*lp_d))*N_uni
 A3.permute([-3,-20,-1],0)
 A3p=((r_d)*U*(l_d*lp))*N_uni
 A3p.permute([3,20,1],0)
 A3=A3+A3p



 svd=A2.getBlock().svd()
 Landa=inv(svd[1])
 #print Landa.getBlock()*svd[1]
 v=copy.copy(svd[2])
 v.transpose()
 u=svd[0]
 u.transpose()
 s=Landa.getBlock()
 A2_inv=v*s*u
 A2_mat=A2.getBlock()
 #distance_iden_val=distance_iden(A2_mat,A2_inv)
 #print 'distance1=', distance_iden_val
 #print A2.getBlock()*A2_inv

 A=A3.getBlock()
 A=A*A2_inv
 A3.putBlock(A)
 A3.setLabel([3,20,1])
 A3.permute([3,20,1],2)

 rf=copy.copy(A3)
 rf_d=copy.copy(rf)
 rf_d.setLabel([-3,-20,-1])

 return rf, rf_d
Esempio n. 24
0
def Ham(h):
    spin = 0.5
    sx = (matSp() + matSm())
    sz = matSz()
    iden = uni10.Matrix(2, 2, [1, 0, 0, 1])
    ham = uni10.otimes(sz, sz) * (-2.00) + (-0.500) * float(h) * (
        uni10.otimes(iden, sx) + uni10.otimes(sx, iden))
    dim = int(spin * 2 + 1)
    bdi = uni10.Bond(uni10.BD_IN, dim)
    bdo = uni10.Bond(uni10.BD_OUT, dim)
    H = uni10.UniTensor([bdi, bdi, bdo, bdo], "TFIM")
    H.putBlock(ham)
    return H
Esempio n. 25
0
def transverseIsing(h):
    spin = 0.5
    sx = 0.5 * (matSp() + matSm())
    sz = matSz()
    iden = uni10.Matrix(2, 2, [1, 0, 0, 1])
    ham =uni10.otimes(2*sz,2*sz)*(-1) \
     +0.25*float(h)*(uni10.otimes(iden,2*sx)+uni10.otimes(2*sx,iden))
    dim = int(spin * 2 + 1)
    bdi = uni10.Bond(uni10.BD_IN, dim)
    bdo = uni10.Bond(uni10.BD_OUT, dim)
    H = uni10.UniTensor([bdi, bdi, bdo, bdo], "TFIM")
    H.putBlock(ham)
    return H
Esempio n. 26
0
def   svd_parity(theta):
    #print theta,theta.getBlock().svd()
    bdo=uni10.Bond(uni10.BD_OUT,theta.bond(1).Qlist())
    bdo1=uni10.Bond(uni10.BD_OUT,theta.bond(2).Qlist())

    #A_{m<n}=U_{mm}S_{mm}V_{mn}

    LA=uni10.UniTensor([theta.bond(1), bdo])
    GA=uni10.UniTensor([theta.bond(0), theta.bond(1),bdo])
    GB=uni10.UniTensor([theta.bond(1), bdo1])
    svds = {}
    blk_qnums = theta.blockQnum()
    dim_svd=[]
    for qnum in blk_qnums:
        svds[qnum] = theta.getBlock(qnum).svd()
    for qnum in blk_qnums:
        svd = svds[qnum]
        GA.putBlock(qnum, svd[0])
        GB.putBlock(qnum, svd[2])
        LA.putBlock(qnum, svd[1])
#    print LA
    return GA, LA,GB
Esempio n. 27
0
def Iden_uni10(d):
 bdi=uni10.Bond(uni10.BD_IN, d)
 bdo=uni10.Bond(uni10.BD_OUT, d)
 Iden_Matrix=uni10.Matrix(d*d,d)
 for i in xrange(d):
   for j in xrange(d):
    for m in xrange(d):
     if i is j and j is m: 
      Iden_Matrix[i*d+j,m]=1
     else:
      Iden_Matrix[i*d+j,m]=0
 Iden_uni10=uni10.UniTensor([bdi,bdi,bdo], 'Iden_uni10')
 Iden_uni10.putBlock(Iden_Matrix)   
 return Iden_uni10
Esempio n. 28
0
def transverseIsing(h):
    spin = 0.5
    sx = matSx()
    sy = matSy()
    sz = matSz()
    iden = uni10.Matrix(2, 2, [1, 0, 0, 1])
    ham = uni10.otimes(sz, sz) * (-1) + (-0.2500) * float(h) * (
        uni10.otimes(iden, sx) + uni10.otimes(sx, iden))
    dim = int(spin * 2 + 1)
    bdi = uni10.Bond(uni10.BD_IN, dim)
    bdo = uni10.Bond(uni10.BD_OUT, dim)
    H = uni10.UniTensor([bdi, bdi, bdo, bdo], "TFIM")
    H.putBlock(ham)
    return H
Esempio n. 29
0
def initialize_SVD_lrprime(l, r, l_d, r_d, N_uni,U,D,d_phys):
 
 bdiB=uni10.Bond(uni10.BD_IN, d_phys*D)
 bdoB=uni10.Bond(uni10.BD_OUT, d_phys*D)
 bdi_pys=uni10.Bond(uni10.BD_IN, d_phys)
 bdi_pyso=uni10.Bond(uni10.BD_OUT, d_phys)
 bdi=uni10.Bond(uni10.BD_IN, D)
 bdo=uni10.Bond(uni10.BD_OUT, D)

 U.setLabel([-20,-40,20,40])
 lp=copy.copy(l)
 rp=copy.copy(r)
 #lp.setLabel([1,40,-3])
 Teta=U*lp*rp
 Teta.permute([1,-20,2,-40],2)
 svd=Teta.getBlock().svd()
 s=Sqrt(svd[1])
 U=svd[0]*s
 V=s*svd[2]
 U.resize(U.row(),rp.bond()[0].dim() )
 V.resize(rp.bond()[0].dim(), V.col())
 
 rp=uni10.UniTensor([bdiB, bdi_pys, bdo ])
 rp.putBlock(U)
 rp.setLabel([1,20,3])
 rp.permute([3,20,1],2)
 
 lp=uni10.UniTensor([ bdi, bdoB, bdi_pyso])
 lp.putBlock(V)
 lp.setLabel([3,2,40])
 lp.permute([2,40,3],2)
 lp_d=copy.copy(lp)
 rp_d=copy.copy(rp)
 rp_d.setLabel([-3,-20,-1])
 lp_d.setLabel([-2,-40,-3])
 
 return  lp, rp, lp_d, rp_d
Esempio n. 30
0
def Heisenberg(h):
    spin = 0.5
    sx = matSx()
    sy = matSy()
    sz = matSz()
    iden = uni10.Matrix(2, 2, [1, 0, 0, 1])
    ham = (float(h) * uni10.otimes(sz, sz) * (1.00 / 4.00) +
           (1.00 / 4.00) * uni10.otimes(sx, sx) +
           (-1.00 / 4.00) * uni10.otimes(sy, sy))
    dim = int(spin * 2 + 1)
    bdi = uni10.Bond(uni10.BD_IN, dim)
    bdo = uni10.Bond(uni10.BD_OUT, dim)
    H = uni10.UniTensor([bdi, bdi, bdo, bdo], "Heisenberg")
    H.putBlock(ham)
    return H