예제 #1
0
 def from_matrices(cls, Bs, Svs=None, norm=1.0):
     sites = []
     bss = []
     Bs[0] = Bs[0] * norm
     for b in Bs:
         b = np.array(b)
         bss.append(b.transpose([2, 0, 1]))  #for some stupid reason
         sites.append(Site(LegCharge.from_trivial(b.shape[2])))
     return SimpleMPS(
         tenpy.networks.mps.MPS.from_Bflat(sites, bss, Svs, form=None))
예제 #2
0
def random_MPS(L, d, chimax, func=randmat.standard_normal_complex, bc='finite', form='B'):
    site = Site(charges.LegCharge.from_trivial(d))
    chi = [chimax] * (L + 1)
    if bc == 'finite':
        for i in range(L // 2 + 1):
            chi[i] = chi[L - i] = min(chi[i], d**i)
    Bs = []
    for i in range(L):
        Bs.append(func((d, chi[i], chi[i + 1])))
    dtype = np.common_type(*Bs)
    psi = MPS.from_Bflat([site] * L, Bs, bc=bc, dtype=dtype, form=None)
    if form is not None:
        psi.canonical_form()
        psi.convert_form(form)
    return psi
예제 #3
0
 def from_matrices(cls, Ws):
     sites = []
     wss = []
     for w in Ws:
         assert w.shape[2] == w.shape[
             3]  # For now only square MPO's are possible
         sites.append(Site(LegCharge.from_trivial(w.shape[2])))
         leg_i = LegCharge.from_trivial(w.shape[0])
         leg_o = LegCharge.from_trivial(w.shape[1])
         leg_p = LegCharge.from_trivial(w.shape[2])
         Wn = npc.Array.from_ndarray(
             w, [leg_i, leg_o.conj(), leg_p,
                 leg_p.conj()],
             labels=["wL", "wR", "p", "p*"])
         wss.append(Wn)
     return SimpleMPO(tenpy.networks.mpo.MPO(sites, wss))