Exemplo n.º 1
0
def iso_contract(T, isoT):
    """ applying isometry and its transpose on tensor T, shrinkage T's dimension"""
    iso_net = uni10.Network('isometry.net')
    res = uni10.UniTensorR(T)
    isoT = uni10.UniTensorR(isoT)
    T_trans = uni10.UniTensorR(np.transpose(isoT.GetBlock()))
    iso_net.PutTensor(0, T)
    iso_net.PutTensor(1, isoT)
    iso_net.PutTensor(2, T_trans)
    iso_net.Launch(res)
    return res
Exemplo n.º 2
0
def matD():
    """create delta tensor"""
    mat = np.zeros(16)
    mat[0] = mat[15] = 1
    bdout = uni10.Bond(uni10.BD_OUT, 2)
    T = uni10.UniTensorR([bdout, bdout, bdout, bdout])
    T.SetElem(mat)
    return T
Exemplo n.º 3
0
def CG_contraction(A, B):
    net = uni10.Network("CG_contract.net")
    result = uni10.UniTensorR(A)
    net.PutTensor(0, A)
    net.PutTensor(1, B)
    net.Launch(result)
    result = result.CombineBond([2, -2])
    result = result.CombineBond([4, -4])
    return result
Exemplo n.º 4
0
def merge(delta, m, mt):
    """ initially the tensors are different, so I decide to merge M/MT into delta tensor such that
    the tensors are the same, therefore we only need to consider 1 tensor when doing TRG"""
    network = uni10.Network("merge_bond.net")
    result = uni10.UniTensorR(delta)
    network.PutTensor('D', delta)
    network.PutTensor("M", m)
    network.PutTensor("MT", mt)
    network.Launch(result)
    return result
Exemplo n.º 5
0
def tTrace(Ta, Tb, Tc, Td):
    """ return the tensor trace result"""
    net = uni10.Network("trace.net")
    res = uni10.UniTensorR(Ta)
    net.PutTensor(0, Ta)
    net.PutTensor(1, Tb)
    net.PutTensor(2, Tc)
    net.PutTensor(3, Td)
    net.Launch(res)
    scalar = res.GetBlock()[0]
    return scalar
Exemplo n.º 6
0
def update(T, chi):
    T2 = CG_contraction(T, T)
    copy = uni10.UniTensorR(T2)
    copy.SetLabel([3, 4, 1, -2])
    X = uni10.Contract(T2, copy)
    U, norm = svd(
        X.GetBlock(),
        chi)  # use SVD to truncate the tensor with bond dimension chi
    result = iso_contract(T2, U)
    norm = np.max(result.GetBlock()) / 2
    result = uni10.Permute(result, [2, 1, 4, 3], 2)
    return result * (1 / norm)
Exemplo n.º 7
0
def matMT(beta):
    mat = matM(beta).GetBlock()
    T = uni10.UniTensorR(np.transpose(mat))
    return T
Exemplo n.º 8
0
def matM(beta):
    mat = np.array([[np.cosh(beta)**(1 / 2),
                     np.sinh(beta)**(1 / 2)],
                    [np.cosh(beta)**(1 / 2), -1 * np.sinh(beta)**(1 / 2)]])
    T = uni10.UniTensorR(mat)
    return T