Пример #1
0
 def test_energy_contraction_ones_z2(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps Energy (Ham=Identity, peps=ones, Z2 symmetry) calculation\n'
         + '-' * 50)
     # Create a PEPS
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 2
     Ny = 2
     d = 2
     D = 3
     Zn = 2
     backend = 'numpy'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=1000,
                 Zn=2,
                 backend=backend,
                 normalize=False)
     # Set all tensor values to 1
     for xind in range(Nx):
         for yind in range(Ny):
             peps[xind][yind].fill_all(1.)
     # Get the Hamiltonian
     from cyclopeps.ops.identity import return_op
     ham = return_op(Nx, Ny, sym='Z2', backend=backend)
     # Calculate initial norm
     norm0 = peps.calc_norm() * 4.
     mpiprint(0, 'Norm (routine) = {}'.format(norm0))
     # Perform the Exact energy calculation:
     bra = einsum('LDWCM,lMXcu->LDluWXCc', peps[0][0],
                  peps[0][1]).remove_empty_ind(0).remove_empty_ind(
                      0).remove_empty_ind(0).remove_empty_ind(0)
     bra = einsum('WXCc,CdYRm->dRWXYcm', bra,
                  peps[1][0]).remove_empty_ind(0).remove_empty_ind(0)
     bra = einsum('WXYcm,cmZru->ruWXYZ', bra,
                  peps[1][1]).remove_empty_ind(0).remove_empty_ind(0)
     norm1 = einsum('WXYZ,WXYZ->', bra, bra.conj())
     norm1 = norm1 * 4.
     mpiprint(0, 'Norm (explicit) = {}'.format(norm1))
     tmp = einsum('WXYZ,wxYZ->WXwx', bra, bra.conj())
     E1 = einsum('WXwx,WXwx->', tmp, ham[0][0][0])
     tmp = einsum('WXYZ,wXyZ->WYwy', bra, bra.conj())
     E1 += einsum('WYwy,WYwy->', tmp, ham[1][0][0])
     tmp = einsum('WXYZ,WXyz->YZyz', bra, bra.conj())
     E1 += einsum('YZyz,YZyz->', tmp, ham[0][1][0])
     tmp = einsum('WXYZ,WxYz->XZxz', bra, bra.conj())
     E1 += einsum('XZxz,XZxz->', tmp, ham[1][1][0])
     mpiprint(0,
              'Explicitly computed energy (not normalized) = {}'.format(E1))
     # Contract Energy again
     E2 = peps.calc_op(ham, normalize=False)
     mpiprint(0, 'Energy via peps Method (not normalized) = {}'.format(E2))
     self.assertTrue(abs((norm0 - norm1) / norm0) < 1e-10)
     print('Check here {}, {}, {}, {}'.format(norm0, norm1, E1, E2))
     self.assertTrue(abs((norm0 - E1) / norm0) < 1e-10)
     self.assertTrue(abs((norm0 - E2) / norm0) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #2
0
 def test_canonical_normalization_z2(self):
     from cyclopeps.tools.peps_tools import PEPS
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nCanonical Peps Normalization test (Z2 Symmetry) \n' + '-' * 50)
     Nx = 3
     Ny = 5
     d = 2
     D = 3
     chi = 10
     Zn = 2
     backend = 'numpy'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=chi,
                 Zn=Zn,
                 backend=backend,
                 normalize=False,
                 canonical=True)
     norm = peps.calc_norm(chi=chi)
     norm = peps.normalize()
     mpiprint(0, 'Norm = {}'.format(norm))
     self.assertTrue(abs(1.0 - norm) < 1e-3)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #3
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)
Пример #4
0
 def test_normalization_ctf(self):
     from cyclopeps.tools.peps_tools import PEPS
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps (5x5) Normalization test without Symmetry (ctf)\n' +
         '-' * 50)
     Nx = 5
     Ny = 5
     d = 2
     D = 6
     chi = 10
     Zn = None
     backend = 'ctf'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=chi,
                 Zn=Zn,
                 backend=backend,
                 normalize=True)
     norm = peps.calc_norm(chi=chi)
     mpiprint(0, 'Norm = {}'.format(norm))
     self.assertTrue(abs(1.0 - norm) < 1e-3)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #5
