コード例 #1
0
ファイル: u2p_debug.py プロジェクト: sunchong137/TNMBL
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
コード例 #2
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())
コード例 #3
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
コード例 #4
0
ファイル: optimize.py プロジェクト: sunchong137/TNMBL
def Mat_np_to_Uni(Mat_np):
    d0 = np.size(Mat_np, 0)
    d1 = np.size(Mat_np, 1)
    Mat_uni = uni10.Matrix(d0, d1)
    for i in xrange(d0):
        for j in xrange(d1):
            Mat_uni[i * d1 + j] = Mat_np[i, j]
    return Mat_uni
コード例 #5
0
ファイル: basicitebd.py プロジェクト: vegaandagev/ipeps-2
def Initialize_function(Gamma, Landa):
    for i in xrange(len(Gamma)):
        Gamma[i].randomize()
    D = Gamma[0].bond(1).dim()
    matrix_Iden = uni10.Matrix(D, D)
    matrix_Iden.identity()
    for i in xrange(len(Landa)):
        Landa[i].putBlock(matrix_Iden)
コード例 #6
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
コード例 #7
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
コード例 #8
0
ファイル: utils.py プロジェクト: sunchong137/TNMBL
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
コード例 #9
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
コード例 #10
0
ファイル: env.py プロジェクト: sunchong137/TNMBL
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
コード例 #11
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
コード例 #12
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
コード例 #13
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
コード例 #14
0
ファイル: basicitebd.py プロジェクト: vegaandagev/ipeps-2
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
コード例 #15
0
ファイル: env.py プロジェクト: sunchong137/TNMBL
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
コード例 #16
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
コード例 #17
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
コード例 #18
0
def distance_iden(A2,A2_inv):
 A=A2*A2_inv
 d=int(A.row())
 matrixI=uni10.Matrix(d, d)
 for i in xrange(d):
  for j in xrange(d):
   if(i==j):
    matrixI[i*d+j]=1.0
   else:
    matrixI[i*d+j]=0.0
 sum=0 
 for i in xrange(d):
  for j in xrange(d):
   sum=abs(A[i*d+j]+(-1.00)*matrixI[i*d+j])
 return sum
コード例 #19
0
def Obtain_grad(l, r, l_d, r_d, lp, rp, lp_d, rp_d ,N_uni,U):
 U.setLabel([-20,-40,20,40])
 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*rp)*N_uni)*Iden)
 A2.permute([-3,-20,-1],0)
 D_r=copy.copy(A2)
 A2=(((lp*lp_d*rp_d)*N_uni)*Iden)
 A2.permute([3,20,1],0)
 D_r=D_r+A2
 A3=((r)*U*(l*lp_d))*N_uni
 A3.permute([-3,-20,-1],0)
 D_r=D_r+(-1.00)*A3
 A3p=((r_d)*U*(l_d*lp))*N_uni
 A3p.permute([3,20,1],0)
 D_r=D_r+(-1.00)*A3p
 D_r.setLabel([3,20,1])
 D_r.permute([3,20,1],2)


 A2=(((rp*rp_d*lp)*N_uni)*Iden)
 A2.permute([-2,-40,-3],0)
 D_l=copy.copy(A2)
 A2=(((rp*rp_d*lp_d)*N_uni)*Iden)
 A2.permute([2,40,3],0)
 D_l=A2+D_l

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

 D_l.setLabel([2,40,3])
 D_l.permute([2,40,3],2)

 
 return D_r, D_l
コード例 #20
0
ファイル: optimize.py プロジェクト: sunchong137/TNMBL
def exp_matrix(H_direct, Gamma, U_update):
    dim0 = int(H_direct.row())
    dim1 = int(H_direct.col())
    M0 = np.zeros((dim0, dim1))
    M_return1 = uni10.Matrix(dim0, dim1)
    #t0 = time.time()
    for i in xrange(dim0):
        for j in xrange(dim1):
            M0[i, j] = H_direct[i * dim1 + j]
    #print time.time() - t0, "replacing"

    M0 = expm(+Gamma * M0)

    for i in xrange(dim0):
        for j in xrange(dim1):
            M_return1[i * dim1 + j] = M0[i, j]
    M_return1 = M_return1 * U_update
    return M_return1
コード例 #21
0
def Distance(l, r, lp, rp ,N_uni, U):
 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])
 
 lp_d=copy.copy(lp)
 rp_d=copy.copy(rp)

 rp_d.setLabel([-3,-20,-1])
 lp_d.setLabel([-2,-40,-3])

 
 l_d=copy.copy(l)
 r_d=copy.copy(r)

 r_d.setLabel([-3,-20,-1])
 l_d.setLabel([-2,-40,-3])
 
 
 
 A1=((((r*r_d)*H)*(N_uni))*l*l_d)
 A2=((((rp*rp_d)*Iden)*(N_uni))*lp*lp_d)
 A3=((((r*rp_d)*U)*(N_uni))*l*lp_d)
 A4=((((rp*r_d)*H1)*(N_uni))*lp*l_d)
 A=A1+A2+(-1.00)*A3+(-1.00)*A4
 return A
