Example #1
0
    def __init__(self,t,Delta,mu,nsite,periodic=False,manybody=True):
        self.t,self.mu,self.Delta=t,mu,Delta
        self.nsite=nsite
        self.periodic=periodic
        self.manybody=manybody

        if manybody:
            spaceconfig=SuperSpaceConfig(chorder([1,1,self.nsite,1]))
        else:
            spaceconfig=SpaceConfig(chorder([2,1,self.nsite,1]))
        hgen=RHGenerator(spaceconfig=spaceconfig)

        #define the operator of the system
        hgen.register_params({
            '-t':-self.t if not self.manybody else 2*self.t,
            'Delta':self.Delta,
            '-mu':-self.mu,
            })

        #define a structure and initialize bonds.
        rlattice=Chain(N=nsite)
        if periodic:
            rlattice.usegroup(TranslationGroup(rlattice.N[:,newaxis]*rlattice.a,per=ones(1,dtype='bool')))
        hgen.uselattice(rlattice)

        b1s=rlattice.getbonds(1)  #the nearest neighbor

        #add the hopping term.
        op_t1=op_simple_hopping(label='hop1',spaceconfig=spaceconfig,bonds=b1s)
        hgen.register_operator(op_t1,param='-t')
        op_n=op_simple_onsite(label='n',spaceconfig=spaceconfig)
        hgen.register_operator(op_n,param='-mu')

        #add the p-wave term
        if not manybody:
            op_d=op_on_bond(label='pp',spaceconfig=spaceconfig,mats=[(1j if b.bondv[0]>0 else -1j)*sy for b in b1s],bonds=b1s)
            hgen.register_operator(op_d,param='Delta')
        else:
            op_d=sum([BBilinear(
                index1=spaceconfig.c2ind(chorder([0,b.atom1,0])),  #spin, atom orbit
                index2=spaceconfig.c2ind(chorder([0,b.atom2,0])),
                spaceconfig=spaceconfig,bondv=b.bondv,factor=1 if b.bondv[0]>0 else -1,indices_ndag=2)  #spin, atom orbit
                for b in b1s])
            op_d=op_d+op_d.HC
            hgen.register_operator(op_d,param='Delta')

        self.hgen=hgen
        self.qnumber='PM'
Example #2
0
def test_nonint():
    '''
    Run vMPS for Heisenberg model.
    '''
    nsite=10
    model=ChainN(t=1.,U=0.,nsite=nsite)
    spaceconfig1=SuperSpaceConfig([1,2,1])
    #exact result
    h0=zeros([nsite,nsite])
    fill_diagonal(h0[1:,:-1],1.); h0=h0+h0.T
    e_=2*eigvalsh(h0)
    e_exact=sum(e_[e_<0])
    pdb.set_trace()

    #run vmps
    #generate a random mps as initial vector
    bmg=SimpleBMG(spaceconfig=spaceconfig1,qstring='QM')
    #k0=product_state(config=random.randint(0,2,nsite),hndim=2)
    k0=product_state(config=repeat([1,2],nsite/2),hndim=spaceconfig1.hndim,bmg=bmg)
    mpo=model.hchain.toMPO(bmg=bmg,method='direct')
    #k0=product_state(config=repeat([0,2],nsite/2),hndim=model.spaceconfig.hndim,bmg=bmg)

    #setting up the engine
    vegn=VMPSEngine(H=mpo,k0=k0,eigen_solver='LC')
    #check the label setting is working properly
    assert_(all([ai.shape==(ai.labels[0].bm.N,ai.labels[1].bm.N,ai.labels[2].bm.N) for ai in vegn.ket.ML]))
    assert_(all([ai.shape==(ai.labels[0].bm.N,ai.labels[1].bm.N,ai.labels[2].bm.N,ai.labels[3].bm.N) for ai in vegn.H.OL]))
    #warm up
    vegn.warmup(10)
    vegn.eigen_solver='JD'
    e,v=vegn.run(maxN=[40,60,80,100,100,100,100],which='SA',nsite_update=2,endpoint=(5,'->',0))
    assert_almost_equal(e,e_exact,rtol=1e-4)
Example #3
0
def test_inff(mode='save'):
    '''
    Run infinite vMPS for Heisenberg model.
    '''
    t=1.
    U=100.
    mu=U/2.
    #generate a random mps as initial vector
    spaceconfig1=SuperSpaceConfig([1,2,1])
    bmg=SimpleBMG(spaceconfig=spaceconfig1,qstring='QM')
    k0=product_state(config=array([1,2]),hndim=spaceconfig1.hndim,bmg=bmg)

    model2=ChainN(t=t,U=U,nsite=2,mu=mu)
    mpo2=model2.hchain.toMPO(bmg=bmg,method='direct')

    model=ChainN(t=t,U=U,nsite=4,mu=mu)
    mpo4=model.hchain.toMPO(bmg=bmg,method='direct')

    mpo=model.hchain.toMPO(bmg=bmg,method='direct')
    #setting up the engine
    vegn=VMPSEngine(H=mpo2,k0=k0,eigen_solver='LC')
    vegn.run(1)
    #H2=mpo2.H
    #print eigvalsh(H2)[0]
    #print model2.hchain
    #print model2.hchain.H()-mpo2.H
    #pdb.set_trace()
    filetoken='data/con_dump_U%s_t%s_mu%s'%(U,t,mu)
    if mode=='save':
        vegn.generative_run(HP=mpo4.OL[1:3],ngen=100,niter_inner=1,maxN=100,trunc_mps=True,which='SA')
        vegn.con.dump_data(filetoken)
    else:
        vegn.con.load_data(filetoken)
    pdb.set_trace()
