예제 #1
0
def genMPO_Apq(nsite, islst, fname, ifQt, debug=False):
    if debug: print '\n[mpo_dmrg_propsMPO.genMPO_Apq] fname=', fname
    t0 = time.time()
    fop = h5py.File(fname, 'w')
    nop = nsite**2
    fop['nop'] = nop
    is1, is2 = islst
    for isite in range(nsite):
        ti = time.time()
        gname = 'site' + str(isite)
        grp = fop.create_group(gname)
        if not ifQt:
            # Loop over operators
            idx = 0
            for p in range(nsite):
                for q in range(nsite):
                    oplst = [[2 * p + is1, 1], [2 * q + is2, 0]]
                    cop = mpo_dmrg_opers.genElemProductSpatial(oplst, isite)
                    grp['op' + str(idx)] = cop
                    idx += 1
        else:
            # Loop over operators
            idx = 0
            for p in range(nsite):
                for q in range(nsite):
                    oplst = [[2 * p + is1, 1], [2 * q + is2, 0]]
                    cop = qtensor_opers.genElemProductSpatialQt(oplst, isite)
                    cop.dump(grp, 'op' + str(idx))
                    idx += 1
        tf = time.time()
        if debug: print ' isite =', isite, ' time = %.2f s' % (tf - ti)
    t1 = time.time()
    if debug: print ' time for genMPO_Apq = %.2f s' % (t1 - t0)
    return fop
예제 #2
0
def genMPO_Epq(nsite, p, q, fname, ifQt, debug=False):
    if debug: print '\n[mpo_dmrg_propsMPO.genMPO_Epq] fname=', fname
    t0 = time.time()
    fop = h5py.File(fname, 'w')
    nop = 2
    fop['nop'] = nop
    for isite in range(nsite):
        ti = time.time()
        gname = 'site' + str(isite)
        grp = fop.create_group(gname)
        if not ifQt:
            # {pa+*qa,pb+*qb}
            for is1 in [0, 1]:
                oplst = [[2 * p + is1, 1], [2 * q + is1, 0]]
                cop = mpo_dmrg_opers.genElemProductSpatial(oplst, isite)
                grp['op' + str(is1)] = cop
        else:
            # {pa+*qa,pb+*qb}
            for is1 in [0, 1]:
                oplst = [[2 * p + is1, 1], [2 * q + is1, 0]]
                cop = qtensor_opers.genElemProductSpatialQt(oplst, isite)
                cop.dump(grp, 'op' + str(is1))
        tf = time.time()
        if debug: print ' isite =', isite, ' time = %.2f s' % (tf - ti)
    t1 = time.time()
    if debug: print ' time for genMPO_Epq = %.2f s' % (t1 - t0)
    return fop