コード例 #22
0
ファイル: utils.py プロジェクト: sunchong137/TNMBL
def matSy():
    spin = 0.5
    dim = int(spin * 2 + 1)
    Mat = (1.0) * uni10.Matrix(dim, dim, [0.0, -1.00, 1.00, 0.00])
    return Mat
コード例 #23
0
ファイル: utils.py プロジェクト: sunchong137/TNMBL
def matSz():
    spin = 0.5
    dim = int(spin * 2 + 1)
    Mat = (1.0) * uni10.Matrix(dim, dim, [1.0, 0, 0, -1.0])
    return Mat
コード例 #24
0
ファイル: utils.py プロジェクト: sunchong137/TNMBL
def mat2uni(mat, lmat):
    mat = mat.reshape(lmat**2)
    mat = list(mat)
    unimat = uni10.Matrix(lmat, lmat, mat)
    return unimat
コード例 #25
0
def matSm():
  spin = 1.0
  dim = int(spin * 2 + 1)
  return np.sqrt(2)*uni10.Matrix(dim, dim, [0, 0, 0, 1, 0, 0, 0, 1, 0])
コード例 #26
0
def matSx():
    spin = 0.5
    dim = int(spin * 2 + 1)
    return uni10.Matrix(dim, dim, [0.0, 1.0, 1.00, 0.0])
コード例 #27
0
def bondrm(T, L, bidx):
    invL = uni10.Matrix(L.row(), L.col(), True)
    for i in xrange(L.elemNum()):
        invL[i] = 0 if L[i] == 0 else 1.0 / L[i]
    bondcat(T, invL, bidx)
コード例 #28
0
ファイル: utils.py プロジェクト: sunchong137/TNMBL
def matIden():
    spin_t = 0.5
    dimT = int(2 * spin_t + 1)
    Mat = uni10.Matrix(dimT, dimT, [1, 0, 0, 1])
    return Mat
コード例 #29
0
ファイル: egM1.py プロジェクト: saeedjahromi/uni10
import sys
import pyUni10 as uni10
import copy

# Spin 1/2 Heisenberg hamiltonian
elem = [1.0/4,      0,      0,     0,\
        0, -1.0/4,  1.0/2,     0,\
        0,  1.0/2, -1.0/4,     0,\
        0,      0,      0, 1.0/4]

H = uni10.Matrix(4, 4, elem)

# Diagonlize H
print H
results = H.eigh()
print "The eigen values:\n\n", results[0]
print "The eigen vectors:\n\n", results[1]

# Access element in a diagonal matrix
D = results[0]
print "D[2] =", D[2]

# Assign element
print "\nAssign D[3] = 7\n"
D[3] = 7
print D

# Access element
print "H[5] =", H[5]

#Make a pure density matrix from ground state
コード例 #30
0
ファイル: u2p_debug.py プロジェクト: sunchong137/TNMBL
sys.path.append("/Users/sunchong/CodingDir/TNMBL")
from qsampl import *
from pauli2body import *
import pyUni10 as uni10
from scipy import linalg as sla
import copy 


L=6

# ### bond construction
sx = np.array([0.,1.,1.,0.]).reshape(2,2)
sy = np.array([0.,-1,1,0.]).reshape(2,2)
sz = np.array([1.,0.,0.,-1.]).reshape(2,2)
si = np.eye(2)
Sx = uni10.Matrix(2,2,[0.,1.,1.,0.])
Sy = uni10.Matrix(2,2,[0.,-1,1,0.])
Sz = uni10.Matrix(2,2,[1.,0.,0.,-1.])
Si = uni10.Matrix(2,2,[1.,0.,0.,1.])


hm = -1.* np.kron(sx,sx)-0.5*(np.kron(sz,si)+np.kron(si,sz))
hl = -1.* np.kron(sx,sx)-0.5*np.kron(si,sz)-np.kron(sz,si)
hr = -1.* np.kron(sx,sx)-np.kron(si,sz)-0.5*np.kron(sz,si)

bdi = uni10.Bond(uni10.BD_IN,2)
bdo = uni10.Bond(uni10.BD_OUT,2)

u11 = np.einsum('ij,kl->ikjl',sx,sz)
u12 = np.einsum('ij,kl->ikjl',si,sx)
u13 = np.einsum('ij,kl->ikjl',sz,sz)