I know the explicit form of the bulk tensors and edge vectors, \(M_{ij}^{[m_1 m_2]}, \, l_{i}^{[m_1 m_2]}, r_{i}^{[m_1 m_2]}\).
For example, for a bulk tensor, I have a \(\chi\) by \(\chi\) by \(d\) by \(d\) numpy array filled with floats, where \(\chi\) is the bond dimension and \(d\) is the physical dimension.
In reading the documentation for tenpy.networks.mpo, it looks like I can initialize MPOs with tenpy.networks.mpo.MPO, but this appears to require a different format than numpy arrays. How can I turn my numpy arrays into the \(W\) tensors that TeNPy accepts? Thank you for the help!
*****************************************************
To make this more concrete, here's an example of a case with \(\chi = d= 2\).
Code: Select all
import numpy as np
import tenpy
import tenpy.linalg.np_conserved as npc
from tenpy.algorithms import dmrg
from tenpy.networks.mps import MPS
from tenpy.networks.mpo import MPO
tenpy.tools.misc.setup_logging(to_stdout="INFO")
from tenpy.networks.site import SpinSite
from tenpy.models.lattice import Chain
from tenpy.models.model import CouplingModel, NearestNeighborModel, MPOModel
N=6 #number of sites
t = 1/2 #tanh(beta)
t_arr = np.array([t**2,0,0,t, 0,t,t,0, 0,t,t,0, t,0,0,1])
t_arr = t_arr.reshape((2,2,2,2)) #bulk tensor
edge_arr = np.array([0,t,t,0, t,0,0,1])
edge_arr_left = edge_arr.reshape((1,2,2,2)) #left tensor
edge_arr_right = edge_arr.reshape((2,1,2,2)) #right tensor
### need to fix up the above tensors
Ws = [edge_arr_left] + (N-2)*[t_arr] + [edge_arr_right]
spin = SpinSite(conserve='None')
H = MPO([spin] * N, Ws, bc='finite', IdL=0, IdR=-1)