## Question about generating random MPS

How do I use this algorithm? What does that parameter do?
QichengTang
Posts: 32
Joined: 08 Jan 2019, 03:03

### Question about generating random MPS

Hi everyone,

I'm trying to generate a random MPS by using the example in test module of tenpy (see the end of this post).
I found that when L > 140, it will raise RuntimeError: SVD found no singluar values.

thanks,
Qicheng

Code: Select all

def random_SpinHalfMPS(L, chimax, func=randmat.standard_normal_complex, bc='finite', form='B'):
d = 2
site = SpinHalfSite(conserve=None)
chi = [chimax] * (L + 1)
if bc == 'finite':
for i in range(L // 2 + 1):
chi[i] = chi[L - i] = min(chi[i], d**i)
Bs = []
for i in range(L):
Bs.append(func((d, chi[i], chi[i + 1])))
#dtype = np.common_type(*Bs)
psi = MPS.from_Bflat([site] * L, Bs, bc=bc, dtype=None, form=None)
if form is not None:
psi.canonical_form()
psi.convert_form(form)
return psi

Johannes
Posts: 198
Joined: 21 Jul 2018, 12:52
Location: UC Berkeley

### Re: Question about generating random MPS

This is an overflow error; the norm of the psi increases with each tensor added.
You can observe this by using psi.canonical_form_finite(renormalize=False) and printing psi.norm of the final state.
The norm blows up exponentially with the number of tensors.
Trying a few normalizations, I found that

Code: Select all

Bs = []
for i in range(L):
Bs.append(func((d, chi[i], chi[i + 1]))/ (np.sqrt(chi[i+1]) * d))

is the correct normalization to counter the blowup of the norm in this case.