grid_outer¶
full name: tenpy.linalg.np_conserved.grid_outer
parent module:
tenpy.linalg.np_conserved
type: function

tenpy.linalg.np_conserved.
grid_outer
(grid, grid_legs, qtotal=None, grid_labels=None)[source]¶ Given an np.array of npc.Arrays, return the corresponding higherdimensional Array.
 Parameters
grid (array_like of {
Array
 None}) – The grid gives the first part of the axes of the resulting array. Entries have to have all the same shape and chargedata, giving the remaining axes.None
entries in the grid are interpreted as zeros.grid_legs (list of
LegCharge
) – One LegCharge for each dimension of the grid along the grid.qtotal (charge) – The total charge of the Array. By default (
None
), derive it out from a nontrivial entry of the grid.grid_labels (list of {str  None}) – One label associated to each of the grid axes.
None
for nonnamed labels.
 Returns
res – An Array with shape
grid.shape + nontrivial_grid_entry.shape
. Constructed such thatres[idx] == grid[idx]
for any indexidx
of the grid the grid entry is not trivial (None
). Return type
See also
detect_grid_outer_legcharge()
can calculate one missing
LegCharge
of the grid.
Examples
A typical usecase for this function is the generation of an MPO. Say you have npc.Arrays
Splus, Sminus, Sz, Id
, each with legs[phys.conj(), phys]
. Further, you have to define appropriate LegCharges l_left and l_right. Then one ‘matrix’ of the MPO for a nearest neighbour Heisenberg Hamiltonian could look like:>>> W_mpo = grid_outer([[Id, Splus, Sminus, Sz, None], ... [None, None, None, None, J*0.5*Sminus], ... [None, None, None, None, J*0.5*Splus], ... [None, None, None, None, J*Sz], ... [None, None, None, None, Id]], ... leg_charges=[l_left, l_right]) >>> W_mpo.shape (5, 5, 2, 2)