def genHRfacSpatialQt(pindx,nsite,isite,int1e,qpts,maxslc=1,model_u=0.): p,ip = pindx iop = 1 isym = 2 status = 'L' isz = p%2 site = mpo_dmrg_opers1e.genHRfacSpatial(pindx,nsite,isite,int1e,qpts,model_u) # Site physical indices qu,qd = qtensor_opers.genQphys(isym,isite) # Orbital dependent part ql1e,qr1e = qtensor_opers.genElemQnums(p,2*isite ,iop,status) ql2e,qr2e = qtensor_opers.genElemQnums(p,2*isite+1,iop,status) ql1 = ql1e qr1 = qr2e ql1w,qr1w = genWfacQnums(nsite,2*isite ,isz,status) ql2w,qr2w = genWfacQnums(nsite,2*isite+1,isz,status) ql2 = ql1w qr2 = qr2w ql = [q1+q2 for q1,q2 in itertools.product(ql1,ql2)] qr = [q1+q2 for q1,q2 in itertools.product(qr1,qr2)] if abs(model_u)>1.e-12: if isite == 0: qr += [[0.,0.]] elif isite == nsite//2-1: ql += [[0.,0.]] else: ql += [[0.,0.]] qr += [[0.,0.]] # Reduce symmetry: local spin rotation do not change particle number if ip is not None: ql = qtensor_util.reduceQnumsToN(ql) qr = qtensor_util.reduceQnumsToN(qr) qu = qtensor_util.reduceQnumsToN(qu) qd = qtensor_util.reduceQnumsToN(qd) # # We sort the internal quantum number first # nql = len(ql) nqr = len(qr) idxl = qtensor_opers.sortQnums(ql) idxr = qtensor_opers.sortQnums(qr) ql = numpy.array(ql)[idxl] qr = numpy.array(qr)[idxr] site = site[numpy.ix_(idxl,idxr)].copy() # Slice operators if necessary qts = qtensor.Qt(2) qts.maxslc[0] = min(maxslc,nql) qts.maxslc[1] = min(maxslc,nqr) qts.genDic() for islc in range(qts.maxslc[0]): slc0 = parallel_util.partitionSites(nql,qts.maxslc[0],islc) for jslc in range(qts.maxslc[1]): slc1 = parallel_util.partitionSites(nqr,qts.maxslc[1],jslc) ijdx = qts.ravel([islc,jslc]) qts.dic[ijdx] = qtensor.qtensor([False,True,False,True]) # Note that the qsyms for the last two dimensions are not collected qts.dic[ijdx].fromDenseTensor(site[numpy.ix_(slc0,slc1)],[ql[slc0],qr[slc1],qu,qd],ifcollect=[1,1,0,0]) qts.size[ijdx] = qts.dic[ijdx].size_allowed return qts
def genHenRfacSpatialQt(dmrg, pindx, isite, iop): p, ip = pindx isym = 2 site = mpo_dmrg_ptopers.genHenRfacSpatial(dmrg, pindx, isite, iop) if iop == 0: nbond = 3 elif iop == 1 or iop == 2: nbond = 5 # Site physical indices qu, qd = genQphys(isym, isite) ql = [[0., 0.]] * nbond qr = [[0., 0.]] * nbond if isite == 0: ql = [[0., 0.]] if isite == dmrg.nsite - 1: qr = [[0., 0.]] ql = numpy.array(ql) qr = numpy.array(qr) # Reduce symmetry: local spin rotation do not change particle number if ip is not None: ql = qtensor_util.reduceQnumsToN(ql) qr = qtensor_util.reduceQnumsToN(qr) qu = qtensor_util.reduceQnumsToN(qu) qd = qtensor_util.reduceQnumsToN(qd) nql = len(ql) nqr = len(qr) # Slice operators if necessary qts = qtensor.Qt(2) qts.maxslc[0] = 1 qts.maxslc[1] = 1 qts.genDic() for islc in range(qts.maxslc[0]): slc0 = parallel_util.partitionSites(nql, qts.maxslc[0], islc) for jslc in range(qts.maxslc[1]): slc1 = parallel_util.partitionSites(nqr, qts.maxslc[1], jslc) ijdx = qts.ravel([islc, jslc]) qts.dic[ijdx] = qtensor.qtensor([False, True, False, True]) # Note that the qsyms for the last two dimensions are not collected qts.dic[ijdx].fromDenseTensor(site[numpy.ix_(slc0, slc1)], [ql[slc0], qr[slc1], qu, qd], ifcollect=[1, 1, 0, 0]) qts.size[ijdx] = qts.dic[ijdx].size_allowed return qts