示例#1
0
def setupQtmpPRDM(dmrg,ncsite,key,status):
   dmrg.qkey = numpy.array(eval(key))
   if ncsite == 1:
      qsymr = dmrg.qkey-dmrg.qlst[2]
      qnums = [dmrg.qlst[0],dmrg.qlst[1],qsymr]
      dmrg.qtmp = qtensor.qtensor([False,False,True])
   elif ncsite == 2:
      if status == 'L':
         qsymr = mpo_dmrg_qphys.dpt(dmrg.qlst[2],dmrg.qlst[3])
         qsymr = dmrg.qkey - qsymr
         qnums = [dmrg.qlst[0],dmrg.qlst[1],qsymr]
      elif status == 'R':
         qsyml = mpo_dmrg_qphys.dpt(dmrg.qlst[0],dmrg.qlst[1])
         qsymr = dmrg.qkey-dmrg.qlst[3]
         qnums = [qsyml,dmrg.qlst[2],qsymr]
      dmrg.qtmp = qtensor.qtensor([False,False,True])
   rank,qsyms,ndims,idlst = qtensor_util.fromQnums(qnums)
   dmrg.qtmp.fromQsyms(rank,qsyms,ndims)
   dmrg.idlstCI = copy.deepcopy(idlst)
   # For pRDM:
   if status == 'L':
      qnums2 = [qnums[0],qnums[1],qnums[0],qnums[1]]
   elif status == 'R':
      qnums2 = [qnums[1],qnums[2],qnums[1],qnums[2]]
   rank,qsyms,ndims,idlst = qtensor_util.fromQnums(qnums2)
   dmrg.idlstPRDM = copy.deepcopy(idlst)
   return 0
示例#2
0
def sweep_updateBoundary(dmrg, ncsite, sitelst, qred, srotR, status):
    if ncsite == 2:
        if status == 'L' and sitelst[-1] == dmrg.nsite - 1:
            # >>> Only the gs state is saved for generating MPS.
            smat = srotR[0]
            norm = numpy.linalg.norm(smat)
            if (not dmrg.ifpt) or (dmrg.ifpt and dmrg.ifcompression):
                smat = smat / norm
            key = mpo_dmrg_dotutil.floatKey(dmrg.qsectors.keys()[0])
            qsym = [numpy.array(eval(key))]
            if dmrg.ifQt:
                qtmp = qtensor.qtensor([False, False, True])
                qtmp.fromDenseTensor(smat,
                                     [qred, dmrg.qphys[dmrg.nsite - 1], qsym])
                smat = qtmp
            # DUMP
            mpo_dmrg_io.saveQnum(dmrg.flmps, dmrg.nsite, qsym)
            mpo_dmrg_io.saveSite(dmrg.flmps, dmrg.nsite - 1, smat)
        elif status == 'R' and sitelst[0] == 0:
            # >>> Only the gs state is saved for generating MPS.
            smat = srotR[0]
            norm = numpy.linalg.norm(smat)
            if (not dmrg.ifpt) or (dmrg.ifpt and dmrg.ifcompression):
                smat = smat / norm
            key = mpo_dmrg_dotutil.floatKey(dmrg.qsectors.keys()[0])
            qsym = [numpy.array(eval(key))]
            if dmrg.ifQt:
                qtmp = qtensor.qtensor([True, False, False])
                qtmp.fromDenseTensor(smat, [qsym, dmrg.qphys[0], qred])
                smat = qtmp

# DUMP
            mpo_dmrg_io.saveQnum(dmrg.frmps, 0, qsym)
            mpo_dmrg_io.saveSite(dmrg.frmps, 0, smat)
    return 0
示例#3
0
def sweep_updateSite(dmrg, isite, ncsite, sigs, qred, site, status):
    # Update symmetry and save sites
    if status == 'L':
        # Example:[==**-] isite=2, lmps[2], qnuml[3]
        dmrg.sigsl[isite + 1] = sigs.copy()
        dmrg.qnuml[isite + 1] = qred.copy()
        if dmrg.ifQt:
            qtmp = qtensor.qtensor([False, False, True])
            #				Ql[i-1]  +  Qn[i]  =  Ql[i]
            qtmp.fromDenseTensor(site, [dmrg.qlst[0], dmrg.qlst[1], qred])
            siteN = qtmp
        else:
            siteN = site.copy()
        # DUMP
        mpo_dmrg_io.saveQnum(dmrg.flmps, isite + 1, qred)
        mpo_dmrg_io.saveSite(dmrg.flmps, isite, siteN)
    elif status == 'R':
        # Example: [--**=] isite=2, jsite=3, rmps[3], qnumr[3]
        jsite = isite + ncsite - 1
        dmrg.sigsr[jsite] = sigs.copy()
        dmrg.qnumr[jsite] = qred.copy()
        if dmrg.ifQt:
            qtmp = qtensor.qtensor([True, False, False])
            #		          Qr[i-1]  =  Qn[i]   +   Qr[i]
            qtmp.fromDenseTensor(site, [qred, dmrg.qlst[-2], dmrg.qlst[-1]])
            siteN = qtmp
        else:
            siteN = site.copy()
        # DUMP
        mpo_dmrg_io.saveQnum(dmrg.frmps, jsite, qred)
        mpo_dmrg_io.saveSite(dmrg.frmps, jsite, siteN)
    return siteN
示例#4
0
def setupQtmpCI(dmrg,ncsite,key):
   dmrg.qkey = numpy.array(eval(key))
   if ncsite == 1:
      qnums = [dmrg.qlst[0],dmrg.qlst[1],dmrg.qkey-dmrg.qlst[2]]
      dmrg.qtmp = qtensor.qtensor([False,False,True])
   elif ncsite == 2:
      qnums = [dmrg.qlst[0],dmrg.qlst[1],dmrg.qlst[2],dmrg.qkey-dmrg.qlst[3]]
      dmrg.qtmp = qtensor.qtensor([False,False,False,True])
   rank,qsyms,ndims,idlst = qtensor_util.fromQnums(qnums)
   dmrg.qtmp.fromQsyms(rank,qsyms,ndims)
   dmrg.idlstCI = copy.deepcopy(idlst)
   return 0
示例#5
0
def loadSite(fmps, isite, ifQt):
    key = 'site' + str(isite)
    if ifQt:
        site = qtensor.qtensor()
        site.load(fmps, key)
    else:
        site = fmps[key].value
    return site
示例#6
0
def copyMPS(fmps1, fmps0, ifQt):
    nsite = fmps0['nsite'].value
    print '\n[mpo_dmrg_io.copyMPS] ifQt=', ifQt, ' nsite=', nsite
    if 'nsite' in fmps1: del fmps1['nsite']
    fmps1['nsite'] = nsite
    # Store qnums
    for isite in range(nsite + 1):
        key = 'qnum' + str(isite)
        if key in fmps1: del fmps1[key]
        fmps1[key] = fmps0[key].value
    # Store sites
    if not ifQt:
        for isite in range(nsite):
            key = 'site' + str(isite)
            if key in fmps1: del fmps1[key]
            fmps1[key] = fmps0[key].value
    else:
        for isite in range(nsite):
            key = 'site' + str(isite)
            if key in fmps1: del fmps1[key]
            site = qtensor.qtensor()
            site.load(fmps0, key)
            site.dump(fmps1, key)
    return 0