示例#1
0
 def test_realistic(self):
     seed_rand(42)
     ham = MPO_ham_heis(20)
     dmrg = DMRG2(ham, bond_dims=[2, 4])
     dmrg.solve()
     rho_ab = dmrg.state.ptr(range(6, 14))
     xf = approx_spectral_function(rho_ab, lambda x: x,
                                   tol=0.1, verbosity=2)
     assert_allclose(1.0, xf, rtol=0.6, atol=0.001)
示例#2
0
 def test_realistic(self):
     ham = MPO_ham_heis(20)
     dmrg = DMRG2(ham, bond_dims=[4, 8])
     dmrg.solve()
     sysa, sysb = range(3, 9), range(12, 17)
     rho_ab_pt = PTPTLazyMPS(dmrg.state, sysa, sysb)
     xf = approx_spectral_function(rho_ab_pt, lambda x: x, beta_tol=1e-6,
                                   tol=0.05, verbosity=2, max_bond=20)
     assert_allclose(1, xf, rtol=0.5, atol=0.1)
示例#3
0
    def test_realistic_ent(self):
        n = 12
        sysa, sysb = range(3, 6), range(6, 8)

        ham = MPO_ham_heis(n)
        dmrg = DMRG2(ham, bond_dims=[2, 4])
        dmrg.solve()
        rho_ab_pt = PTPTLazyMPS(dmrg.state, sysa, sysb)

        psi0 = dmrg.state.to_dense()
        lne = logneg_subsys(psi0, [2] * n, sysa=sysa, sysb=sysb)
        lnx = log2(
            approx_spectral_function(rho_ab_pt, abs, tol=0.1, verbosity=2))
        assert_allclose(lne, lnx, rtol=0.5, atol=0.1)
示例#4
0
    def test_realistic_ent(self):
        n = 12
        sysa, sysb = range(3, 6), range(6, 8)
        sysab = (*sysa, *sysb)

        ham = MPO_ham_heis(n)
        dmrg = DMRG2(ham, bond_dims=[10])
        dmrg.solve()

        psi0 = dmrg.state.to_dense()
        lne = logneg_subsys(psi0, [2] * n, sysa=sysa, sysb=sysb)

        rho_ab = dmrg.state.ptr(sysab, rescale_sites=True)
        rho_ab_pt = rho_ab.partial_transpose(range(3))
        lnx = log2(
            approx_spectral_function(rho_ab_pt, abs, tol=0.1, verbosity=2))
        assert_allclose(lne, lnx, rtol=0.6, atol=0.1)
示例#5
0
 def test_approx_fn(self, fn):
     A = MPO_rand_herm(10, 7, normalize=True)
     xe = sum(fn(eigvalsh(A.to_dense())))
     xf = approx_spectral_function(A, fn, tol=0.1, verbosity=2)
     assert_allclose(xe, xf, rtol=0.5)