Пример #1
0
def solve_update(model,expander,k=10,target_block=None,**kwargs):
    '''
    Solve using chain updates.
    '''
    H_serial=op2collection(op=model.hgen.get_opH())
    #ion()
    #H_serial.show_advanced()
    #pdb.set_trace()
    t0=time.time()
    if isinstance(expander.evolutor,NullEvolutor):
        H=get_H(H=H_serial,hgen=expander)
        Emin,Evec=eigsh(H,k=k,which='SA',maxiter=5000,v0=random.random(H.shape[0]))
    else:
        H2,bm2=get_H_bm(H=H_serial,hgen=expander,bstr=model.qnumber)
        if target_block is not None:
            if hasattr(target_block,'__call__'):
                target_block=target_block(model.nsite)
            H2=bm2.lextract_block(H2,target_block)
        Emin,Evec=eigsh(H2,k=k,which='SA',v0=random.random(H2.shape[0]))
    t1=time.time()
    print 'The Ground State Energy for %s: %s, Elapse %s.'%(model,array(sorted(Emin)),t1-t0)
    return Emin,Evec
Пример #2
0
def solve1_update(J,nsite,override=True,C2parity=None,h=0.):
    '''Get and store the eigen vectors and eigen values for ground state.'''
    model=IsingModel(J=J,h=h,nsite=nsite)

    spaceconfig=SpinSpaceConfig([2,1])
    H_serial=model.H_serial
    expander=RGHGen(spaceconfig=spaceconfig,H=H_serial,evolutor_type='null')
    t0=time.time()
    H=get_H(expander)
    Emin,EV=eigsh(H,k=2,which='SA')
    t1=time.time()

    print 'The Ground State Energy for %s: %s, Elapse %s.'%(model,Emin,t1-t0)
    print 'FIN - CORE:%s'%RANK

    for i in xrange(2):
        suffix='%s_%s.dat'%(model.get_str(),i)
        filename_mps='data/mps_'+suffix
        filename_eng='data/eng_'+suffix
        mps=state2MPS(EV[:,i],sitedim=2,l=0)
        mps.save(filename_mps)
        savetxt(filename_eng,Emin)
Пример #3
0
def solve_update(model,expander,k=1):
    '''
    Solve using chain updates.
    '''
    H_serial=op2collection(op=model.hgen.get_opH())
    ion()
    #H_serial.show_advanced()
    t0=time.time()
    if isinstance(expander.evolutor,NullEvolutor):
        H=get_H(H=H_serial,hgen=expander)
        Emin,Evec=eigsh(H,k=k,which='SA',tol=1e-12)
    else:
        H2,bm2=get_H_bm(H=H_serial,hgen=expander,bstr='P')
        print bm2.check_blockdiag(H2)
        H_even=bm2.lextract_block(H2,0)
        H_odd=bm2.lextract_block(H2,1)
        Emin_even,Evec_even=eigsh(H_even,k=k,which='SA',tol=1e-12)
        Emin_odd,Evec_odd=eigsh(H_odd,k=k,which='SA',tol=1e-12)
        #Emin,Evec=eigsh(H2,k=k,which='SA',tol=1e-12)
    t1=time.time()
    print 'The Ground State Energy for model %s is %s(even),%s(odd): diff -> %s, Elapse -> %s.'%(
            model,Emin_even.min(),Emin_odd.min(),Emin_odd.min()-Emin_even.min(),t1-t0)
    return Emin_even,Evec_even,Emin_odd,Evec_odd