grid_outer¶
full name: tenpy.linalg.np_conserved.grid_outer
parent module:
tenpy.linalg.np_conservedtype: function
-
tenpy.linalg.np_conserved.grid_outer(grid, grid_legs, qtotal=None)[source]¶ Given an np.array of npc.Arrays, return the corresponding higher-dimensional Array.
- Parameters
- gridarray_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 charge-data, giving the remaining axes.
Noneentries in the grid are interpreted as zeros.- grid_legslist of
LegCharge One LegCharge for each dimension of the grid along the grid.
- qtotalcharge
The total charge of the Array. By default (
None), derive it out from a non-trivial entry of the grid.
- gridarray_like of {
- Returns
- res
Array An Array with shape
grid.shape + nontrivial_grid_entry.shape. Constructed such thatres[idx] == grid[idx]for any indexidxof the grid the grid entry is not trivial (None).
- res
See also
detect_grid_outer_legchargecan calculate one missing
LegChargeof the grid.
Examples
A typical use-case for this function is the generation of an MPO. Say you have npc.Arrays
Splus, Sminus, Sz, 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:>>> Id = np.eye_like(Sz) >>> W_mpo = grid_outer([[Id, Splus, Sminus, Sz, None], ... [None, None, None, None, J*Sminus], ... [None, None, None, None, J*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)