Example #4
0
 def __init__(self, which='flat'):
     self.which = which
     self.set_rhofunc(which)
     N = 45
     Lambda = 3.0
     zl = [1.0]
     spaceconfig = SuperSpaceConfig([2, 1, 1])
     wlist = get_wlist(w0=1e-12,
                       Nw=10000,
                       mesh_type='log',
                       Gap=0.1 if which == 'sc' else 0,
                       D=1.)
     # map it to a sun model
     tickers, discmodel = quick_map(wlist=wlist,
                                    rhofunc=self.rhofunc,
                                    N=N,
                                    z=zl,
                                    tick_params={
                                        'tick_type': 'adaptive',
                                        'Lambda': Lambda
                                    })
     # map it to a Wilson chain
     self.baths = map2chain(discmodel)
     self.scales = [ticker2scale(tickers, N, z) for z in zl]
     expander = RGHGen(H=self.baths[0],
                       spaceconfig=spaceconfig,
                       evolutor_type='null')
Example #5
0
    def __init__(self,t,t2=0,U=0,mu=0.,occ=True,nsite=6):
        self.t,self.t2,self.U,self.mu=t,t2,U,mu
        self.occ=occ
        self.nsite=nsite

        #occupation representation will use <SuperSpaceConfig>, otherwise <SpaceConfig>.
        if self.occ:
            spaceconfig=SuperSpaceConfig([nsite,2,1])
        else:
            spaceconfig=SpaceConfig([2,nsite,1],kspace=False)
            if abs(U)>0: warnings.warn('U is ignored in non-occupation representation.')
        hgen=RHGenerator(spaceconfig=spaceconfig)

        #define the operator of the system
        hgen.register_params({
            '-t1':-self.t,
            '-t2':-self.t2,
            'U':self.U,
            '-mu':-self.mu,
            })

        #define a structure and initialize bonds.
        rlattice=Chain(N=nsite)
        hgen.uselattice(rlattice)

        b1s=rlattice.getbonds(1)  #the nearest neighbor
        b2s=rlattice.getbonds(2)  #the nearest neighbor

        #add the hopping term.
        op_t1=op_simple_hopping(label='hop1',spaceconfig=spaceconfig,bonds=b1s)
        hgen.register_operator(op_t1,param='-t1')
        op_t2=op_simple_hopping(label='hop2',spaceconfig=spaceconfig,bonds=b2s)
        hgen.register_operator(op_t2,param='-t2')
        op_n=op_simple_onsite(label='n',spaceconfig=spaceconfig)
        hgen.register_operator(op_n,param='-mu')

        #add the hubbard interaction term if it is in the occupation number representation.
        if self.occ:
            op_ninj=op_U(label='ninj',spaceconfig=spaceconfig)
            hgen.register_operator(op_ninj,param='U')

        self.hgen=hgen
        spaceconfig1=SuperSpaceConfig([1,2,1])
        self.hchain=op2collection(op=self.hgen.get_opH())
        insert_Zs(self.hchain,spaceconfig=spaceconfig1)
Example #6
0
 def set_params(self, U=0., t=1., mu=0.1, t2=0., nsite=6):
     '''Set the parameters.'''
     self.t, self.U, self.t2, self.mu = t, U, t2, mu
     self.model_exact = ChainN(t=t,
                               U=0,
                               t2=t2,
                               mu=mu,
                               occ=False,
                               nsite=nsite)
     self.model_occ = ChainN(t=t, U=U, t2=t2, mu=mu, occ=True, nsite=nsite)
     scfg = self.model_occ.hgen.spaceconfig
     self.spaceconfig1 = SuperSpaceConfig(
         chorder([1, scfg.nspin, scfg.norbit]))
