### Question about generating random MPS

Posted:

**02 Apr 2020, 05:39**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.

I'm not sure where I make wrong, does anyone know something about this?

thanks,

Qicheng

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.

I'm not sure where I make wrong, does anyone know something about this?

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
```