Exemplo n.º 1
0
def dumpMPSwithQnums(conf, fname):
    k = len(conf)
    n = int(sum(conf))
    na = numpy.sum(conf[0::2])
    nb = numpy.sum(conf[1::2])
    spin = (na - nb) / 2.0
    # MPS
    mps0 = mps_class.class_mps(k)
    mps0.hfstate(n, conf)
    mps0 = mps0.merge([[2 * i, 2 * i + 1] for i in range(k / 2)])
    mps0.prt()
    #==================================
    # DUMP Qnums also ...
    #==================================
    qnums = [numpy.array([[0.0, 0.0]])]
    ne = 0.0
    ms = 0.0
    for i in range(k / 2):
        ne += conf[2 * i] + conf[2 * i + 1]
        ms += (conf[2 * i] - conf[2 * i + 1]) / 2.0
        qnum = numpy.array([[ne, ms]])
        qnums.append(qnum)
    with h5py.File(fname, 'w') as f:
        mpo_dmrg_io.dumpMPS(f, [mps0.sites, qnums], icase=1)
    #==================================
    return 0
Exemplo n.º 2
0
def dumpMPS(conf, fname):
    k = len(conf)
    n = int(sum(conf))
    na = numpy.sum(conf[0::2])
    nb = numpy.sum(conf[1::2])
    spin = (na - nb) / 2.0
    # MPS
    mps0 = mps_class.class_mps(k)
    mps0.hfstate(n, conf)
    mps0 = mps0.merge([[2 * i, 2 * i + 1] for i in range(k / 2)])
    mps0.prt()
    with h5py.File(fname, 'w') as f:
        mpo_dmrg_io.dumpMPS(f, mps0.sites, icase=0)
        f['qnum%s' % (k / 2)] = numpy.array([[n, spin]])
    return 0
Exemplo n.º 3
0
def cMPS(fmps0,fmps1,icase=1,thresh=-1,Dcut=-1,debug=False):
   nsite = fmps0['nsite'].value
   print('\n[mpo_dmrg_compress.cMPS] icase =',icase,' nsite=',nsite)
   # No symmetry - mpslst as a list
   if icase == 0:
      mps = objectMPS(fmps0,icase)
      mps = mps.dcompress()
      mpo_dmrg_io.dumpMPS(fmps1,mps.sites,icase)
   # With qnums and numpy.array
   elif icase == 1:
      mps = objectMPS(fmps0,icase)
      mps = mps.qcompress(thresh=thresh,Dcut=Dcut,debug=True)
      mps.qnums = [[numpy.array([0.0,0.0])]]+mps.qnums
      mpo_dmrg_io.dumpMPS(fmps1,[mps.sites,mps.qnums],icase)
   # With qnums and Qt     
   elif icase == 2:
      raise NotImplementedError
   return 0