コード例 #1
0
ファイル: mpo_dmrg_propsMPO.py プロジェクト: jamcas/zmpo_dmrg
def genMPO_SiSj(nsite, ig, jg, fname, ifQt, debug=False):
    if debug: print '\n[mpo_dmrg_propsMPO.genMPO_SiSj] fname=', fname
    t0 = time.time()
    fop = h5py.File(fname, 'w')
    nop = 3
    fop['nop'] = nop
    for isite in range(nsite):
        ti = time.time()
        gname = 'site' + str(isite)
        grp = fop.create_group(gname)
        # vec{S}_i*vec{S}_j = 0.5*(Si+*Sj-+Si-*Sj) + Siz*Sjz
        # (only need to put the factor on the first site)
        if not ifQt:
            # Sip*Sjm
            if isite == 0:
                cop = mpo_dmrg_spinopers.genLocal2Spatial(
                    nsite, isite, ig, jg, 'Sp', 'Sm', 0.5)
            else:
                cop = mpo_dmrg_spinopers.genLocal2Spatial(
                    nsite, isite, ig, jg, 'Sp', 'Sm', 1.0)
            grp['op' + str(0)] = cop
            # Sim*Sjp
            if isite == 0:
                cop = mpo_dmrg_spinopers.genLocal2Spatial(
                    nsite, isite, ig, jg, 'Sm', 'Sp', 0.5)
            else:
                cop = mpo_dmrg_spinopers.genLocal2Spatial(
                    nsite, isite, ig, jg, 'Sm', 'Sp', 1.0)
            grp['op' + str(1)] = cop
            # Siz*Sjz
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite, isite, ig, jg,
                                                      'Sz', 'Sz', 1.0)
            grp['op' + str(2)] = cop
        else:
            # Sip*Sjm
            if isite == 0:
                cop = qtensor_spinopers.genLocal2SpatialQt(
                    nsite, isite, ig, jg, 'Sp', 'Sm', 0.5)
            else:
                cop = qtensor_spinopers.genLocal2SpatialQt(
                    nsite, isite, ig, jg, 'Sp', 'Sm', 1.0)
            cop.dump(grp, 'op' + str(0))
            # Sim*Sjp
            if isite == 0:
                cop = qtensor_spinopers.genLocal2SpatialQt(
                    nsite, isite, ig, jg, 'Sm', 'Sp', 0.5)
            else:
                cop = qtensor_spinopers.genLocal2SpatialQt(
                    nsite, isite, ig, jg, 'Sm', 'Sp', 1.0)
            cop.dump(grp, 'op' + str(1))
            # Siz*Sjz
            cop = qtensor_spinopers.genLocal2SpatialQt(nsite, isite, ig, jg,
                                                       'Sz', 'Sz', 1.0)
            cop.dump(grp, 'op' + str(2))
        tf = time.time()
        if debug: print ' isite =', isite, ' time = %.2f s' % (tf - ti)
    t1 = time.time()
    if debug: print ' time for genMPO_SiSj = %.2f s' % (t1 - t0)
    return fop
コード例 #2
0
def genMPO_Local2Rpt(nsite,ig,jg,ikey,jkey,fac,fname,xts,ifQt,debug=False):
   if debug: print('\n[mpo_dmrg_propsMPORpt.genMPO_Local2Rpt] fname=',fname)
   if debug: print(' ig=',ig,' jg=',jg,' ikey/jkey=',(ikey,jkey))
   t0 = time.time()
   fop = h5py.File(fname,'w')
   npt = len(xts)
   nop = 1*npt
   fop['nop'] = nop
   for isite in range(nsite):
      ti = time.time()
      gname = 'site'+str(isite)
      grp = fop.create_group(gname)
      if not ifQt:
         cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,ikey,jkey,fac)
         for ipt in range(npt):
            rop = mpo_dmrg_opers.genExpISyPhiMat(xts[ipt])
            wop = numpy.tensordot(cop,rop,axes=([3],[0]))
            grp['op'+str(ipt)] = wop
      else:
         for ipt in range(npt):
            cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,ikey,jkey,fac,xts[ipt])
            cop.dump(grp,'op'+str(ipt))
      tf = time.time()
      if debug: print(' isite =',isite,' time = %.2f s'%(tf-ti)) 
   t1 = time.time()
   if debug: print(' time for genMPO_Local2Rpt = %.2f s'%(t1-t0))
   return fop
コード例 #3
0
def genLocal2SpatialQt(nsite,isite,ig,jg,ikey,jkey,fac):
   isym = 2 
   # (D,D,4,4) [D<=2] 
   site = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,ikey,jkey,fac)
   # Status
   qt = qtensor.qtensor([False,True,False,True])
   # Site physical indices
   qu,qd = qtensor_opers.genQphys(isym,isite)
   qli,qri = genSpinOpersQnums(nsite,isite,ikey)
   qlj,qrj = genSpinOpersQnums(nsite,isite,jkey)
   # Direct product of quantum numbers
   ql = [q1+q2 for q1,q2 in itertools.product(qli,qlj)]
   qr = [q1+q2 for q1,q2 in itertools.product(qri,qrj)]
   qt.fromDenseTensor(site,[ql,qr,qu,qd])
   return qt
