reset environment

How do I use this algorithm? What does that parameter do?
Post Reply
Posts: 6
Joined: 23 Jul 2021, 06:42

reset environment

Post by ling »

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 = dmrg.TwoSiteDMRGEngine(psi, model, dmrg_params)
    E, psi =

    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.

    #get the first-excited-state energy
    psi1 = psi.copy()
    dmrg_params['orthogonal_to'] = [psi]
    eng1 = dmrg.TwoSiteDMRGEngine(psi1, model, dmrg_params)
    E1, psi1 =
con1.png (17.6 KiB) Viewed 86 times
The result is not good that \(C_{i,i+1}\) is affected by the value position in hxlist.
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.
User avatar
Site Admin
Posts: 337
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: reset environment

Post by Johannes »

Since you fully re-initialize the TwoSiteDMRGEngine in the example you sent without passing the environment, you actually don't reuse the environment here. You define a new (random) product_state, but don't use it to initialize psi itself, I assume you also do that within the loop?

And what exactly do your get_rdm and qcon functions do?
The usual definition of the entanglement entropy would just be to call the psi method entanglement_entropy.

The (two-site) truncation error of DMRG is included in the log; you can just call with default parameters.
For a L=10 site chain with chi_max >= 16, there's no truncation at all.
Post Reply