@@ -7,7 +7,7 @@ module TestAlgorithms
77
88using .. TestSetup
99using Test, TestExtras
10- using MPSKit
10+ using MPSKit: fuse_mul_mpo
1111using TensorKit
1212using TensorKit: ℙ
1313
763763end
764764
765765@testset "TaylorCluster time evolution" begin
766+ L = 4
767+ dt = 0.05
768+ dτ = -im * dt
769+
770+ @testset "O(1) exact expression" begin
771+ alg = TaylorCluster(; N=1, compression=true, extension=true)
772+ for H in (transverse_field_ising(), heisenberg_XXX())
773+ # Infinite
774+ mpo = make_time_mpo(H, dt, alg)
775+ O = mpo[1]
776+ I, A, B, C, D = H[1][1], H.A[1], H.B[1], H.C[1], H.D[1]
777+
778+ @test size(O, 1) == size(D, 1)^2 + (size(D, 1) * size(B, 1))
779+ @test size(O, 4) == size(D, 4)^2 + (size(C, 4) * size(D, 4))
780+
781+ O_exact = similar(O)
782+ O_exact[1, 1, 1, 1] = I + dτ * D + dτ^2 / 2 * fuse_mul_mpo(D, D)
783+ O_exact[1, 1, 1, 2] = C + dτ * symm_mul_mpo(C, D)
784+ O_exact[2, 1, 1, 1] = dτ * (B + dτ * symm_mul_mpo(B, D))
785+ O_exact[2, 1, 1, 2] = A + dτ * (symm_mul_mpo(A, D) + symm_mul_mpo(C, B))
786+
787+ @test all(isapprox.(parent(O), parent(O_exact)))
788+
789+ # Finite
790+ H_fin = open_boundary_conditions(H, L)
791+ mpo_fin = make_time_mpo(H_fin, dt, alg)
792+ mpo_fin2 = open_boundary_conditions(mpo, L)
793+ for i in 1:L
794+ @test all(isapprox.(parent(mpo_fin[i]), parent(mpo_fin2[i])))
795+ end
796+ end
797+ end
798+
799+ @testset "O(2) exact expression" begin
800+ alg = TaylorCluster(; N=2, compression=true, extension=true)
801+ for H in (transverse_field_ising(), heisenberg_XXX())
802+ # Infinite
803+ mpo = make_time_mpo(H, dt, alg)
804+ O = mpo[1]
805+ I, A, B, C, D = H[1][1], H.A[1], H.B[1], H.C[1], H.D[1]
806+
807+ @test size(O, 1) ==
808+ size(D, 1)^3 + (size(D, 1)^2 * size(B, 1)) + (size(D, 1) * size(B, 1)^2)
809+ @test size(O, 4) ==
810+ size(D, 4)^3 + (size(C, 4) * size(D, 4)^2) + (size(D, 4) * size(C, 4)^2)
811+
812+ O_exact = similar(O)
813+ O_exact[1, 1, 1, 1] = I + dτ * D + dτ^2 / 2 * fuse_mul_mpo(D, D) +
814+ dτ^3 / 6 * fuse_mul_mpo(fuse_mul_mpo(D, D), D)
815+ O_exact[1, 1, 1, 2] = C + dτ * symm_mul_mpo(C, D) +
816+ dτ^2 / 2 * symm_mul_mpo(C, D, D)
817+ O_exact[1, 1, 1, 3] = fuse_mul_mpo(C, C) + dτ * symm_mul_mpo(C, C, D)
818+ O_exact[2, 1, 1, 1] = dτ *
819+ (B + dτ * symm_mul_mpo(B, D) +
820+ dτ^2 / 2 * symm_mul_mpo(B, D, D))
821+ O_exact[2, 1, 1, 2] = A + dτ * symm_mul_mpo(A, D) +
822+ dτ^2 / 2 * symm_mul_mpo(A, D, D) +
823+ dτ * (symm_mul_mpo(C, B) + dτ * symm_mul_mpo(C, B, D))
824+ O_exact[2, 1, 1, 3] = 2 * (symm_mul_mpo(A, C) + dτ * symm_mul_mpo(A, C, D)) +
825+ dτ * symm_mul_mpo(C, C, B)
826+ O_exact[3, 1, 1, 1] = dτ^2 / 2 *
827+ (fuse_mul_mpo(B, B) + dτ * symm_mul_mpo(B, B, D))
828+ O_exact[3, 1, 1, 2] = dτ * (symm_mul_mpo(A, B) + dτ * symm_mul_mpo(A, B, D)) +
829+ dτ^2 / 2 * symm_mul_mpo(B, B, C)
830+ O_exact[3, 1, 1, 3] = fuse_mul_mpo(A, A) + dτ * symm_mul_mpo(A, A, D) +
831+ 2 * dτ * symm_mul_mpo(A, C, B)
832+
833+ @test all(isapprox.(parent(O), parent(O_exact)))
834+
835+ # Finite
836+ H_fin = open_boundary_conditions(H, L)
837+ mpo_fin = make_time_mpo(H_fin, dt, alg)
838+ mpo_fin2 = open_boundary_conditions(mpo, L)
839+ for i in 1:L
840+ @test all(isapprox.(parent(mpo_fin[i]), parent(mpo_fin2[i])))
841+ end
842+ end
843+ end
844+
766845 L = 4
767846 Hs = [transverse_field_ising(; L=L), heisenberg_XXX(; L=L)]
768847
800879 end
801880end
802881
803- @testset "TaylorCluster for non-square Hamiltonians" begin
804- # Make a MPOHamiltonian with very non-square Tensors
805- # Make different orders and kinds of TaylorCluster time-evolution MPOs
806- # Check the virtual dimensions match up between the MPOs
807-
808- chain = fill(ℂ^2, 8)
809- O = randn(ComplexF64, ℂ^2 ← ℂ^2)
810-
811- ops1 = fill((1, 2) => O ⊗ O, 5)
812- ops2 = [(2, 3) => O ⊗ O ⊗ O for i in 2:(length(chain) - 1)]
813- ops3 = [(3, 5) => O ⊗ O ⊗ O for i in 3:(length(chain) - 2)]
814-
815- H = FiniteMPOHamiltonian(chain, ops1..., ops2..., ops3...)
816-
817- for N in 1:3
818- for configuration in ((false, false), (false, true), (true, false), (true, true))
819- O = make_time_mpo(H, 0.1, TaylorCluster(N, configuration...))
820- for i in 1:(length(chain) - 1)
821- @test right_virtualspace(O, i) == left_virtualspace(O, i + 1)
822- end
823- end
824- end
825- end
826-
827882end
0 commit comments