0
 def test_energy_contraction_heis_z2(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps Energy (Ham=Heisenberg, peps=random, Z2 symmetry) calculation\n'
         + '-' * 50)
     # Create a PEPS
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 2
     Ny = 2
     d = 2
     D = 3
     Zn = 2
     backend = 'ctf'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=1000,
                 Zn=2,
                 backend=backend,
                 normalize=False)
     # Get the Hamiltonian
     from cyclopeps.ops.heis import return_op
     ham = return_op(Nx, Ny, sym='Z2', backend=backend)
     # Calculate initial norm
     norm0 = peps.calc_norm()
     mpiprint(0, 'Norm (routine) = {}'.format(norm0))
     # Perform the Exact energy calculation:
     bra = einsum('LDWCM,lMXcu->LDluWXCc', peps[0][0],
                  peps[0][1]).remove_empty_ind(0).remove_empty_ind(
                      0).remove_empty_ind(0).remove_empty_ind(0)
     bra = einsum('WXCc,CdYRm->dRWXYcm', bra,
                  peps[1][0]).remove_empty_ind(0).remove_empty_ind(0)
     bra = einsum('WXYcm,cmZru->ruWXYZ', bra,
                  peps[1][1]).remove_empty_ind(0).remove_empty_ind(0)
     norm1 = einsum('WXYZ,WXYZ->', bra, bra.conj())
     norm1 = norm1
     mpiprint(0, 'Norm (explicit) = {}'.format(norm1))
     #print(ham[0][0][0])
     tmp = einsum('WXYZ,wxYZ->WXwx', bra, bra.conj())
     E1 = einsum('WXwx,WXwx->', tmp, ham[0][0][0])
     tmp = einsum('WXYZ,wXyZ->WYwy', bra, bra.conj())
     E1 += einsum('WYwy,WYwy->', tmp, ham[1][0][0])
     tmp = einsum('WXYZ,WXyz->YZyz', bra, bra.conj())
     E1 += einsum('YZyz,YZyz->', tmp, ham[0][1][0])
     tmp = einsum('WXYZ,WxYz->XZxz', bra, bra.conj())
     E1 += einsum('XZxz,XZxz->', tmp, ham[1][1][0])
     E1 = E1
     mpiprint(0,
              'Explicitly computed energy (not normalized) = {}'.format(E1))
     # Contract Energy again
     E2 = peps.calc_op(ham, normalize=False)
     mpiprint(0, 'Energy via peps Method (not normalized) = {}'.format(E2))
     self.assertTrue(abs((norm0 - norm1) / norm0) < 1e-10)
     self.assertTrue(abs((E2 - E1) / E1) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #6
0
 def test_rotate_ctf(self):
     mpiprint(0,
              '\n' + '=' * 50 + '\nPeps Rotation test (ctf)\n' + '-' * 50)
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 3
     Ny = 3
     d = 2
     D = 3
     chi = 100
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=chi,
                 normalize=False,
                 backend='ctf')
     norm0 = peps.calc_norm()
     peps.rotate()
     norm1 = peps.calc_norm()
     peps.rotate(clockwise=False)
     norm2 = peps.calc_norm()
     mpiprint(0, 'Norms = {},{},{}'.format(norm0, norm1, norm2))
     self.assertTrue(abs((norm0 - norm1) / norm0) < 1e-5)
     self.assertTrue(abs((norm0 - norm2) / norm0) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #7
0
 def test_canonical_rotate_z2(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nCanonical Peps Rotation test (Z2 Symmetry)\n' + '-' * 50)
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 3
     Ny = 3
     d = 2
     D = 3
     chi = 10
     Zn = 2
     backend = 'numpy'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=chi,
                 Zn=Zn,
                 backend=backend,
                 normalize=False,
                 canonical=True)
     norm0 = peps.calc_norm()
     peps.rotate()
     norm1 = peps.calc_norm()
     peps.rotate(clockwise=False)
     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)
Пример #8
0
 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)
