@@ -12,12 +12,12 @@ function chain_plus_ancilla(; nchain)
1212 for j in 1 : nchain
1313 add_vertex! (g, j)
1414 end
15- for j in 1 : (nchain - 1 )
16- add_edge! (g, j=> j + 1 )
15+ for j in 1 : (nchain- 1 )
16+ add_edge! (g, j => j + 1 )
1717 end
1818 # Add ancilla vertex near middle of chain
1919 add_vertex! (g, 0 )
20- add_edge! (g, 0 => nchain÷ 2 )
20+ add_edge! (g, 0 => nchain ÷ 2 )
2121 return g
2222end
2323
3131
3232 # Make Heisenberg model Hamiltonian
3333 h = OpSum ()
34- for j in 1 : (N - 1 )
35- h += " Sz" , j, " Sz" , j+ 1
36- h += 1 / 2 , " S+" , j, " S-" , j+ 1
37- h += 1 / 2 , " S-" , j, " S+" , j+ 1
34+ for j in 1 : (N- 1 )
35+ h += " Sz" , j, " Sz" , j + 1
36+ h += 1 / 2 , " S+" , j, " S-" , j + 1
37+ h += 1 / 2 , " S-" , j, " S+" , j + 1
3838 end
3939 H = ttn (h, sites)
4040
5454 E, gs_psi = dmrg (H, psi0; insert_kwargs= (; trunc), nsites, nsweeps, outputlevel)
5555 (outputlevel >= 1 ) && println (" 2-site DMRG energy = " , E)
5656
57- insert_kwargs= (; trunc)
57+ insert_kwargs = (; trunc)
5858 nsites = 1
5959 tmax = 0.10
6060 time_range = 0.0 : 0.02 : tmax
7373
7474 # Test that accumulated phase angle is E*tmax
7575 z = inner (psi1_t, gs_psi)
76- @test abs ( atan (imag (z)/ real (z)) - E * tmax) < 1E-4
76+ @test atan (imag (z) / real (z)) ≈ E * tmax atol = 1E-4
7777end
7878
7979@testset " Applyexp Time Point Handling" begin
8383
8484 # Make Heisenberg model Hamiltonian
8585 h = OpSum ()
86- for j in 1 : (N - 1 )
87- h += " Sz" , j, " Sz" , j+ 1
88- h += 1 / 2 , " S+" , j, " S-" , j+ 1
89- h += 1 / 2 , " S-" , j, " S+" , j+ 1
86+ for j in 1 : (N- 1 )
87+ h += " Sz" , j, " Sz" , j + 1
88+ h += 1 / 2 , " S+" , j, " S-" , j + 1
89+ h += 1 / 2 , " S-" , j, " S+" , j + 1
9090 end
9191 H = ttn (h, sites)
9292
9999
100100 nsites = 2
101101 trunc = (; cutoff= 1E-8 , maxdim= 100 )
102- insert_kwargs= (; trunc)
102+ insert_kwargs = (; trunc)
103103
104104 # Test that all time points are reached and reported correctly
105- time_points = [0.0 ,0.1 ,0.25 ,0.32 ,0.4 ]
105+ time_points = [0.0 , 0.1 , 0.25 , 0.32 , 0.4 ]
106106 times = Real[]
107107 function collect_times (problem; kws... )
108108 push! (times, ITensorNetworks. current_time (problem))
109109 end
110- time_evolve (H, time_points, psi0; insert_kwargs, nsites, sweep_callback= collect_times,outputlevel= 1 )
111- @test norm ( times - time_points) < 10 * eps (Float64)
110+ time_evolve (H, time_points, psi0; insert_kwargs, nsites, sweep_callback= collect_times, outputlevel= 1 )
111+ @test times ≈ time_points atol = 10 * eps (Float64)
112112
113113 # Test that all exponents are reached and reported correctly
114- exponent_points = [- 0.0 ,- 0.1 ,- 0.25 ,- 0.32 ,- 0.4 ]
114+ exponent_points = [- 0.0 , - 0.1 , - 0.25 , - 0.32 , - 0.4 ]
115115 exponents = Real[]
116116 function collect_exponents (problem; kws... )
117117 push! (exponents, ITensorNetworks. current_exponent (problem))
118118 end
119- applyexp (H, exponent_points, psi0; insert_kwargs, nsites, sweep_callback= collect_exponents,outputlevel= 1 )
120- @test norm ( exponents - exponent_points) < 10 * eps (Float64)
119+ applyexp (H, exponent_points, psi0; insert_kwargs, nsites, sweep_callback= collect_exponents, outputlevel= 1 )
120+ @test exponents ≈ exponent_points atol = 10 * eps (Float64)
121121end
0 commit comments