## MPO-MPS contraction using apply

How do I use this algorithm? What does that parameter do?
Ned
Posts: 2
Joined: 31 Aug 2022, 13:29

### MPO-MPS contraction using apply

Hello all,

I have an operator which is the summation of the annihilation operator of fermions and each term in the summation has a different coefficient.
= \sum a_{i}* c_{i, \up}

since we should consider the Jordan Wigner string, it is not possible to use the onsite function so I try to construct the MPO in the following way.

(i= 1: W =[Cu , JW]
1< i<L : W = [ [Id, 0] , [Cu , JW] ]
i=L : W =[ [Id , Cu] ] )

Code: Select all

def test_MPO():

deltax= 0.05 ; Kf = 0.0 ;  J0= 5  ;  K0 =0.0
gauss_coef = []
for j in range(L):
abc = (-((j-J0)**2) / (2.0 * deltax)) + 1j*K0*j*np.pi
gauss_coef.append(np.exp(abc))

s = SpinHalfFermionSite (cons_N="N", cons_Sz="Sz",filling=1.0)

for i in range(L):

W_grid = [[s.Id , None], [  (gauss_coef[i])* s.Cu , s.JW ]]
legW = npc.LegCharge.from_qflat(s.leg.chinfo, [ s.Cu.qtotal, s.JW.qtotal])
W = npc.grid_outer( W_grid, [legW, legW.conj()], grid_labels=['wL', 'wR'])
Ws = [W] * L
Ws[0] = W[-1:, :]
Ws[-1] = W[:, :1]
#for i in range(L):
#print('Ws[',i,']=' , Ws[i])

WP = mpo.MPO([s] * L, Ws, bc='finite', IdL=[0] * L + [None], IdR=[None] + [-1] * (L))

return( WP)

MM1 = test_MPO()
Excited = MM1.apply(phi, options={'compression_method':'SVD', 'trunc_params':{'svd_min': 1.0-10, 'trunc_cut': None, 'verbose': 0} })
print('updated state=',Excited)

When I want to print the properties of this MPO everything looks fine However, when I want to apply this MPO on an MPS, I cannot use the predefined function Apply or apply_naviely in the MPO class.
And instead of an updated MPS I get this: updated state= TruncationError(eps=2.8725e-07, ov=0.9999994255)

Can you please let me know why I can not use the apply function in this case?

thanks
Johannes
Posts: 357
Joined: 21 Jul 2018, 12:52
Location: TU Munich

### Re: MPO-MPS contraction using apply

Sorry that I couldn't answer earlier, I'd been swamped with other things to finish.
You're on the right track, but had some convention issue along the way:

First, in TeNPy, the convention is that Jordan Wigner strings extend to the left, not to the right.
The MPO you wrote down generates $$\sum_i \alpha_i c_i \prod_{j>i} JW_i$$ instead of $$\sum_i \alpha_i c_i \prod_{j<i} JW_i$$.

Second, you wrote the MPO in the lower left triangular form, while in TeNPy we usually write it in the upper right triangular form.
That's not really an issue, if you would have set the IdL=-1 and IdR=0 accordingly, but you set them as IdL=0 and IdR=-1 (corresponding to the upper right triangular form).

I've just imlemented the MPO method from_wavepacket in c9e02cb32a334183fc101e9939fb77541a32e78f.
It contains an example, so I guess you're now good to go.

I didn't test this extensively, so please let me know if you find any issues!