def test_ascending_descending(chi, dtype): """ test if ascending and descending operations are doing the right thing """ wC, uC, rho_0 = bml.initialize_binary_MERA_random(phys_dim=2, chi=chi, dtype=dtype) wC, uC = bml.unlock_layer(wC, uC) #add a transitional layer wC, uC = bml.unlock_layer(wC, uC) #add a transitional layer ham_0 = bml.initialize_TFI_hams(dtype) rho = [0 for n in range(len(wC) + 1)] ham = [0 for n in range(len(wC) + 1)] rho[-1] = bml.steady_state_density_matrix(10, rho_0, wC[-1], uC[-1]) ham[0] = ham_0 for p in range(len(rho) - 2, -1, -1): rho[p] = bml.descending_super_operator(rho[p + 1], wC[p], uC[p]) for p in range(len(wC)): ham[p + 1] = bml.ascending_super_operator(ham[p], wC[p], uC[p]) energies = [ tn.ncon([rho[p], ham[p]], [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]) for p in range(len(rho)) ] np.testing.assert_allclose( np.array( [energies[p] / energies[p + 1] for p in range(len(energies) - 1)]), 0.5)
def test_padding(chi, dtype): wC, uC, rho_0 = bml.initialize_binary_MERA_random(phys_dim=2, chi=chi, dtype=dtype) wC, uC = bml.unlock_layer(wC, uC) #add a transitional layer wC, uC = bml.unlock_layer(wC, uC) #add a transitional layer ham_0 = bml.initialize_TFI_hams(dtype) def get_energies(wC, uC, rho_0, ham_0): rho = [0 for n in range(len(wC) + 1)] ham = [0 for n in range(len(wC) + 1)] rho[-1] = bml.steady_state_density_matrix(10, rho_0, wC[-1], uC[-1]) ham[0] = ham_0 for p in range(len(rho) - 2, -1, -1): rho[p] = bml.descending_super_operator(rho[p + 1], wC[p], uC[p]) for p in range(len(wC)): ham[p + 1] = bml.ascending_super_operator(ham[p], wC[p], uC[p]) energies = [ tn.ncon([rho[p], ham[p]], [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]) for p in range(len(rho)) ] return energies energies_1 = get_energies(wC, uC, rho_0, ham_0) chi_new = chi + 1 wC, uC = bml.pad_mera_tensors(chi_new, wC, uC) rho_0 = misc_mera.pad_tensor(rho_0, [chi_new] * 6) energies_2 = get_energies(wC, uC, rho_0, ham_0) np.testing.assert_allclose(energies_1, energies_2)