jcmgray / quimb

A python library for quantum information and many-body calculations including tensor networks.
http://quimb.readthedocs.io
Other
455 stars 107 forks source link

Drawing of MPO #122

Closed shadibeh closed 2 years ago

shadibeh commented 2 years ago

What is your issue?

Hi everyone! I used the following code to draw MPO:

import quimb as qu
import quimb.tensor as qtn
N = 10
U = qu.gen.rand.rand_uni(2)
#Reshape U into tensor [1,1,2,2]
U_T = np.zeros([1, 1, 2, 2], dtype=complex)
U_T[0, 0, 0, 0] = U[0][0]
U_T[0, 0, 1, 0] = U[1][0]
U_T[0, 0, 0, 1] = U[0][1]
U_T[0, 0, 1, 1] = U[1][1]
#build MPO
U_MPO = qtn.MatrixProductOperator([U_T ] * 10, shape='lrud')
U_MPO.draw()

It led to the following figure: Unknown

I expected to have 10 sites, each one with two legs. However, one site has just one leg.

The version of my quimb is:1.3.0+395.gc34bb13

jcmgray commented 2 years ago

Hi, I think the automatic layout has just made the two indices on tensor 7 overlap! There are some options for customizing the layout here https://quimb.readthedocs.io/en/latest/tensor-drawing.html#Positioning-tensors.

shadibeh commented 2 years ago

Thanks a lot for the link. That solved the issue.