## How to get the data of NPC arrays

How do I use this algorithm? What does that parameter do?
Qottmann
Posts: 13
Joined: 27 Mar 2019, 09:11
Location: ICFO Barcelona

### How to get the data of NPC arrays

Hello again,

I sometimes want to look at the actual data of the tensors in an MPS or MPO network, but I am a bit puzzled by the ._data attribute. For example, I want the W tensor of a Bose Hubbard model w/o conservation. I create the model

Code: Select all

model_params = dict(
filling = 1.,
n_max = 4,
t = 1,
U = 1,
mu = 1,
L=100,
bc_MPS='finite',
conserve = None,
verbose=0)
M = BoseHubbardChain(model_params)
and then get the W at, say, site 50:

Code: Select all

M.calc_H_MPO().get_W(50)
>>> <npc.Array shape=(4, 4, 5, 5) charge=ChargeInfo([], []) labels=['wL', 'wR', 'p', 'p*']>
Now the way I understand it is that if I want the actual entries of this npc.Array instance I get the attribute ._data, but

Code: Select all

M.calc_H_MPO().get_W(50)._data
outputs a list with 7 (1,1,5,5) arrays, so clearly not all the data from the (4,4,5,5) tensor. What am I missing here?

The same question goes for MPS tensors.
As always all the help is much appreciated!
Best regards,
Korbinian

Johannes
The _data attribute of an tenpy.linalg.np_conserved.Array is a list with individual blocks of the tensor. Even without charges, there can be subblocks defined. this is the case for an MPO to exploit the sparseness of an MPO - if you write the Matrix, there are usually lot's of zeros, e.g. in your case only 7 of the 5x5=25 entries are nonzero.
For example W = M.H_MPO.get_W(50).to_ndarray() gives you the desired Array of shape (4,4,5,5).