Ejemplo n.º 1
0
    def test_local_hamiltonians_3(self):
        Sx1, Sy1, Sz1 = N_body_spins(0.5, 1, 3)
        Sx2, Sy2, Sz2 = N_body_spins(0.5, 2, 3)
        Sx3, Sy3, Sz3 = N_body_spins(0.5, 3, 3)

        Sx12, Sy12, Sz12 = N_body_spins(0.5, 1, 2)
        Sx22, Sy22, Sz22 = N_body_spins(0.5, 2, 2)

        mps = self.mps_0_3
        listH = [Sz12@Sz22+Sx12, Sz12@Sz22+Sx12+Sx22]
        fullH = sum([n_body(a, i, len(listH), d=2) for i, a in enumerate(listH)], axis=0)
        self.assertTrue(mps.dA_dt(listH, fullH=False)==mps.dA_dt(fullH, fullH=True))
Ejemplo n.º 2
0
    def test_local_recombine(self):
        Sx1, Sy1, Sz1 = N_body_spins(0.5, 1, 4)
        Sx2, Sy2, Sz2 = N_body_spins(0.5, 2, 4)
        Sx3, Sy3, Sz3 = N_body_spins(0.5, 3, 4)
        Sx4, Sy4, Sz4 = N_body_spins(0.5, 4, 4)

        Sx12, Sy12, Sz12 = N_body_spins(0.5, 1, 2)
        Sx22, Sy22, Sz22 = N_body_spins(0.5, 2, 2)

        listH4 = [Sz12@Sz22+Sx12, Sz12@Sz22+Sx12+Sx22, Sz12@Sz22+Sx22]
        comH4 = sum([n_body(a, i, len(listH4), d=2) for i, a in enumerate(listH4)], axis=0)
        fullH4 = Sz1@Sz2+Sz2@Sz3+Sz3@Sz4+Sx1+Sx2+Sx3+Sx4
        self.assertTrue(allclose(fullH4, comH4))
Ejemplo n.º 3
0
    def test_local_hamiltonians_7(self):
        Sx1, Sy1, Sz1 = N_body_spins(0.5, 1, 7)
        Sx2, Sy2, Sz2 = N_body_spins(0.5, 2, 7)
        Sx3, Sy3, Sz3 = N_body_spins(0.5, 3, 7)
        Sx4, Sy4, Sz4 = N_body_spins(0.5, 4, 7)
        Sx5, Sy5, Sz5 = N_body_spins(0.5, 5, 7)
        Sx6, Sy6, Sz6 = N_body_spins(0.5, 6, 7)
        Sx7, Sy7, Sz7 = N_body_spins(0.5, 7, 7)

        Sx12, Sy12, Sz12 = N_body_spins(0.5, 1, 2)
        Sx22, Sy22, Sz22 = N_body_spins(0.5, 2, 2)

        mps = self.mps_0_7
        listH = [Sz12@Sz22+Sx12, Sz12@Sz22+Sx12+Sx22, Sz12@Sz22+Sx12+Sx22, Sz12@Sz22+Sx12+Sx22, Sz12@Sz22+Sx12+Sx22, Sz12@Sz22+Sx22]
        fullH = sum([n_body(a, i, len(listH), d=2) for i, a in enumerate(listH)], axis=0)
        self.assertTrue(mps.dA_dt(listH, fullH=False)==mps.dA_dt(fullH, fullH=True))
Ejemplo n.º 4
0
    def test_random_with_energy(self):
        Sx12, Sy12, Sz12 = N_body_spins(0.5, 1, 2)
        Sx22, Sy22, Sz22 = N_body_spins(0.5, 2, 2)

        L = 6
        d = 2
        D = 1

        h = 4*Sz12@Sz22+2*Sx22+2*Sz22
        h = (h+h.conj().T)/2
        H = [h for _ in range(L-1)]
        H[0] = H[0]+2*Sx12+2*Sz12

        comH = sum([n_body(a, i, len(H), d=2) for i, a in enumerate(H)], axis=0)
        v = eigvalsh(comH)
        E = (max(v)-min(v))/2.5

        tol = 1e-10
        mps = fMPS().random_with_energy_E(E, H, L, d, D, 1e-10)
        self.assertTrue(abs(mps.energy(H)-E)<tol)