コード例 #4
0
def genLocal2RSpatialQt(nsite,isite,ig,jg,ikey,jkey,fac,phi):
   isym = 2 
   # (D,D,4,4) [D<=2] 
   cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,ikey,jkey,fac)
   rop = mpo_dmrg_opers.genExpISyPhiMat(phi)
   site = numpy.tensordot(cop,rop,axes=([3],[0]))
   # Status
   qt = qtensor.qtensor([False,True,False,True])
   # Site physical indices
   qu,qd = qtensor_opers.genQphys(isym,isite)
   qli,qri = genSpinOpersQnums(nsite,isite,ikey)
   qlj,qrj = genSpinOpersQnums(nsite,isite,jkey)
   # Direct product of quantum numbers
   ql = [q1+q2 for q1,q2 in itertools.product(qli,qlj)]
   qr = [q1+q2 for q1,q2 in itertools.product(qri,qrj)]
   # Reduce symmetry
   qu = qtensor_util.reduceQnumsToN(qu)
   qd = qtensor_util.reduceQnumsToN(qd)
   ql = qtensor_util.reduceQnumsToN(ql)
   qr = qtensor_util.reduceQnumsToN(qr)
   qt.fromDenseTensor(site,[ql,qr,qu,qd],ifcollect=[0,0,0,0])
   return qt
コード例 #5
0
ファイル: mpo_dmrg_propsMPO.py プロジェクト: jamcas/zmpo_dmrg
def genMPO_Local2(nsite, ig, jg, ikey, jkey, fac, fname, ifQt, debug=False):
    if debug: print '\n[mpo_dmrg_propsMPO.genMPO_Local2] fname=', fname
    if debug: print ' ig=', ig, ' jg=', jg, ' ikey/jkey=', (ikey, jkey)
    t0 = time.time()
    fop = h5py.File(fname, 'w')
    nop = 1
    fop['nop'] = nop
    for isite in range(nsite):
        ti = time.time()
        gname = 'site' + str(isite)
        grp = fop.create_group(gname)
        if not ifQt:
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite, isite, ig, jg,
                                                      ikey, jkey, fac)
            grp['op' + str(0)] = cop
        else:
            cop = qtensor_spinopers.genLocal2SpatialQt(nsite, isite, ig, jg,
                                                       ikey, jkey, fac)
            cop.dump(grp, 'op' + str(0))
        tf = time.time()
        if debug: print ' isite =', isite, ' time = %.2f s' % (tf - ti)
    t1 = time.time()
    if debug: print ' time for genMPO_Local2 = %.2f s' % (t1 - t0)
    return fop
コード例 #6
0
def genMPO_SiSjRpt(nsite,ig,jg,fname,xts,ifQt,debug=False):
   if debug: print('\n[mpo_dmrg_propsMPORpt.genMPO_SiSjRpt] fname=',fname)
   t0 = time.time()
   fop = h5py.File(fname,'w')
   npt = len(xts)
   nop = 3*npt
   fop['nop'] = nop
   for isite in range(nsite):
      ti = time.time()
      gname = 'site'+str(isite)
      grp = fop.create_group(gname)
      # 0.5*(Si+*Sj-+Si-*Sj) + Szi*Szj
      if not ifQt:
         # (a) 0.5*Si+*Sj-
         if isite == 0:
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,'Sp','Sm',0.5)
         else:
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,'Sp','Sm',1.0)
         for ipt in range(npt):
            rop = mpo_dmrg_opers.genExpISyPhi(xts[ipt])
            wop = mpo_dmrg_opers.prodTwoOpers(cop,rop)
            grp['op'+str(0*npt+ipt)] = wop
         # (b) 0.5*Si-*Sj+
         if isite == 0:
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,'Sm','Sp',0.5)
         else:
            cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,'Sm','Sp',1.0)
         for ipt in range(npt):
            rop = mpo_dmrg_opers.genExpISyPhi(xts[ipt])
            wop = mpo_dmrg_opers.prodTwoOpers(cop,rop)
            grp['op'+str(1*npt+ipt)] = wop
         # (c) Szi*Szj
         cop = mpo_dmrg_spinopers.genLocal2Spatial(nsite,isite,ig,jg,'Sz','Sz',1.0)
         for ipt in range(npt):
            rop = mpo_dmrg_opers.genExpISyPhi(xts[ipt])
            wop = mpo_dmrg_opers.prodTwoOpers(cop,rop)
            grp['op'+str(2*npt+ipt)] = wop
      else:
         # Sip*Sjm
         for ipt in range(npt):
            if isite == 0:
               cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,'Sp','Sm',0.5,xts[ipt])
            else:
               cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,'Sp','Sm',1.0,xts[ipt])
            cop.dump(grp,'op'+str(0*npt+ipt))
         # Sim*Sjp
         for ipt in range(npt):
            if isite == 0:
               cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,'Sm','Sp',0.5,xts[ipt])
            else:
               cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,'Sm','Sp',1.0,xts[ipt])
            cop.dump(grp,'op'+str(1*npt+ipt))
         # Siz*Sjz
         for ipt in range(npt):
            cop = qtensor_spinopers.genLocal2RSpatialQt(nsite,isite,ig,jg,'Sz','Sz',1.0,xts[ipt])
            cop.dump(grp,'op'+str(2*npt+ipt))
      tf = time.time()
      if debug: print(' isite =',isite,' time = %.2f s'%(tf-ti)) 
   t1 = time.time()
   if debug: print(' time for genMPO_SiSjRpt = %.2f s'%(t1-t0))
   return fop