def nAverage_fpeps2by2(peps0): debug = False nr, nc = peps0.shape # <P|P> tmp = peps0[0, 1].copy() p23 = tmp.ptys[0] d23 = tmp.dims[0] p1 = tmp.ptys[2] d1 = tmp.dims[2] swap = fpeps_util.genSwap(p23, d23, p1, d1) peps1 = peps.copy(peps0) peps1[0, 1] = einsum('pludr,pUuP->PlUdr', peps1[0, 1], swap) ovlp = peps.dot(peps1, peps1) if debug: print print "Ovlp=", peps.dot(peps0, peps0) print "Ovlp=", ovlp nloc = fpeps_util.genNloc() # \hat{N} is a sum of local terms nav = 0.0 for i in range(nr): for j in range(nc): peps2 = peps.copy(peps1) peps2[i, j] = einsum('Pp,pludr->Pludr', nloc, peps1[i, j]) nav += peps.dot(peps1, peps2) return ovlp, nav
def nAverage_fpeps3by3(peps0): nr, nc = peps0.shape # <P|P> peps0b = reflection(peps0) peps1b = peps.copy(peps0b) for i in range(nr): for j in range(nc): tmp = peps1b[i, j].copy() p0 = tmp.ptys[1] d0 = tmp.dims[1] p1 = tmp.ptys[2] d1 = tmp.dims[2] swapLU = fpeps_util.genSwap(p0, d0, p1, d1) tmp = einsum('luUL,pLUdr->pludr', swapLU, tmp) p0 = tmp.ptys[4] d0 = tmp.dims[4] p1 = tmp.ptys[3] d1 = tmp.dims[3] swapRD = fpeps_util.genSwap(p0, d0, p1, d1) tmp = einsum('RDdr,pluDR->pludr', swapRD, tmp) peps1b[i, j] = tmp.copy() ovlp = fpeps_util.fdot(peps0b, peps1b) if debug: print print "Ovlp=", peps.dot(peps0, peps0) print "Ovlp=", ovlp nloc = fpeps_util.genNloc() # \hat{N} is a sum of local terms nav = 0.0 for j in range(nc): for i in range(nr): # Measure each local occupation <Ni> peps2b = peps.copy(peps1b) peps2b[i, j] = einsum('Pp,pludr->Pludr', nloc, peps1b[i, j]) nii = fpeps_util.fdot(peps0b, peps2b) nav += nii print '(i,j)=', (i, j), '<Nloc>=', nii, nii / ovlp print 'nav=', ovlp, nav, nav / ovlp return ovlp, nav
def energy_fpeps3by3(peps0): nr, nc = peps0.shape # <P|P> peps0b = reflection(peps0) peps1b = peps.copy(peps0b) for i in range(nr): for j in range(nc): tmp = peps1b[i, j].copy() p0 = tmp.ptys[1] d0 = tmp.dims[1] p1 = tmp.ptys[2] d1 = tmp.dims[2] swapLU = fpeps_util.genSwap(p0, d0, p1, d1) tmp = einsum('luUL,pLUdr->pludr', swapLU, tmp) p0 = tmp.ptys[4] d0 = tmp.dims[4] p1 = tmp.ptys[3] d1 = tmp.dims[3] swapRD = fpeps_util.genSwap(p0, d0, p1, d1) tmp = einsum('RDdr,pluDR->pludr', swapRD, tmp) peps1b[i, j] = tmp.copy() ovlp = fpeps_util.fdot(peps0b, peps1b) if debug: print print "Ovlp=", peps.dot(peps0, peps0) print "Ovlp=", ovlp etot = 0.0 # <P|U[i]|P> if debug: print "\nU-terms:" uterm = fpeps_util.genUterm(U) for j in range(nc): for i in range(nr): peps2 = peps.copy(peps0) peps2[i, j] = einsum('Pp,pludr->Pludr', uterm, peps0[i, j]) peps2b = reflection(peps2) eloc = fpeps_util.fdot(peps2b, peps1b) if debug: print '(i,j)=', (i, j), ' <U>=', eloc etot += eloc # # T-term # tC_aa, tA_aa = fpeps_util.genTaa() tC_bb, tA_bb = fpeps_util.genTbb() # Jordan-Wigner sign factor for i\=j parity = fpeps_util.genParitySgn([0, 1], [2, 2]) tC_aa = einsum('xqp,pr->xqr', tC_aa, parity) tC_bb = einsum('xqp,pr->xqr', tC_bb, parity) # Vertical bond => Simple is the chosen embedding if debug: print "\nVbonds:" for j in range(nc): for i in range(nr - 1): eloc = [0, 0] for idx, thops in enumerate([[tC_aa, tA_aa], [tC_bb, tA_bb]]): tC, tA = thops peps2 = peps.copy(peps0) peps2[i, j] = einsum('xqp,pludr->qlxudr', tC, peps2[i, j]).merge_adjpair(2, 3) peps2[i + 1, j] = einsum('xqp,pludr->qluxdr', tA, peps2[i + 1, j]).merge_adjpair(3, 4) sgn = fpeps_util.genParitySgn(peps2[i + 1, j].ptys[1], peps2[i + 1, j].dims[1]) peps2[i + 1, j] = einsum('lL,qLudr->qludr', sgn, peps2[i + 1, j]) peps2b = reflection(peps2) eloc[idx] = 2.0 * fpeps_util.fdot(peps2b, peps1b) if debug: print 't<i,j>=', (i, j), 'eloc=', sum(eloc), eloc etot += sum(eloc) # horizontal bond # |/ |/ # --A----B-- # /| /| # *----* # | | if debug: print "\nHbonds:" for i in range(nr): for j in range(nc - 1): for idx, thops in enumerate([[tC_aa, tA_aa], [tC_bb, tA_bb]]): tC, tA = thops peps2 = peps.copy(peps0) peps2[i, j] = einsum('xqp,pludr->qludxr', tC, peps2[i, j]).merge_adjpair(4, 5) peps2[i, j + 1] = einsum('xqp,pludr->qxludr', tA, peps2[i, j + 1]).merge_adjpair(1, 2) sgn = fpeps_util.genParitySgn(peps2[i, j].ptys[2], peps2[i, j].dims[2]) peps2[i, j] = einsum('uU,qlUdr->qludr', sgn, peps2[i, j]) #??? WHY??? => ABSORBED. #for k in range(i): # sgn = fpeps_util.genParitySgn(peps2[k,j+1].ptys[0],peps2[k,j+1].dims[0]) # peps2[k,j+1] = einsum('qQ,Qludr->qludr',sgn,peps2[k,j+1]) peps2b = reflection(peps2) eloc[idx] = 2.0 * fpeps_util.fdot(peps2b, peps1b) if debug: print 't<i,j>=', (i, j), 'eloc=', sum(eloc), eloc etot += sum(eloc) return ovlp, etot
def energy_fpeps2by2(peps0): debug = True nr, nc = peps0.shape # <P|P> tmp = peps0[0, 1].copy() p23 = tmp.ptys[0] d23 = tmp.dims[0] p1 = tmp.ptys[1] d1 = tmp.dims[1] swap1 = fpeps_util.genSwap(p23, d23, p1, d1) # In fact, for 'uniform' distribution swap1=swap2 tmp = peps0[0, 2].copy() p23 = tmp.ptys[0] d23 = tmp.dims[0] p1 = tmp.ptys[2] d1 = tmp.dims[2] swap2 = fpeps_util.genSwap(p23, d23, p1, d1) # 'Bosonic peps' peps1 = peps.copy(peps0) peps1[0, 1] = einsum('pludr,pLlP->PLudr', peps1[0, 1], swap1) peps1[0, 2] = einsum('pludr,pUuP->PlUdr', peps1[0, 2], swap2) ovlp = peps.dot(peps1, peps1) if debug: print print "Ovlp(bare)=", peps.dot(peps0, peps0) print "Ovlp(swap)=", ovlp etot = 0.0 # <P|U[i]|P> if debug: print "\nU-terms:" U = 1.5 uterm = fpeps_util.genUterm(U) for j in range(nc): for i in range(nr): peps2 = peps.copy(peps1) peps2[i, j] = einsum('Pp,pludr->Pludr', uterm, peps1[i, j]) eloc = peps.dot(peps1, peps2) if debug: print '(i,j)=', (i, j), ' <U>=', eloc etot = etot + eloc exit() # # # # a b c d # # | | | | # # | 2--*-3 # # |/ |/ # # 0----1 # # # tC_aa,tA_aa = fpeps_util.genTaa() # tC_bb,tA_bb = fpeps_util.genTbb() # # # H02 = vertical bond # peps2 = peps1.copy() # peps2[0,0] = einsum('xqp,pludr->qlxudr',tC_aa,peps1[0,0]).merge_adjpair(2,3) # peps2[1,0] = einsum('xqp,pludr->qluxdr',tA_aa,peps1[1,0]).merge_adjpair(3,4) # elocA = peps.dot(peps1,peps2) # peps2 = peps1.copy() # peps2[0,0] = einsum('xqp,pludr->qlxudr',tC_bb,peps1[0,0]).merge_adjpair(2,3) # peps2[1,0] = einsum('xqp,pludr->qluxdr',tA_bb,peps1[1,0]).merge_adjpair(3,4) # elocB = peps.dot(peps1,peps2) # etot = etot + 2.0*(elocA+elocB) # if debug: # print # print 't02aa=',elocA # print 't02bb=',elocB # # # H23 = horizontal bond # # | | # # *----* # # |/ |/ # # --2----3-- # # / / # peps2 = peps1.copy() # peps2[1,0] = einsum('xqp,pludr->qludxr',tC_aa,peps1[1,0]).merge_adjpair(4,5) # peps2[1,1] = einsum('xqp,pludr->qxludr',tA_aa,peps1[1,1]).merge_adjpair(1,2) # elocA = peps.dot(peps1,peps2) # peps2 = peps1.copy() # peps2[1,0] = einsum('xqp,pludr->qludxr',tC_bb,peps1[1,0]).merge_adjpair(4,5) # peps2[1,1] = einsum('xqp,pludr->qxludr',tA_bb,peps1[1,1]).merge_adjpair(1,2) # elocB = peps.dot(peps1,peps2) # etot = etot + 2.0*(elocA+elocB) # if debug: # print # print 't23aa=',elocA # print 't23bb=',elocB # # # parity along physical index # parity = fpeps_util.genParitySgn([0,1],[2,2]) # # # H01 - hbond # peps2 = peps1.copy() # peps2[0,0] = einsum('xqp,pludr->qludxr',tC_aa,peps1[0,0]).merge_adjpair(4,5) # peps2[0,1] = einsum('xqp,pludr->qxludr',tA_aa,peps1[0,1]).merge_adjpair(1,2) # peps2[1,0] = einsum( 'qp,pludr->qludr',parity,peps1[1,0]) # peps2[1,1] = einsum( 'qp,pludr->qludr',parity,peps1[1,1]) # elocA = peps.dot(peps1,peps2) # peps2 = peps1.copy() # peps2[0,0] = einsum('xqp,pludr->qludxr',tC_bb,peps1[0,0]).merge_adjpair(4,5) # peps2[0,1] = einsum('xqp,pludr->qxludr',tA_bb,peps1[0,1]).merge_adjpair(1,2) # peps2[1,0] = einsum( 'qp,pludr->qludr',parity,peps1[1,0]) # peps2[1,1] = einsum( 'qp,pludr->qludr',parity,peps1[1,1]) # elocB = peps.dot(peps1,peps2) # etot = etot + 2.0*(elocA+elocB) # if debug: # print # print 't01aa=',elocA # print 't01bb=',elocB # # # H13 - vbond # peps2 = peps1.copy() # peps2[0,1] = einsum( 'qp,pludr->qludr',parity,peps1[0,1]) # peps2[0,1] = einsum('xqp,pludr->qlxudr',tC_aa,peps2[0,1]).merge_adjpair(2,3) # peps2[1,1] = einsum('xqp,pludr->qluxdr',tA_aa,peps1[1,1]).merge_adjpair(3,4) # peps2[1,1] = einsum( 'qp,pludr->qludr',parity,peps2[1,1]) # elocA = peps.dot(peps1,peps2) # peps2 = peps1.copy() # peps2[0,1] = einsum( 'qp,pludr->qludr',parity,peps1[0,1]) # peps2[0,1] = einsum('xqp,pludr->qlxudr',tC_bb,peps2[0,1]).merge_adjpair(2,3) # peps2[1,1] = einsum('xqp,pludr->qluxdr',tA_bb,peps1[1,1]).merge_adjpair(3,4) # peps2[1,1] = einsum( 'qp,pludr->qludr',parity,peps2[1,1]) # elocB = peps.dot(peps1,peps2) # etot = etot + 2.0*(elocA+elocB) # if debug: # print # print 't13aa=',elocA # print 't13bb=',elocB return ovlp, etot
def energy_fpeps2by2(peps0): nr, nc = peps0.shape # <P|P> tmp = peps0[0, 1].copy() p23 = tmp.ptys[0] d23 = tmp.dims[0] p1 = tmp.ptys[2] d1 = tmp.dims[2] swap = fpeps_util.genSwap(p23, d23, p1, d1) peps1 = peps.copy(peps0) peps1[0, 1] = einsum('pludr,pUuP->PlUdr', peps1[0, 1], swap) ovlp = peps.dot(peps1, peps1) if debug: print print "Ovlp=", peps.dot(peps0, peps0) print "Ovlp=", ovlp etot = 0.0 # <P|U[i]|P> if debug: print "\nU-terms:" uterm = fpeps_util.genUterm(U) for i in range(nr): for j in range(nc): peps2 = peps.copy(peps1) peps2[i, j] = einsum('Pp,pludr->Pludr', uterm, peps1[i, j]) eloc = peps.dot(peps1, peps2) if debug: print '(i,j)=', (i, j), ' <U>=', eloc etot = etot + eloc # # a b c d # | | | | # | 1--*-3 # |/ |/ # 0----2 # tC_aa, tA_aa = fpeps_util.genTaa() tC_bb, tA_bb = fpeps_util.genTbb() # Test local terms: if debug: tCA_aa = einsum('xqr,xrp->qp', tC_aa, tA_aa) tCA_bb = einsum('xqr,xrp->qp', tC_bb, tA_bb) for i in [0, 1]: peps2 = peps.copy(peps1) peps2[i, 0] = einsum('qp,pludr->qludr', tCA_aa, peps1[i, 0]) elocA = 2.0 * peps.dot(peps1, peps2) print 't[' + str(i) + ']aa=', elocA peps2 = peps.copy(peps1) peps2[i, 0] = einsum('qp,pludr->qludr', tCA_bb, peps1[i, 0]) elocA = 2.0 * peps.dot(peps1, peps2) print 't[' + str(i) + ']bb=', elocA # Jordan-Wigner sign factor for i\=j parity = fpeps_util.genParitySgn([0, 1], [2, 2]) tC_aa = einsum('xqp,pr->xqr', tC_aa, parity) tC_bb = einsum('xqp,pr->xqr', tC_bb, parity) # H01 = vertical bond peps2 = peps.copy(peps1) peps2[0, 0] = einsum('xqp,pludr->qlxudr', tC_aa, peps1[0, 0]).merge_adjpair(2, 3) peps2[1, 0] = einsum('xqp,pludr->qluxdr', tA_aa, peps1[1, 0]).merge_adjpair(3, 4) elocA = 2.0 * peps.dot(peps1, peps2) peps2 = peps.copy(peps1) peps2[0, 0] = einsum('xqp,pludr->qlxudr', tC_bb, peps1[0, 0]).merge_adjpair(2, 3) peps2[1, 0] = einsum('xqp,pludr->qluxdr', tA_bb, peps1[1, 0]).merge_adjpair(3, 4) elocB = 2.0 * peps.dot(peps1, peps2) etot = etot + (elocA + elocB) if debug: print print 't01aa=', elocA print 't01bb=', elocB # H13 = horizontal bond # | | # *----* # |/ |/ # --1----3-- # / / peps2 = peps.copy(peps1) peps2[1, 0] = einsum('xqp,pludr->qludxr', tC_aa, peps1[1, 0]).merge_adjpair(4, 5) peps2[1, 1] = einsum('xqp,pludr->qxludr', tA_aa, peps1[1, 1]).merge_adjpair(1, 2) elocA = 2.0 * peps.dot(peps1, peps2) peps2 = peps.copy(peps1) peps2[1, 0] = einsum('xqp,pludr->qludxr', tC_bb, peps1[1, 0]).merge_adjpair(4, 5) peps2[1, 1] = einsum('xqp,pludr->qxludr', tA_bb, peps1[1, 1]).merge_adjpair(1, 2) elocB = 2.0 * peps.dot(peps1, peps2) etot = etot + (elocA + elocB) if debug: print print 't13aa=', elocA print 't13bb=', elocB # H02 - hbond peps2 = peps.copy(peps1) peps2[0, 0] = einsum('xqp,pludr->qludxr', tC_aa, peps1[0, 0]).merge_adjpair(4, 5) peps2[0, 1] = einsum('xqp,pludr->qxludr', tA_aa, peps1[0, 1]).merge_adjpair(1, 2) peps2[1, 0] = einsum('qp,pludr->qludr', parity, peps1[1, 0]) peps2[1, 1] = einsum('qp,pludr->qludr', parity, peps1[1, 1]) elocA = 2.0 * peps.dot(peps1, peps2) peps2 = peps.copy(peps1) peps2[0, 0] = einsum('xqp,pludr->qludxr', tC_bb, peps1[0, 0]).merge_adjpair(4, 5) peps2[0, 1] = einsum('xqp,pludr->qxludr', tA_bb, peps1[0, 1]).merge_adjpair(1, 2) peps2[1, 0] = einsum('qp,pludr->qludr', parity, peps1[1, 0]) peps2[1, 1] = einsum('qp,pludr->qludr', parity, peps1[1, 1]) elocB = 2.0 * peps.dot(peps1, peps2) etot = etot + (elocA + elocB) if debug: print print 't02aa=', elocA print 't02bb=', elocB # H23 - vbond peps2 = peps.copy(peps1) peps2[0, 1] = einsum('qp,pludr->qludr', parity, peps1[0, 1]) peps2[0, 1] = einsum('xqp,pludr->qlxudr', tC_aa, peps2[0, 1]).merge_adjpair(2, 3) peps2[1, 1] = einsum('xqp,pludr->qluxdr', tA_aa, peps1[1, 1]).merge_adjpair(3, 4) peps2[1, 1] = einsum('qp,pludr->qludr', parity, peps2[1, 1]) elocA = 2.0 * peps.dot(peps1, peps2) peps2 = peps.copy(peps1) peps2[0, 1] = einsum('qp,pludr->qludr', parity, peps1[0, 1]) peps2[0, 1] = einsum('xqp,pludr->qlxudr', tC_bb, peps2[0, 1]).merge_adjpair(2, 3) peps2[1, 1] = einsum('xqp,pludr->qluxdr', tA_bb, peps1[1, 1]).merge_adjpair(3, 4) peps2[1, 1] = einsum('qp,pludr->qludr', parity, peps2[1, 1]) elocB = 2.0 * peps.dot(peps1, peps2) etot = etot + (elocA + elocB) if debug: print print 't23aa=', elocA print 't23bb=', elocB print print 'ovlp,etot=', ovlp, etot return ovlp, etot