Advanced Computing Platform for Theoretical Physics

commit大文件会使得服务器变得不稳定,请大家尽量只commit代码,不要commit大的文件。

Commit dc5ed25b authored by Lei Wang's avatar Lei Wang

start ctmrg from tensor

parent 4162baf1
......@@ -11,8 +11,10 @@ def ctmrg(T, d, Dcut, max_iter):
lnZ = 0.0
truncation_error = 0.0
C = torch.randn(d, d, dtype=T.dtype, device=T.device) #T.sum((0,1))
E = torch.randn(d, d, d, dtype=T.dtype, device=T.device)#T.sum(1)
#C = torch.randn(d, d, dtype=T.dtype, device=T.device) #T.sum((0,1))
#E = torch.randn(d, d, d, dtype=T.dtype, device=T.device)#T.sum(1)
C = T.sum((0,1))
E = T.sum(1)
D = d
sold = torch.zeros(d, dtype=T.dtype, device=T.device)
......@@ -53,7 +55,7 @@ def ctmrg(T, d, Dcut, max_iter):
if (diff < 1E-8):
break
sold = s
print ('ctmrg iterations', n)
Z1 = torch.einsum('ab,bcd,fd,gha,hcij,fjk,lg,mil,mk', (C,E,C,E,T,E,C,E,C))
#CEC = torch.einsum('da,ebd,ce->abc', (C,E,C)).view(1, D**2*d)
#ETE = torch.einsum('abc,lbdr,mdn->almcrn',(E,T,E)).contiguous().view(D**2*d, D**2*d)
......@@ -65,7 +67,7 @@ def ctmrg(T, d, Dcut, max_iter):
#print (' Z1, Z2, Z3:', Z1.item(), Z2.item(), Z3.item())
lnZ += torch.log(Z1.abs()) + torch.log(Z3.abs()) - 2.*torch.log(Z2.abs())
return lnZ, truncation_error
return lnZ, truncation_error/n
if __name__=='__main__':
torch.set_num_threads(1)
......
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