Пример #9
0
 def test_energy_itf_contraction_ones(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps Energy (Ham=ITF, peps=ones, no symmetry) calculation\n' +
         '-' * 50)
     # Create a PEPS
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 2
     Ny = 2
     d = 2
     D = 3
     backend = 'ctf'
     peps = PEPS(Nx=Nx,
                 Ny=Ny,
                 d=d,
                 D=D,
                 chi=1000,
                 normalize=False,
                 backend=backend)
     # Set all tensor values to 1
     for xind in range(Nx):
         for yind in range(Ny):
             peps[xind][yind].fill_all(1.)
     # Get the Hamiltonian
     from cyclopeps.ops.itf import return_op
     ham = return_op(Nx, Ny, (1., 2.), backend=backend)
     # Calculate initial norm
     norm0 = peps.calc_norm()
     mpiprint(0, 'Norm = {}'.format(norm0))
     # Perform the Exact energy calculation:
     bra = einsum('LDWCM,lMXcu->WXCc', peps[0][0], peps[0][1])
     bra = einsum('WXCc,CdYRm->WXYcm', bra, peps[1][0])
     bra = einsum('WXYcm,cmZru->WXYZ', bra, peps[1][1])
     norm1 = einsum('WXYZ,WXYZ->', bra, bra.conj())
     mpiprint(0, 'Explicitly computed norm = {}'.format(norm1))
     tmp = einsum('WXYZ,wxYZ->WXwx', bra, bra.conj())
     E1 = einsum('WXwx,WXwx->', tmp, ham[0][0][0])
     tmp = einsum('WXYZ,wXyZ->WYwy', bra, bra.conj())
     E1 += einsum('WYwy,WYwy->', tmp, ham[1][0][0])
     tmp = einsum('WXYZ,WXyz->YZyz', bra, bra.conj())
     E1 += einsum('YZyz,YZyz->', tmp, ham[0][1][0])
     tmp = einsum('WXYZ,WxYz->XZxz', bra, bra.conj())
     E1 += einsum('XZxz,XZxz->', tmp, ham[1][1][0])
     mpiprint(0,
              'Explicitly computed energy (not normalized) = {}'.format(E1))
     # Contract Energy again
     E2 = peps.calc_op(ham, normalize=False)
     mpiprint(0, 'Energy (routine) = {}'.format(E2))
     self.assertTrue(abs((E2 - E1) / E1) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #10
0
 def test_energy_contraction(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps Energy (Ham=Identity, peps=random, no symmetry) calculation\n'
         + '-' * 50)
     # Create a PEPS
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 2
     Ny = 2
     d = 2
     D = 3
     backend = 'ctf'
     peps = PEPS(Nx=Nx, Ny=Ny, d=d, D=D, chi=1000, backend=backend)
     # Get the Hamiltonian
     from cyclopeps.ops.identity import return_op
     ham = return_op(Nx, Ny, backend=backend)
     # Calculate initial norm
     norm0 = peps.calc_norm() * 4.
     # Perform the Exact energy calculation:
     bra = einsum('LDWCM,lMXcu->WXCc', peps[0][0], peps[0][1])
     bra = einsum('WXCc,CdYRm->WXYcm', bra, peps[1][0])
     bra = einsum('WXYcm,cmZru->WXYZ', bra, peps[1][1])
     norm1 = einsum('WXYZ,WXYZ->', bra, bra.conj()) * 4.
     tmp = einsum('WXYZ,wxYZ->WXwx', bra, bra.conj())
     E1 = einsum('WXwx,WXwx->', tmp, ham[0][0][0])
     tmp = einsum('WXYZ,wXyZ->WYwy', bra, bra.conj())
     E1 += einsum('WYwy,WYwy->', tmp, ham[1][0][0])
     tmp = einsum('WXYZ,WXyz->YZyz', bra, bra.conj())
     E1 += einsum('YZyz,YZyz->', tmp, ham[0][1][0])
     tmp = einsum('WXYZ,WxYz->XZxz', bra, bra.conj())
     E1 += einsum('XZxz,XZxz->', tmp, ham[1][1][0])
     # Contract Energy again
     E2 = peps.calc_op(ham, normalize=False)
     self.assertTrue(abs((norm0 - norm1) / norm0) < 1e-10)
     mpiprint(0, 'Passed Norm1')
     self.assertTrue(abs((norm0 - E1) / norm0) < 1e-10)
     mpiprint(0, 'Passed E1')
     mpiprint(0, 'Norm from calc_norm = {}'.format(norm0))
     mpiprint(0, 'Norm from exact contraction {}'.format(norm1))
     mpiprint(0, 'Norm from Energy calc op = {}'.format(E2))
     mpiprint(0, 'Norm from Energy exact contraction {}'.format(E1))
     #mpiprint(0,norm1,E1,norm0,E2,abs((norm0-E2)/norm0))
     self.assertTrue(abs((norm0 - E2) / norm0) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #11
0
 def test_energy_itf_contraction(self):
     mpiprint(
         0, '\n' + '=' * 50 +
         '\nPeps Energy (Ham=ITF, peps=random, no symmetry) calculation\n' +
         '-' * 50)
     # Create a PEPS
     from cyclopeps.tools.peps_tools import PEPS
     Nx = 2
     Ny = 2
     d = 2
     D = 3
     backend = 'ctf'
     peps = PEPS(Nx=Nx, Ny=Ny, d=d, D=D, chi=1000, backend=backend)
     peps2 = PEPS(Nx=Nx, Ny=Ny, d=d, D=D, chi=1000, backend=backend)
     # Get the Hamiltonian
     from cyclopeps.ops.itf import return_op
     ham = return_op(Nx, Ny, (1., 2.), backend=backend)
     # Perform the Exact energy calculation:
     bra = einsum('LDWCM,lMXcu->WXCc', peps[0][0], peps[0][1])
     bra = einsum('WXCc,CdYRm->WXYcm', bra, peps[1][0])
     bra = einsum('WXYcm,cmZru->WXYZ', bra, peps[1][1])
     ket = einsum('LDWCM,lMXcu->WXCc', peps2[0][0], peps2[0][1])
     ket = einsum('WXCc,CdYRm->WXYcm', ket, peps2[1][0])
     ket = einsum('WXYcm,cmZru->WXYZ', ket, peps2[1][1])
     norm1 = einsum('WXYZ,WXYZ->', bra, ket)
     tmp = einsum('WXYZ,wxYZ->WXwx', bra, ket)
     E1 = einsum('WXwx,WXwx->', tmp, ham[0][0][0])
     tmp = einsum('WXYZ,wXyZ->WYwy', bra, ket)
     E2 = einsum('WYwy,WYwy->', tmp, ham[1][0][0])
     tmp = einsum('WXYZ,WXyz->YZyz', bra, ket)
     E3 = einsum('YZyz,YZyz->', tmp, ham[0][1][0])
     tmp = einsum('WXYZ,WxYz->XZxz', bra, ket)
     E4 = einsum('XZxz,XZxz->', tmp, ham[1][1][0])
     E1 = E1 + E2 + E3 + E4
     # Contract Energy again
     E2 = peps.calc_op(ham, normalize=False, chi=1e100, ket=peps2)
     mpiprint(0, 'Energy (exact)   = {}'.format(E1))
     mpiprint(0, 'Energy (routine) = {}'.format(E2))
     self.assertTrue(abs((E2 - E1) / E1) < 1e-10)
     mpiprint(0, 'Passed\n' + '=' * 50)
Пример #12
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)
Пример #13
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)
Пример #14
0
# TEBD Parameters
step_sizes = [0.1]
n_step = [5]

# Get Hamiltonian
if Zn is None:
    ham = return_op(Nx, Ny, sym=None, backend=backend)
else:
    ham = return_op(Nx, Ny, sym='Z2', backend=backend)

# Create PEPS
peps = PEPS(Nx,
            Ny,
            d,
            D,
            chi,
            Zn=Zn,
            chi_norm=10,
            chi_op=10,
            backend=backend,
            normalize=False)

# Setup Profiling
profile_fname = 'calc_norm_stats_Nx{}_Ny{}_d{}_D{}_chi{}_Zn{}_{}'.format(
    Nx, Ny, d, D, chi, Zn, backend)
if backend == 'ctf':
    from ctf import timer_epoch
    te = timer_epoch('1')
    te.begin()
t0 = time.time()
# Evaluate Operator
cProfile.run('val = peps.calc_norm(chi=chi)', profile_fname)
Пример #15
0
print('dr = {}'.format(dr))
print('dl = {}'.format(dl))
print('du = {}'.format(du))
print('dd = {}'.format(dd))
print('sx = {}'.format(sx))
print('sy = {}'.format(sy))

# Create the Suzuki trotter decomposed operator
ops = return_op(Nx, Ny, params)
opsl = ops_conj_trans(ops)
curr_ops = return_curr_op(Nx, Ny, params)
dens_ops_top = return_dens_op(Nx, Ny, top=True)
dens_ops_bot = return_dens_op(Nx, Ny, top=False)

# Run TEBD
peps = PEPS(Nx, Ny, d, D[0], chi[0], fname=fnamer, fdir=savedir)
pepsl = PEPS(Nx, Ny, d, D[0], chi[0], fname=fnamel, fdir=savedir)

