Advanced Computing Platform for Theoretical Physics

Commit 1d4363f0 authored by Lei Wang's avatar Lei Wang
Browse files

better starting point in CTMRG, symmetrize T

parent bf55d87c
......@@ -5,18 +5,18 @@ torch.manual_seed(42)
torch.set_num_threads(1)
from torch.utils.checkpoint import checkpoint
from tensornets import CTMRG, TRG
from tensornets import CTMRG
def symmetrize(A):
'''
A(phy, up, left, down, right)
A(phy, up, left, down, right, phy')
left-right, up-down, diagonal symmetrize
'''
Asymm = (A + A.permute(0, 3, 2, 1))/2. # left-right symmetry
Asymm = (Asymm + Asymm.permute(2, 1, 0, 3))/2. # up-down symmetry
Asymm = (Asymm + Asymm.permute(3, 2, 1, 0))/2. # skew-diagonal symmetry
Asymm = (Asymm + Asymm.permute(1, 0, 3, 2))/2. # diagonal symmetry
Asymm = (A + A.permute(0, 1, 4, 3, 2, 5))/2. # left-right symmetry
Asymm = (Asymm + Asymm.permute(0, 3, 2, 1, 4, 5))/2. # up-down symmetry
Asymm = (Asymm + Asymm.permute(0, 4, 3, 2, 1, 5))/2. # skew-diagonal symmetry
Asymm = (Asymm + Asymm.permute(0, 2, 1, 4, 3, 5))/2. # diagonal symmetry
return Asymm
def ctmrg(T, chi, nctmrg):
......@@ -79,8 +79,9 @@ class Ising(torch.nn.Module):
else:
T = renormalize(*tensors)
T = symmetrize(T)
T = torch.einsum('xabcdx->abcd', (T)) #trace
#T = symmetrize(T)
#T = torch.einsum('xabcdy,yefghx->aebfcgdh', (T, T)).contiguous().view(self.D**2, self.D**2, self.D**2, self.D**2)
f = T.abs().max()
......
......@@ -59,8 +59,8 @@ def CTMRG(T, chi, max_iter, use_checkpoint=False):
threshold = 1E-12 if T.dtype is torch.float64 else 1E-6 # ctmrg convergence threshold
# C(down, right), E(up,right,down)
C = torch.rand(chi, chi, dtype=T.dtype, device=T.device) #T.sum((0,1)) #
E = torch.rand(chi, T.shape[0], chi, dtype=T.dtype, device=T.device)#T.sum(1).permute(0,2,1)
C = T.sum((0,1)) #
E = T.sum(1).permute(0,2,1)
truncation_error = 0.0
sold = torch.zeros(chi, dtype=T.dtype, device=T.device)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment