Example #1
0
 def test_normalization_Z3(self):
     from cyclopeps.tools.peps_tools import PEPS
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps (5x5) Normalization test with Z3 Symmetry\n' + '-' * 50)
     Nx = 5
     Ny = 5
     d = 2
     D = 6
     chi = 50
     Zn = 3  # Zn symmetry (here, Z3)
     dZn = 2
     backend = 'ctf'
     # Generate random PEPS
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=chi,
                 Zn=Zn,
                 dZn=dZn,
                 backend=backend,
                 normalize=False)
     # Compute the norm (2 ways for comparison)
     peps_sparse = peps.make_sparse()
     norm0 = peps.calc_norm(chi=chi)
     norm1 = peps_sparse.calc_norm(chi=chi)
     mpiprint(0, 'Symmetric Sparse Norm = {}'.format(norm1))
     mpiprint(0, 'Symmetric Dense Norm = {}'.format(norm0))
     self.assertTrue(abs((norm0 - norm1) / norm1) < 1e-3)
     mpiprint(0, 'Passed\n' + '=' * 50)
Example #2
0
 def test_normalization_Z2_ctf(self):
     from cyclopeps.tools.peps_tools import PEPS
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps (5x5) Normalization test with Z2 Symmetry (ctf)\n' +
         '-' * 50)
     Nx = 5
     Ny = 5
     d = 2
     D = 6
     chi = 10
     Zn = 2  # Zn symmetry (here, Z2)
     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))
     # Normalize the PEPS
     norm2 = peps.normalize()
     peps_sparse = peps.make_sparse()
     norm3 = peps_sparse.calc_norm(chi=chi)
     mpiprint(0,
              'Symmetric Dense Norm (After normalized) = {}'.format(norm2))
     mpiprint(0,
              'Symmetric Sparse Norm (After normalized) = {}'.format(norm3))
     # Do some assertions to check if passed
     self.assertTrue(abs((norm0 - norm1) / norm1) < 1e-3)
     self.assertTrue(abs(1.0 - norm2) < 1e-3)
     self.assertTrue(abs(1.0 - norm3) < 1e-3)
     mpiprint(0, 'Passed\n' + '=' * 50)
Example #3
0
 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)
Example #4
0
# Get inputs
Ny = int(argv[1])
Nx = int(argv[2])
d = 2
D = int(argv[3])
chi = int(argv[4])
Zn = int(argv[5])
backend = 'numpy'

# Create a random pep
peps = PEPS(Nx=Nx,
            Ny=Ny,
            d=d,
            D=D,
            chi=chi,
            Zn=Zn,
            backend=backend,
            normalize=False)

# contract the norm
fname = argv[6] + '_norm_stats_Nx' + str(Nx) + '_Ny' + str(Ny) + '_d' + str(
    d) + '_D' + str(D) + '_chi' + str(chi)
t0 = time.time()
cProfile.run('norm = peps.calc_norm(chi=chi)', fname + '_symtensor')
tf = time.time()
print('Symtensor Contraction Time = {}'.format(tf - t0))
peps_sparse = peps.make_sparse()
t0 = time.time()
cProfile.run('norm1 = peps_sparse.calc_norm(chi=chi)', fname + '_slow')
print('Slow Contraction Time = {}'.format(tf - t0))