I want to calculate the ground-state entanglement of the transverse Ising model \(H=J_{z}\sum_{i=1}^{L}\sigma_{i}^{z}\sigma_{i+1}^{z}-h_{x}\sum_{i=1}^{L}\sigma_{i}^{x}\) and get a list \(C_{i,i+1}(h_{x})=[C(h_{x}=0.5),C(h_{x}=0.51),...,C(h_{x}=1.5)]\).

Code: Select all

```
L = 10 #the length of Ising chain with periodic boundary condition
Jz = 1
hx = np.arange(0.5,1.501,0.01)
C = []
for i in hx:
product_state = ['up' if random.randint(0,1) else 'down' for _ in range(L)]
hxlist = 2*i*np.ones(L)
hzlist = np.zeros(L)
Jzlist = 4*np.ones(L)
Jxlist = np.zeros(L)
Jylist =np.zeros(L)
model_param = {'L':L,'bc_MPS':'finite','bc_x':'periodic','order':'folded','Jx':Jxlist,'Jy':Jylist,'Jz':Jzlist,'hx':hxlist,'hz':hzlist,'conserve':None}
model = SpinModel(model_param)
options = dict(N_steps=1, trunc_params=trunc_params)
eng = RandomUnitaryEvolution(psi, options)
eng.run()
eng = dmrg.TwoSiteDMRGEngine(psi, model, dmrg_params)
E, psi = eng.run()
rdmn1 = get_rdm(psi,0,1) #get the reduced density matrix of site 0 and 1.
con1 = qcon(rdmn1) #get the nearest-neighbor entanglement between site 0-1.
C.append(con1)
#get the first-excited-state energy
psi1 = psi.copy()
dmrg_params['orthogonal_to'] = [psi]
eng1 = dmrg.TwoSiteDMRGEngine(psi1, model, dmrg_params)
E1, psi1 = eng1.run()
```

1. Is this due to the environment not being reset?

How can I avoid this mistake?

2. How can I output the truncation error to measure the accuracy of the calculation?

Your advice is very important to me, Looking forward to your reply.

Thanks!