eH = cytnx.UniTensor(eH,2) eH.print_diagram() print(eH) H = cytnx.UniTensor(H,2) H.print_diagram() ## Create MPS: # # | | # --A-la-B-lb-- # A = cytnx.UniTensor([cytnx.Bond(chi),cytnx.Bond(2),cytnx.Bond(chi)],rowrank=1,labels=[-1,0,-2]); B = cytnx.UniTensor(A.bonds(),rowrank=1,labels=[-3,1,-4]); cytnx.random.Make_normal(B.get_block_(),0,0.2); cytnx.random.Make_normal(A.get_block_(),0,0.2); A.print_diagram() B.print_diagram() #print(A) #print(B) la = cytnx.UniTensor([cytnx.Bond(chi),cytnx.Bond(chi)],rowrank=1,labels=[-2,-3],is_diag=True) lb = cytnx.UniTensor([cytnx.Bond(chi),cytnx.Bond(chi)],rowrank=1,labels=[-4,-5],is_diag=True) la.put_block(cytnx.ones(chi)); lb.put_block(cytnx.ones(chi)); la.print_diagram() lb.print_diagram() #print(la) #print(lb)
eH = cytnx.UniTensor(eH, 2) eH.tag() # this will tag with in/out(ket/bra) on each bond. eH.print_diagram() H = cytnx.UniTensor(H, 2) H.tag() H.print_diagram() ## Create MPS, with bond tagged with direction in/out(ket/bra): # ^ ^ # | | # ->-A-> ->la-> ->B-> ->lb-> # A = cytnx.UniTensor([ cytnx.Bond(chi, cytnx.BD_KET), cytnx.Bond(2, cytnx.BD_BRA), cytnx.Bond(chi, cytnx.BD_BRA) ], rowrank=1, labels=[-1, 0, -2]) B = cytnx.UniTensor(A.bonds(), rowrank=1, labels=[-3, 1, -4]) cytnx.random.Make_normal(B.get_block_(), 0, 0.2) cytnx.random.Make_normal(A.get_block_(), 0, 0.2) A.print_diagram() B.print_diagram() #print(A) #print(B) la = cytnx.UniTensor( [cytnx.Bond(chi, cytnx.BD_KET), cytnx.Bond(chi, cytnx.BD_BRA)],
H.reshape_(2, 2, 2, 2) eH = cytnx.UniTensor(eH, 2) eH.print_diagram() print(eH) H = cytnx.UniTensor(H, 2) H.print_diagram() ## Create MPS: # # | | # --A-la-B-lb-- # A = cytnx.UniTensor( [cytnx.Bond(chi), cytnx.Bond(2), cytnx.Bond(chi)], rowrank=1, labels=[-1, 0, -2]) B = cytnx.UniTensor(A.bonds(), rowrank=1, labels=[-3, 1, -4]) cytnx.random.Make_normal(B.get_block_(), 0, 0.2) cytnx.random.Make_normal(A.get_block_(), 0, 0.2) A.print_diagram() B.print_diagram() #print(A) #print(B) la = cytnx.UniTensor([cytnx.Bond(chi), cytnx.Bond(chi)], rowrank=1, labels=[-2, -3], is_diag=True) lb = cytnx.UniTensor([cytnx.Bond(chi), cytnx.Bond(chi)],
# which is the same in this model, but in general they could be different Hup = H Hdown = Hup.clone() ## Hamiltonain Hu = cy.UniTensor(Hup, 3) Hd = cy.UniTensor(Hdown, 3) ## create 3PESS: s1 = cy.UniTensor(cy.random.normal([D, D, D], 0, 0.5), 0) s2 = s1.clone() A = cy.UniTensor(cy.random.normal([D, 2, D], 0, 0.5), 2) B = cy.UniTensor(cy.random.normal([D, 2, D], 0, 0.5), 2) C = cy.UniTensor(cy.random.normal([D, 2, D], 0, 0.5), 2) Ls1 = [ cy.UniTensor([cy.Bond(D), cy.Bond(D)], rowrank=1, is_diag=True) for i in range(3) ] for i in Ls1: i.put_block(cy.ones(D)) Ls2 = [i.clone() for i in Ls1] ## gates: eHu = cy.linalg.ExpH(Hu, -tau) eHd = cy.linalg.ExpH(Hd, -tau) ## iterator: Eup_old, Edown_old = 0, 0 cov = False for i in range(maxit):
Tn3 = cytnx.zeros(10, device=cytnx.Device.cpu) print(Tn) print(Tn2) print(Tn3) Tna = cytnx.zeros((2, 3)) Tn2a = cytnx.zeros((2, 3), dtype=cytnx.Type.Float) Tn3a = cytnx.zeros((2, 3), device=cytnx.Device.cpu) print(Tna) print(Tn2a) print(Tn3a) ##============================= ## Bond ##============================= bd_in = cytnx.Bond(10, cytnx.bondType.BD_BRA) print(bd_in) bd_sym = cytnx.Bond(3,cytnx.bondType.BD_KET,\ [[0,2],[1,2],[1,3]],\ [cytnx.Symmetry.Zn(2),\ cytnx.Symmetry.U1()]) print(bd_sym) print(bd_sym == bd_sym) bd_1 = cytnx.Bond(3) bd_2 = cytnx.Bond(2) bd_3 = cytnx.Bond(4) U = cytnx.UniTensor([bd_1, bd_2, bd_3], Rowrank=2, dtype=cytnx.Type.Double) U.print_diagram()
## # Author: Kai-Hsin Wu ## #Example of 1D Heisenberg model ## iTEBD ##------------------------------------- chi = 40 J = 1.0 CvgCrit = 1.0e-12 dt = 0.1 ## Create Si Sj local H with symmetry: ## SzSz + S+S- + h.c. bdi = cytnx.Bond(2, cytnx.BD_KET, [[1], [-1]]) bdo = bdi.clone().set_type(cytnx.BD_BRA) H = cytnx.UniTensor([bdi, bdi, bdo, bdo], labels=[2, 3, 0, 1], rowrank=2) ## assign: # Q = 2 # Q = 0: # Q = -2: # [1] [[ -1, 1] [1] # [ 1,-1]] H.get_block_([2])[0] = 1 T0 = H.get_block_([0]) T0[0, 0] = T0[1, 1] = -1 T0[0, 1] = T0[1, 0] = 1 H.get_block_([-2])[0] = 1 ## create gate: eH = cytnx.linalg.ExpH(H, -dt)