Example #7
0
def test_int():
    '''
    Run vMPS for Heisenberg model.
    '''
    nsite=32
    U=10.0
    model=ChainN(t=1.,U=U,mu=U/2.,nsite=nsite)
    spaceconfig1=SuperSpaceConfig([1,2,1])
    #EG,mps=self.dmrgrun(model)

    #run vmps
    #generate a random mps as initial vector
    bmg=SimpleBMG(spaceconfig=spaceconfig1,qstring='QM')
    #k0=product_state(config=random.randint(0,2,nsite),hndim=2)
    k0=product_state(config=repeat([1,2],nsite/2),hndim=spaceconfig1.hndim,bmg=bmg)
    #mpo=model.hchain.toMPO(bmg=bmg,method='addition').compress(kernel='ldu')[0]
    #mpo.eliminate_zeros(1e-8)
    mpo=model.hchain.toMPO(bmg=bmg,method='direct')
    #mpo3=model.hchain.toMPO(bmg=bmg,method='direct').compress(kernel='ldu')[0]
    #mpo4=model.hchain.toMPO(bmg=bmg,method='direct').compress(kernel='dpl')[0]
    #k0=product_state(config=repeat([0,2],nsite/2),hndim=model.spaceconfig.hndim,bmg=bmg)

    #warm up the engine
    #vegn=VMPSEngine(H=mpo,k0=k0,eigen_solver='LC')
    #vegn.warmup(12)

    #generative run
    model2=ChainN(t=1,U=U,mu=U/2.,nsite=2)
    k02=product_state(config=array([1,2]),hndim=spaceconfig1.hndim,bmg=bmg)
    mpo2=model2.hchain.toMPO(bmg=bmg,method='direct')
    vegn=VMPSEngine(H=mpo2,k0=k02,eigen_solver='LC')
    vegn.generative_run(HP=mpo.OL[1:3],ngen=nsite/2-1,niter_inner=1,maxN=50,trunc_mps=False,which='SA')

    vegn.run(6,maxN=[40,50,50,50,50,50,50])
    #vegn.run(maxN=80,which='SA',nsite_update=1,endpoint=(3,'->',0))
    pdb.set_trace()
Example #8
0
    def __init__(self,t,mu,K1,K2,nsite,U=0.,periodic=False,use_sx=True):
        self.t,self.mu,self.K1,self.K2,self.U=t,mu,K1,K2,U
        self.nsite=nsite
        self.periodic=periodic
        self.use_sx=use_sx

        spaceconfig=SuperSpaceConfig(chorder([1,2,self.nsite,1]))
        hgen=RHGenerator(spaceconfig=spaceconfig)

        #define the operator of the system
        hgen.register_params({
            '-t':-self.t,
            'K1':self.K1,
            'K2':self.K2,
            '-mu':-self.mu,
            'U':self.U
            })

        #define a structure and initialize bonds.
        rlattice=Chain(N=nsite)
        if periodic:
            rlattice.usegroup(TranslationGroup(rlattice.N[:,newaxis]*rlattice.a,per=ones(1,dtype='bool')))
        hgen.uselattice(rlattice)

        b1s=rlattice.getbonds(1)  #the nearest neighbor

        #add the hopping term.
        op_t1=op_simple_hopping(label='hop1',spaceconfig=spaceconfig,bonds=b1s)
        hgen.register_operator(op_t1,param='-t')
        op_n=op_simple_onsite(label='n',spaceconfig=spaceconfig)
        hgen.register_operator(op_n,param='-mu')
        op_nn=op_U(spaceconfig=spaceconfig)
        hgen.register_operator(op_nn,param='U')

        #add the interaction term
        ql1=[]
        op_K1=sum([Qlinear(indices=array([
            spaceconfig.c2ind(chorder([0,i%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([1,i%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([1,(i+1)%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([0,(i+1)%nsite,0]))]),spaceconfig=spaceconfig)  #spin, atom orbit
            for i in xrange(nsite if periodic else nsite-1)])
        op_K1=op_K1+op_K1.HC
        op_K1.label='K1'
        hgen.register_operator(op_K1,param='K1')

        op_K2=sum([Qlinear(indices=array([
            spaceconfig.c2ind(chorder([0,i%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([0,(i+1)%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([1,(i+1)%nsite,0])),  #spin, atom orbit
            spaceconfig.c2ind(chorder([1,i%nsite,0]))]),spaceconfig=spaceconfig)  #spin, atom orbit
            for i in xrange(nsite if periodic else nsite-1)])
        op_K2=op_K2+op_K2.HC
        if self.use_sx:
            op_K2+=sum([Qlinear(indices=array([
                spaceconfig.c2ind(chorder([0,i%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([1,(i+1)%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([0,(i+1)%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([1,i%nsite,0]))]),spaceconfig=spaceconfig)  #spin, atom orbit
                for i in xrange(nsite if periodic else nsite-1)])
            op_K2+=sum([Qlinear(indices=array([
                spaceconfig.c2ind(chorder([1,i%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([0,(i+1)%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([1,(i+1)%nsite,0])),  #spin, atom orbit
                spaceconfig.c2ind(chorder([0,i%nsite,0]))]),spaceconfig=spaceconfig)  #spin, atom orbit
                for i in xrange(nsite if periodic else nsite-1)])
        op_K2.label='K2'
        hgen.register_operator(op_K2,param='K2')

        self.hgen=hgen
        self.qnumber='QR' if K2!=0 else 'QM'
Example #9
0
 def test_H0(self):
     spaceconfig = SuperSpaceConfig([2, 1, 1])
     ed, Bz = 0.2, 0.3
     imp = AndersomImp(U=1., ed=ed, Bz=Bz)
     assert_allcose(imp.H0, ed * identity(2) + Bz * sz)