def test_canonical_flip(self): mpiprint( 0, '\n' + '=' * 50 + '\nCanonical Peps Flipping test\n' + '-' * 50) from cyclopeps.tools.peps_tools import PEPS Nx = 5 Ny = 5 d = 2 D = 3 chi = 10 peps = PEPS(Nx=Nx, Ny=Ny, d=d, D=D, chi=chi, normalize=False, canonical=True) norm0 = peps.calc_norm() peps.flip() norm1 = peps.calc_norm() peps.flip() norm2 = peps.calc_norm() mpiprint(0, 'Norms = {},{},{}'.format(norm0, norm1, norm2)) self.assertTrue(abs((norm0 - norm1) / norm0) < 1e-3) self.assertTrue(abs((norm0 - norm2) / norm0) < 1e-10) mpiprint(0, 'Passed\n' + '=' * 50)
def test_flip_Z2_ctf(self): mpiprint( 0, '\n' + '=' * 50 + '\nPeps Z2 Flipping test (ctf)\n' + '-' * 50) from cyclopeps.tools.peps_tools import PEPS Nx = 5 Ny = 5 d = 2 D = 6 Zn = 2 chi = 10 backend = 'ctf' # Generate random PEPS peps = PEPS(Nx=Nx, Ny=Ny, d=d, D=D, chi=chi, Zn=Zn, backend=backend, normalize=False) # Compute the norm (2 ways for comparison) norm0 = peps.calc_norm(chi=chi) peps_sparse = peps.make_sparse() norm1 = peps_sparse.calc_norm(chi=chi) mpiprint(0, 'Symmetric Dense Norm = {}'.format(norm0)) mpiprint(0, 'Symmetric Sparse Norm = {}'.format(norm1)) # Rotate the PEPS peps.flip() norm2 = peps.calc_norm(chi=chi) peps_sparse = peps.make_sparse() norm3 = peps_sparse.calc_norm(chi=chi) mpiprint(0, 'Flipped Symmetric Dense Norm = {}'.format(norm2)) mpiprint(0, 'Flipped Symmetric Sparse Norm = {}'.format(norm3)) self.assertTrue(abs((norm0 - norm1) / norm1) < 1e-3) self.assertTrue(abs((norm0 - norm2) / norm2) < 1e-3) self.assertTrue(abs((norm0 - norm3) / norm3) < 1e-3) mpiprint(0, 'Passed\n' + '=' * 50)