Exemple #1
0
	def __init__(self):
		self.ket=np.random.rand(2**6)
		self.ket2=np.random.rand(2**6)
		self.mps=ket2mps(self.ket,2,6,cano='right')
		self.mps.contract_s()
		self.mps2=ket2mps(self.ket2,2,6,cano='right')
		self.ops=[np.random.random(size=(2,2)) for i in range(6)]
Exemple #2
0
import numpy as np
from scipy.linalg import kron
from scipy.sparse import identity
from copy import deepcopy

from mps import MPS,ket2mps,overlap,expect
from dmrg import DMRGEngine
from testdmrg import lhgen,rhgen

ket=np.random.rand(2**4)
mps=ket2mps(ket,2,4,cano='mixed',div=2)
ket2=np.random.rand(2**4)
mps2=ket2mps(ket2,2,4,cano='mixed',div=2)

opl=[np.array([[0.5,0.],[0.,-0.5]]),np.array([[1.,0.],[0.,1.]]),np.array([[1.,0.],[0.,1.]]),np.array([[1.,0.],[0.,1.]])]
OP=deepcopy(opl[0])
for i in range(3):
	OP=kron(OP,np.array([[1.,0.],[0.,1.]]))

def test_tomps():
	dmrg=DMRGEngine(lhgen,rhgen)  
	dmrg.finite(mwarmup=10,mlist=[10])
	dmps=dmrg.tomps()
	return dmps

def test_shape(mps):
	for M in mps.Ms:
		print M.shape

def test_shift(mps):
	mps.shift(site=mps.L/2-1)
Exemple #3
0
from scipy.sparse import identity
from copy import deepcopy

from mps import MPS,ket2mps#,overlap,expect
from marker import Marker,MarkerGen,sz_in

pmarkers=[sz_in for i in range(4)]
mgen=MarkerGen(pmarkers,4,0)
markers=mgen.markers
#for marker in markers:
	#perm=marker.reorder()
	#print marker.qns,perm

#ket=np.random.rand(2**4)
ket=np.array([0.,0.,0.,1.,0.,1.,1.,0.,0.,1.,1.,0.,1.,0.,0.,0.])
mps=ket2mps(ket,2,4,cano='right',markers=markers,pmarkers=pmarkers)
mps.contract_s()

def shape():
	for M in mps.Ms:
		print M.shape

def qns():
	for M in mps.Ms:
		for marker in M.markers:
			print marker.qns

def cano():
	for M in mps.Ms[:mps.L]:                                                                                                                                                         
		print np.tensordot(M.array,M.array.conjugate().transpose(),axes=([1,2],[1,0]))-identity(M.shape[0])