@@ -950,51 +950,94 @@ module TestAlgorithms
950950 end
951951
952952 @testset " Finite temperature methods" begin
953- L = 6
954- H = transverse_field_ising (; L)
955- trscheme = truncdim (20 )
956- verbosity = 1
957- beta = 0.1
953+ imaginary_evolution = true
954+ @testset " Finite-size" begin
955+ L = 6
956+ H = transverse_field_ising (; L)
957+ trscheme = truncdim (20 )
958+ verbosity = 1
959+ beta = 0.1
960+
961+ # exact diagonalization
962+ H_dense = convert (TensorMap, H)
963+ Z_dense_1 = tr (exp (- beta * H_dense))^ (1 / L)
964+ Z_dense_2 = tr (exp (- 2 beta * H_dense))^ (1 / L)
965+
966+ # taylor cluster
967+ rho_taylor_1 = make_time_mpo (H, beta, TaylorCluster (; N = 2 ); imaginary_evolution)
968+ Z_taylor_1 = tr (rho_taylor_1)^ (1 / L)
969+ @test Z_taylor_1 ≈ Z_dense_1 atol = 1.0e-2
970+ Z_taylor_2 = real (dot (rho_taylor_1, rho_taylor_1))^ (1 / L)
971+ @test Z_taylor_2 ≈ Z_dense_2 atol = 1.0e-2
972+
973+ E_x_taylor = @constinferred expectation_value (rho_taylor_1, 1 => S_x ())
974+ E_xx_taylor = @constinferred expectation_value (rho_taylor_1, (1 , 2 ) => S_xx ())
975+
976+ # WII
977+ rho_wii = make_time_mpo (H, beta, WII (); imaginary_evolution)
978+ Z_wii = tr (rho_wii)^ (1 / L)
979+ @test Z_wii ≈ Z_dense_1 atol = 1.0e-2
980+ @test expectation_value (rho_wii, 1 => S_x ()) ≈ E_x_taylor atol = 1.0e-2
981+ @test expectation_value (rho_wii, (1 , 2 ) => S_xx ()) ≈ E_xx_taylor atol = 1.0e-2
982+
983+ # MPO multiplication
984+ rho_mps = convert (FiniteMPS, rho_taylor_1)
985+ rho_mps, = approximate (rho_mps, (rho_taylor_1, rho_mps), DMRG2 (; trscheme, verbosity))
986+ Z_mpomul = tr (convert (FiniteMPO, rho_mps))^ (1 / L)
987+ @test Z_mpomul ≈ Z_dense_2 atol = 1.0e-2
988+
989+ # TDVP
990+ rho_0 = MPSKit. infinite_temperature_density_matrix (H)
991+ rho_0_mps = convert (FiniteMPS, rho_0)
992+ rho_mps, = timestep (rho_0_mps, H, 0.0 , beta, TDVP2 (; trscheme); imaginary_evolution)
993+ Z_tdvp = real (dot (rho_mps, rho_mps))^ (1 / L)
994+ @test Z_tdvp ≈ Z_dense_2 atol = 1.0e-2
995+
996+ @test expectation_value (rho_0_mps, 1 => S_x ()) ≈ 0
997+ @test expectation_value (rho_0_mps, (1 , 2 ) => S_xx ()) ≈ 0
998+ @test expectation_value (rho_mps, 1 => S_x ()) ≈ E_x_taylor atol = 1.0e-2
999+ @test expectation_value (rho_mps, (1 , 2 ) => S_xx ()) ≈ E_xx_taylor atol = 1.0e-2
1000+ end
9581001
959- # exact diagonalization
960- H_dense = convert (TensorMap, H )
961- Z_dense_1 = tr ( exp ( - beta * H_dense)) ^ ( 1 / L )
962- Z_dense_2 = tr ( exp ( - 2 beta * H_dense)) ^ ( 1 / L)
963-
964- # taylor cluster
965- rho_taylor_1 = make_time_mpo (H, beta, TaylorCluster (; N = 2 ); imaginary_evolution = true )
966- Z_taylor_1 = tr (rho_taylor_1) ^ ( 1 / L )
967- @test Z_taylor_1 ≈ Z_dense_1 atol = 1.0e-2
968- Z_taylor_2 = real ( dot (rho_taylor_1, rho_taylor_1)) ^ ( 1 / L )
969- @test Z_taylor_2 ≈ Z_dense_2 atol = 1.0e-2
970-
971- E_x_taylor = @constinferred expectation_value (rho_taylor_1, 1 => S_x ())
972- E_xx_taylor = @constinferred expectation_value (rho_taylor_1, ( 1 , 2 ) => S_xx ())
973-
974- # WII
975- rho_wii = make_time_mpo (H, beta, WII (); imaginary_evolution = true )
976- Z_wii = tr (rho_wii) ^ ( 1 / L )
977- @test Z_wii ≈ Z_dense_1 atol = 1.0e-2
978- @test expectation_value (rho_wii, 1 => S_x ()) ≈ E_x_taylor atol = 1.0e-2
979- @test expectation_value (rho_wii, ( 1 , 2 ) => S_xx ()) ≈ E_xx_taylor atol = 1.0e-2
980-
981- # MPO multiplication
982- rho_mps = convert (FiniteMPS, rho_taylor_1 )
983- rho_mps, = approximate (rho_mps, (rho_taylor_1, rho_mps), DMRG2 (; trscheme, verbosity) )
984- Z_mpomul = tr ( convert (FiniteMPO, rho_mps)) ^ ( 1 / L)
985- @test Z_mpomul ≈ Z_dense_2 atol = 1.0e-2
986-
987- # TDVP
988- rho_0 = MPSKit . infinite_temperature_density_matrix (H )
989- rho_0_mps = convert (FiniteMPS, rho_0 )
990- rho_mps, = timestep (rho_0_mps, H, 0.0 , beta, TDVP2 (; trscheme); imaginary_evolution = true )
991- Z_tdvp = real ( dot (rho_mps, rho_mps)) ^ ( 1 / L)
992- @test Z_tdvp ≈ Z_dense_2 atol = 1.0e-2
993-
994- @test expectation_value (rho_0_mps, 1 => S_x ()) ≈ 0
995- @test expectation_value (rho_0_mps, ( 1 , 2 ) => S_xx ()) ≈ 0
996- @test expectation_value (rho_mps, 1 => S_x ()) ≈ E_x_taylor atol = 1.0e-2
997- @test expectation_value (rho_mps, ( 1 , 2 ) => S_xx ()) ≈ E_xx_taylor atol = 1.0e-2
1002+ @testset " Infinite-size " begin
1003+ H = transverse_field_ising ( )
1004+ trscheme = truncdim ( 20 )
1005+ verbosity = 1
1006+ beta = 0.1
1007+
1008+ # taylor cluster
1009+ alg_taylor = TaylorCluster (; N = 2 )
1010+ rho_taylor = make_time_mpo (H, beta, alg_taylor; imaginary_evolution)
1011+ rho_taylor_2 = make_time_mpo (H, 2 beta, alg_taylor; imaginary_evolution )
1012+ E_taylor = @constinferred expectation_value (rho_taylor, H)
1013+ E_taylor2 = @constinferred expectation_value (rho_taylor_2, H)
1014+
1015+ E_z_taylor = @constinferred expectation_value (rho_taylor, 1 => S_z ())
1016+ @test E_z_taylor ≈ 0 atol = 1.0e-4 # no spontaneous symmetry breaking at finite T
1017+
1018+ # WII
1019+ rho_wii = make_time_mpo (H, beta, WII (); imaginary_evolution )
1020+ @test expectation_value (rho_wii, H) ≈ E_taylor atol = 1.0e-2
1021+ @test expectation_value (rho_wii, 1 => S_z ()) ≈ E_z_taylor atol = 1.0e-2
1022+
1023+ # MPO multiplication
1024+ rho_mps = convert (InfiniteMPS, rho_taylor)
1025+ rho_mps2, = approximate (rho_mps, (rho_taylor, rho_mps), IDMRG (; verbosity) )
1026+ E_mpomul = expectation_value (rho_mps2, H )
1027+ @test E_mpomul ≈ E_taylor2 atol = 1.0e-2
1028+
1029+ # TDVP
1030+ rho_0 = MPSKit . infinite_temperature_density_matrix (H)
1031+ rho_0_mps, = changebonds ( convert (InfiniteMPS, rho_0), H, OptimalExpand (; trscheme = truncdim ( 20 )) )
1032+ rho_mps_tdvp, = timestep (rho_0_mps, H, 0.0 , beta, TDVP (); imaginary_evolution )
1033+ E_tdvp = expectation_value (rho_mps_tdvp, H )
1034+ @test E_tdvp ≈ E_taylor atol = 1.0e-2
1035+
1036+ num_vals = 2
1037+ vals_taylor = @constinferred ( transfer_spectrum ( convert (InfiniteMPS, rho_taylor); num_vals))
1038+ vals_mps = @constinferred ( transfer_spectrum (rho_mps; num_vals))
1039+ @test vals_taylor[ 1 : num_vals] ≈ vals_mps[ 1 : num_vals]
1040+ end
9981041 end
9991042
10001043 @testset " Sector conventions" begin
0 commit comments