Beispiel #1
0
 def update_bond(self, i):
     j = (i + 1) % self.psi.L
     # get effective Hamiltonian
     Heff = SimpleHeff(self.LPs[i], self.RPs[j], self.H_mpo[i],
                       self.H_mpo[j])
     # Diagonalize Heff, find ground state `theta`
     theta0 = np.reshape(self.psi.get_theta2(i),
                         [Heff.shape[0]])  # initial guess
     e, v = arp.eigsh(Heff,
                      k=1,
                      which='SA',
                      return_eigenvectors=True,
                      v0=theta0)
     theta = np.reshape(v[:, 0], Heff.theta_shape)
     # split and truncate
     Ai, Sj, Bj = split_truncate_theta(theta, self.chi_max, self.eps)
     # put back into MPS
     Gi = np.tensordot(np.diag(self.psi.Ss[i]**(-1)), Ai,
                       axes=[1, 0])  # vL [vL*], [vL] i vC
     self.psi.Bs[i] = np.tensordot(Gi, np.diag(Sj),
                                   axes=[2, 0])  # vL i [vC], [vC*] vC
     self.psi.Ss[j] = Sj  # vC
     self.psi.Bs[j] = Bj  # vC j vR
     self.update_LP(i)
     self.update_RP(j)
def run_infinite_TEBD(psi, U_bonds, N_steps, chi_max, eps=1.e-10):
    """basically the same as c_tebd.run_TEBD, but adjusted to work for infinite (uniform) MPS.
    (should work regardless of whether you did exercise 10.1)"""
    Nbonds = L = 2
    for n in range(N_steps):
        for k in [0, 1]:  # even, odd
            for i_bond in range(k, Nbonds, 2):
                U_bond = U_bonds[i_bond]
                i, j = i_bond, (i_bond + 1) % L
                theta = psi.get_theta1(i)
                theta = np.tensordot(theta, psi.Bs[j],
                                     [2, 0])  # vL i [vR], [vL] j vR
                Utheta = np.tensordot(
                    U_bond, theta,
                    axes=([2, 3], [1, 2]))  # i j [i*] [j*], vL [i] [j] vR
                Utheta = np.transpose(Utheta, [2, 0, 1, 3])  # vL i j vR
                # split and truncate
                Ai, Sj, Bj = split_truncate_theta(Utheta, chi_max, eps)
                # put back into MPS
                Gi = np.tensordot(np.diag(psi.Ss[i]**(-1)), Ai,
                                  axes=[1, 0])  # vL [vL*], [vL] i vC
                psi.Bs[i] = np.tensordot(Gi, np.diag(Sj),
                                         axes=[2, 0])  # vL i [vC], [vC] vC
                psi.Ss[j] = Sj  # vC
                psi.Bs[j] = Bj  # vC j vR
Beispiel #3
0
def update_bond(psi, i, U_bond, chi_max, eps):
    """Apply `U_bond` acting on i,j=(i+1) to `psi`."""
    j = (i + 1) % psi.L
    # construct theta matrix
    theta = psi.get_theta2(i)  # vL i j vR
    # apply U
    Utheta = np.tensordot(U_bond, theta, axes=([2, 3], [1, 2]))  # i j [i*] [j*], vL [i] [j] vR
    Utheta = np.transpose(Utheta, [2, 0, 1, 3])  # vL i j vR
    # split and truncate
    Ai, Sj, Bj = split_truncate_theta(Utheta, chi_max, eps)
    # put back into MPS
    Gi = np.tensordot(np.diag(psi.Ss[i]**(-1)), Ai, axes=[1, 0])  # vL [vL*], [vL] i vC
    psi.Bs[i] = np.tensordot(Gi, np.diag(Sj), axes=[2, 0])  # vL i [vC], [vC] vC
    psi.Ss[j] = Sj  # vC
    psi.Bs[j] = Bj  # vC j vR
 def update_bond(self, i):
     j = i + 1
     # get effective Hamiltonian
     Heff = HEffective(self.LPs[i], self.RPs[j], self.H_mpo[i], self.H_mpo[j])
     # Diagonalize Heff, find ground state `theta`
     theta0 = np.reshape(self.psi.get_theta2(i), [Heff.shape[0]])  # initial guess
     e, v = arp.eigsh(Heff, k=1, which='SA', return_eigenvectors=True, v0=theta0)
     theta = np.reshape(v[:, 0], Heff.theta_shape)
     # split and truncate
     Ai, Sj, Bj = split_truncate_theta(theta, self.chi_max, self.eps)
     # put back into MPS
     Gi = np.tensordot(np.diag(self.psi.Ss[i]**(-1)), Ai, axes=[1, 0])  # vL [vL*], [vL] i vC
     self.psi.Bs[i] = np.tensordot(Gi, np.diag(Sj), axes=[2, 0])  # vL i [vC], [vC*] vC
     self.psi.Ss[j] = Sj  # vC
     self.psi.Bs[j] = Bj  # vC j vR
     self.update_LP(i)
     self.update_RP(j)
def run_infinite_TEBD(psi, U_bonds, N_steps, chi_max, eps=1.e-10):
    """basically the same as c_tebd.run_TEBD, but adjusted to work for infinite (uniform) MPS.
    (should work regardless of whether you did exercise 10.1)"""
    Nbonds = L = 2
    for n in range(N_steps):
        for k in [0, 1]:  # even, odd
            for i_bond in range(k, Nbonds, 2):
                U_bond = U_bonds[i_bond]
                i, j = i_bond, (i_bond + 1) % L
                theta = psi.get_theta1(i)
                theta = np.tensordot(theta, psi.Bs[j], [2, 0])  # vL i [vR], [vL] j vR
                Utheta = np.tensordot(U_bond, theta, axes=([2, 3], [1, 2]))  # i j [i*] [j*], vL [i] [j] vR
                Utheta = np.transpose(Utheta, [2, 0, 1, 3])  # vL i j vR
                # split and truncate
                Ai, Sj, Bj = split_truncate_theta(Utheta, chi_max, eps)
                # put back into MPS
                Gi = np.tensordot(np.diag(psi.Ss[i]**(-1)), Ai, axes=[1, 0])  # vL [vL*], [vL] i vC
                psi.Bs[i] = np.tensordot(Gi, np.diag(Sj), axes=[2, 0])  # vL i [vC], [vC] vC
                psi.Ss[j] = Sj  # vC
                psi.Bs[j] = Bj  # vC j vR