Beispiel #1
0
def mf_wave(method,append=False,dmu=0.01,**kwargs):
    '''
    Get the majorana wave functions.
    '''
    even_block=(0,0)
    odd_block=(0,1)
    blocks=[even_block,odd_block]
    filenames=['data/mps_W1%s_W2%s_U%s_N%s_dmu%s_%s.dat'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'),dmu,blocks[0]),
        'data/mps_W1%s_W2%s_U%s_N%s_dmu%s_%s.dat'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'),dmu,blocks[1])]
    mjfile='data/mf_W1%s_W2%s_U%s_N%s_dmu%s.npy'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'),dmu)
    #filenames2=['data/mps_W1%s_W2%s_U%s_N%s_dmu%s_%s.dat'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'),-dmu,blocks[0]),
        #'data/mps_W1%s_W2%s_U%s_N%s_dmu%s_%s.dat'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'),-dmu,blocks[1])]
    if method=='dmrg':
        kets=[]
        model,expander=get_solving_system(evolutor_type='masked',perturb={'mu':(0,dmu)},periodic=False,**kwargs)
        if not append:
            for target_block,filename in zip(blocks,filenames):
                EG,ket=solve_dmrg(model,expander,target_block=odd_block,nlevel=1)
                ket.save(filename)
                kets.append(ket)
            ket_even,ket_odd=kets
        else:
            ket_even=MPS.load(filenames[0])
            ket_odd=MPS.load(filenames[1])
            #ket_even=MPS.load(filenames[0])+MPS.load(filenames2[0])
            #ket_odd=MPS.load(filenames[1])+MPS.load(filenames2[1])
            #ket_even.compress()
            #ket_odd.compress()
    elif method=='direct':
        model,expander=get_solving_system(evolutor_type='full',periodic=False,**kwargs)
        EGs,EVs=solve_direct(model,k=2)
        EG_even,ket_even=EGs[1],state2MPS(EVs[:,1],sitedim=expander.spaceconfig.hndim,l=0)
        EG_odd,ket_odd=EGs[0],state2MPS(EVs[:,0],sitedim=expander.spaceconfig.hndim,l=0)

    pls=smajorana4mps(spaceconfig=expander.spaceconfig,ket_even=ket_even,ket_odd=ket_odd,theta=0)
    if RANK==0:
        pls=array(pls)
        #pls=majorana4vec(spaceconfig=model.hgen.spaceconfig,ket_even=ket_even.state,ket_odd=ket_odd.state)
        #pls=dos4mps(spaceconfig=expander.spaceconfig,ket=ket_even)
        #pls=dos4vec(spaceconfig=model.hgen.spaceconfig,ket=EVs[:,0])
        save(mjfile,pls)
        return pls
Beispiel #2
0
def frac_charge(method,filename=None,**kwargs):
    '''
    Get the MPS holding fractional charge and store it.
    '''
    if filename is None:
        filename='data/frac_W1%s_W2%s_U%s_N%s'%(kwargs.get('K1'),kwargs.get('K2'),kwargs.get('U'),kwargs.get('nsite'))
    if method=='dmrg':
        model,expander=get_solving_system(evolutor_type='masked',periodic=False,**kwargs)
        target_block=lambda nsite:(0,0) if nsite%2==0 else (0,0.5)
        EG_even,ket_even=solve_dmrg(model,expander,target_block=target_block,nlevel=1,C2parity=1)
        EG_odd,ket_odd=solve_dmrg(model,expander,target_block=target_block,nlevel=1,C2parity=-1)
    elif method=='direct':
        model,expander=get_solving_system(evolutor_type='full',periodic=False,**kwargs)
        EGs,EVs=solve_direct(model,k=6)
        EG_even,ket_even=EGs[0],state2MPS(EVs[:,0],sitedim=expander.spaceconfig.hndim,l=0)
        EG_odd,ket_odd=EGs[5],state2MPS(EVs[:,5],sitedim=expander.spaceconfig.hndim,l=0)
    ket_even.save(filename+'-even.dat')
    ket_odd.save(filename+'-odd.dat')
    print 'Energy even -> %s, odd -> %s'%(EG_even,EG_odd)
    print 'Err -> %s'%(ket_even.tobra(labels=ket_even.labels)*ket_odd)
    pdb.set_trace()
Beispiel #3
0
def mf_wave(method,**kwargs):
    if method=='dmrg':
        model,expander=get_solving_system(evolutor_type='masked',periodic=False,**kwargs)
        eng_even,ket_even=load_mps(target_block=0,**kwargs)
        eng_odd,ket_odd=load_mps(target_block=1,**kwargs)
        NL=ket_even.l
        pls=majorana4mps(spaceconfig=expander.spaceconfig,ket_even=ket_even,ket_odd=ket_odd,\
                theta=0,ordering=concatenate([arange(NL),arange(NL,model.nsite)[::-1]]))
    elif method=='direct':
        model,expander=get_solving_system(evolutor_type='full',periodic=False,**kwargs)
        EGs,EVs=solve_direct(model)
        EG_even,ket_even=EGs[1],state2MPS(EVs[:,1],sitedim=expander.spaceconfig.hndim,l=0)
        EG_odd,ket_odd=EGs[0],state2MPS(EVs[:,0],sitedim=expander.spaceconfig.hndim,l=0)
    #pls=majorana4mps(spaceconfig=expander.spaceconfig,ket_even=ket_even,ket_odd=ket_odd,\
    #        theta=0,ordering=concatenate([arange(NL),arange(NL,model.nsite)[::-1]]))
    pls=majorana4mps(spaceconfig=expander.spaceconfig,ket_even=ket_even,ket_odd=ket_odd,\
            theta=0,ordering=arange(model.nsite)[::-1])
    #pls=majorana4vec(spaceconfig=model.hgen.spaceconfig,ket_even=ket_even.state,ket_odd=ket_odd.state)
    #pls=dos4mps(spaceconfig=expander.spaceconfig,ket=ket_even)
    #pls=dos4vec(spaceconfig=model.hgen.spaceconfig,ket=EVs[:,0])
    ion()
    #subplot(211)
    #plot(abs(ket_even.state))
    #ylim(0,0.5)
    #subplot(212)
    #plot(abs(ket_odd.state))
    #ylim(0,0.5)
    #pdb.set_trace()
    lw=2
    lc='r'
    for n in xrange(2):
        pln=pls[n]
        ax=subplot(121+n)
        lc=LineCollection([[(i,0),(i,pln[i].real.item())] for i in xrange(model.nsite)])
        lc.set_linewidth(lw)
        ax.add_collection(lc)

        ax.autoscale()
        ax.margins(0.1)
    pdb.set_trace()
Beispiel #4
0
def measure_charge(K1,K2,U,nsite,usemps=True):
    '''
    measure the particle number for 6 sites.
    '''
    model,expander=get_solving_system(K1,K2,U=U,nsite=nsite,mu=0.,t=1.,evolutor_type='null',periodic=False)
    E,V=solve_direct(model,k=1)
    if usemps:
        ns=[opunit_N(spaceconfig=expander.spaceconfig,siteindex=i) for i in xrange(nsite)]
        mps=state2MPS(V[:,0],sitedim=expander.spaceconfig.hndim,l=0)
        dos=[expect_onsite(ket=mps,opunit=ns[i]) for i in xrange(nsite)]
    else:
        spaceconfig=model.hgen.spaceconfig
        vec=V[:,0]
        ns=[op_simple_onsite(spaceconfig=spaceconfig,label='n%s'%i,index=spaceconfig.c2ind(array([[0,i,0],[1,i,0]]))) for i in xrange(nsite)]
        dos=[vec.conj().dot(ns[i]().dot(vec)) for i in xrange(nsite)]
    ion()
    plot(dos)
    ylim(0,2)
    pdb.set_trace()
Beispiel #5
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)