# Loop over all optimizaton parameters
for ind in range(len(D)):

    # --------------------------------------------------------------------
    # Calculate right eigenstate
    Ef, peps = run_tebd(Nx,
                        Ny,
                        d,
                        ops,
                        peps=peps,
                        D=D[ind],
                        chi=chi[ind],
                        n_step=n_step[ind],
Пример #16
0
print('dl = {}'.format(dl))
print('du = {}'.format(du))
print('dd = {}'.format(dd))
print('sx = {}'.format(sx))
print('sy = {}'.format(sy))

# Create the Suzuki trotter decomposed operator
ops = return_op(Nx, Ny, params)
opsl = ops_conj_trans(ops)

# Run TEBD
pepsl = PEPS(Nx,
             Ny,
             d,
             D[0],
             chi[0],
             fname=fnamel,
             fdir=savedir,
             norm_tol=0.5,
             norm_bs_upper=3.,
             norm_bs_lower=0.)

# Loop over all optimizaton parameters
for ind in range(len(D)):
    # Update PEPS Parameters
    pepsl.D = D[ind]
    pepsl.chi = chi[ind]
    pepsl.fname = prepend + "Nx{}_Ny{}_sx{}_sy{}_D{}_chi{}_run_left".format(
        Nx, Ny, sxind, syind, D[ind], chi[ind])

    # --------------------------------------------------------------------
    # Calculate left eigenstate
Пример #17
0
print('dr = {}'.format(dr))
print('dl = {}'.format(dl))
print('du = {}'.format(du))
print('dd = {}'.format(dd))
print('sx = {}'.format(sx))
print('sy = {}'.format(sy))

# Create the Suzuki trotter decomposed operator
ops = return_op(Nx,Ny,params)
opsl= ops_conj_trans(ops)
curr_ops = return_curr_op(Nx,Ny,params)
dens_ops_top = return_dens_op(Nx,Ny,top=True)
dens_ops_bot = return_dens_op(Nx,Ny,top=False)

# Run TEBD
peps = PEPS(Nx,Ny,d,D[0],chi[0])
pepsl = PEPS(Nx,Ny,d,D[0],chi[0])
for ind in range(len(D)):
    print('Right Vector' + '-'*50)
    # Calculate right state
    try:
        Ef,peps = run_tebd(Nx,
                           Ny,
                           d,
                           ops,
                           peps=peps,
                           D=D[ind],
                           chi=chi[ind],
                           n_step=ns[ind],
                           step_size=dt[ind])
    except Exception as e: 
Пример #18
0
from cyclopeps.tools.peps_tools import PEPS, load_peps
from cyclopeps.ops.asep import return_op
from cyclopeps.algs.tebd import run_tebd
from cyclopeps.algs.tebd import run_tebd
from sys import argv
import numpy as np

# Get input values
fname = argv[1]
Nx = int(argv[2])
Ny = int(argv[3])
start = 3

# ---------------------------------------------------------
# Create an initial peps
peps = PEPS(Nx=Nx, Ny=Ny, fname=fname + '_restart', fdir='./', normalize=False)
peps.load_tensors(fname)

# TEBD Parameters
step_sizes = [
    0.5, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1,
    0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01,
    0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1,
    0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01, 0.1, 0.01,
    0.1, 0.01, 0.1, 0.01
]
D = [
    1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
    5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9,
    9, 10, 10, 10, 10, 10, 10
]
Пример #19
0
import pstats

# 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))
Пример #20
0
for N in Nvec:
    for prepend in prepend_vec:
        for dind in range(len(D)):
            for sxind in range(21)[::-1]:

                loaded = False
                # Get peps loaded
                try:
                    fnamel = prepend + 'Nx{}_Ny{}_sx{}_sy{}_D{}_chi{}_run_left'.format(
                        N, N, sxind, 0, D[dind], chi[dind])
                    pepsl = PEPS(N,
                                 N,
                                 d,
                                 D[dind],
                                 chi[dind],
                                 norm_tol=0.5,
                                 norm_bs_upper=3.,
                                 norm_bs_lower=0.,
                                 normalize=False)
                    pepsl.load_tensors(pepsdir + fnamel)
                    loaded = True
                except Exception as e:
                    #print('Failed to get PEPS left loaded: {}'.format(e))
                    pepsl = None
                try:
                    fnamer = prepend + 'Nx{}_Ny{}_sx{}_sy{}_D{}_chi{}_run_right'.format(
                        N, N, sxind, 0, D[dind], chi[dind])
                    peps = PEPS(N,
                                N,
                                d,
Пример #21
0
print('sx = {}'.format(sx))
print('sy = {}'.format(sy))

# Create the Suzuki trotter decomposed operator
ops = return_op(Nx, Ny, params)
opsl = ops_conj_trans(ops)
curr_ops = return_curr_op(Nx, Ny, params)
dens_ops_top = return_dens_op(Nx, Ny, top=True)
dens_ops_bot = return_dens_op(Nx, Ny, top=False)

# Run TEBD
peps = PEPS(Nx,
            Ny,
            d,
            D[0],
            chi[0],
            fname=fnamer,
            fdir=savedir,
            norm_tol=0.5,
            norm_bs_upper=3.,
            norm_bs_lower=0.)
pepsl = PEPS(Nx,
             Ny,
             d,
             D[0],
             chi[0],
             fname=fnamel,
             fdir=savedir,
             norm_tol=0.5,
             norm_bs_upper=3.,
             norm_bs_lower=0.)