def spin1_lanczos(D, nsite, Jz=1.0, k=1, target_block=None, periodic=False): """test for directly construct and solve the ground state energy.""" model = Spin1Model2(J=1, Jz=Jz, D=D, nsite=nsite, periodic=periodic) hgen = RGHGen( spaceconfig=model.spaceconfig, H=model.H_serial, evolutor_type="null" if target_block is None else "normal" ) if target_block is None: H = get_H(hgen=hgen) Emin, Evec = _eigsh(H, k=k) elif isinstance(target_block, (tuple, list)): assert k == 1 H0, bm2 = get_H_bm(hgen=hgen, bstr="M") EL, VL = [], [] for tb in target_block: H = bm2.lextract_block(H0, (tb, tb)) Ei, Vi = _eigsh(H, k=1) EL.append(Ei) VL.append(Vi) # print H-H.T.conj() # pdb.set_trace() Emin = concatenate(EL) Evec = None # concatenate(VL,axis=1) else: H, bm2 = get_H_bm(hgen=hgen, bstr="M") H = bm2.lextract_block(H, (target_block, target_block)) Emin, Evec = _eigsh(H, k=k) print "The Ground State Energy is %s" % Emin return Emin, Evec
def get_mps(K,Jp,J1=1.,J2=0.2412,nsite=30,which='finite',data_file=None): ''' Run finite-DMFT/lanczos for two impurity Kondo model to get the Ground state energy. Parameters: :J1/J2/K/Jp: float, the parameters defining the model. :nsite: integer, the number of sites, must be even. :which: 'finite'/'lanczos', select the method to solve the chain, 'finite dmrg' or 'lanczos'. ''' assert(which=='finite' or which=='lanczos') assert(nsite%2==0) model=TIKM(J1=J1,J2=J2,K=K,Jp=Jp,nsite=nsite) hgen=SpinHGen(spaceconfig=model.spaceconfig,evolutor=MaskedEvolutor(hndim=model.spaceconfig.hndim) if which=='finite' else NullEvolutor(hndim=2)) dmrgegn=DMRGEngine(hchain=model.H_serial,hgen=hgen,tol=0) if which=='lanczos': H=get_H(H=model.H_serial,hgen=hgen) EG,EV=eigsh(H,k=1) mps=state2MPS(EV[:,0]) else: EG=dmrgegn.run_finite(endpoint=(2,'<-',0),maxN=[10,20],tol=0)[-1] mps=dmrgegn.get_mps(direction='<-') #right normalized initial state if data_file is not None: mps.save(data_file) return mps