@@ -20,9 +20,10 @@ benchname(spec::AC2Spec) = dim(spec.mps_virtualspaces[1]), dim(spec.mpo_virtuals
2020
2121# Benchmarks
2222# ----------
23- function MPSKit. MPO_AC2_Hamiltonian (spec:: AC2Spec{S} ; T:: Type = Float64) where {S}
23+ function MPSKit. AC2_hamiltonian (spec:: AC2Spec{S} ; T:: Type = Float64) where {S}
2424 GL = randn (T, spec. mps_virtualspaces[1 ] ⊗ spec. mpo_virtualspaces[1 ]' ← spec. mps_virtualspaces[1 ])
2525 GR = randn (T, spec. mps_virtualspaces[3 ] ⊗ spec. mpo_virtualspaces[3 ] ← spec. mps_virtualspaces[3 ])
26+
2627 W1 = MPSKit. JordanMPOTensor {T, S} (undef, spec. mpo_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. physicalspaces[1 ] ⊗ spec. mpo_virtualspaces[2 ])
2728 for (r, c) in spec. nonzero_keys[1 ]
2829 r == c == 1 && continue
@@ -35,27 +36,45 @@ function MPSKit.MPO_AC2_Hamiltonian(spec::AC2Spec{S}; T::Type = Float64) where {
3536 r == size (W2, 1 ) && c == size (W2, 4 ) && continue
3637 W2[r, 1 , 1 , c] = randn! (W2[r, 1 , 1 , c])
3738 end
39+ H = InfiniteMPOHamiltonian (PeriodicVector ([W1, W2]))
40+
41+ A = PeriodicVector (
42+ [
43+ randn (T, spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[2 ]),
44+ randn (T, spec. mps_virtualspaces[2 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ]),
45+ ]
46+ )
47+ C = PeriodicVector (
48+ [
49+ randn (T, spec. mps_virtualspaces[2 ] ← spec. mps_virtualspaces[2 ]),
50+ randn (T, spec. mps_virtualspaces[3 ] ← spec. mps_virtualspaces[3 ]),
51+ ]
52+ )
53+ psi = InfiniteMPS {eltype(A), eltype(C)} (A, A, C, A)
3854
39- return MPSKit. MPO_AC2_Hamiltonian (GL, W1, W2, GR)
55+ GLs, GRs = MPSKit. initialize_environments (psi, H, psi)
56+ envs = MPSKit. InfiniteEnvironments (GLs, GRs)
57+
58+ return MPSKit. AC2_hamiltonian (1 , psi, H, psi, envs)
4059end
4160
4261function contraction_benchmark (spec:: AC2Spec ; T:: Type = Float64)
43- AA = randn (T, spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ] ⊗ spec. physicalspaces[2 ]' )
44- H_eff = MPSKit. MPO_AC2_Hamiltonian (spec; T)
45- H_prep, x_prep = MPSKit. prepare_operator!! (H_eff, AA)
46- init () = randn! (similar (x_prep))
47-
48- return @benchmarkable $ H_prep * x setup = (x = $ init ())
62+ V = spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ] ⊗ spec. physicalspaces[2 ]'
63+ H_eff = MPSKit. AC2_hamiltonian (spec; T)
64+ return @benchmarkable $ H_eff * x setup = x = randn ($ T, $ V)
4965end
5066
5167function preparation_benchmark (spec:: AC2Spec ; T:: Type = Float64)
52- init () = randn (T, spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ] ⊗ spec. physicalspaces[2 ]' )
53- H_eff = MPSKit. MPO_AC2_Hamiltonian (spec; T)
68+ V = spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ] ⊗ spec. physicalspaces[2 ]'
69+ H_eff = MPSKit. AC2_hamiltonian (spec; T)
70+ return @benchmarkable MPSKit. prepare_operator!! ($ H_eff)
71+ end
5472
55- return @benchmarkable begin
56- O′, x′ = MPSKit. prepare_operator!! ($ H_eff, x)
57- y = MPSKit. unprepare_operator!! (x′, O′, x)
58- end setup = (x = $ init ())
73+ function prepared_benchmark (spec:: AC2Spec ; T:: Type = Float64)
74+ V = spec. mps_virtualspaces[1 ] ⊗ spec. physicalspaces[1 ] ← spec. mps_virtualspaces[3 ] ⊗ spec. physicalspaces[2 ]'
75+ H_eff = MPSKit. AC2_hamiltonian (spec; T)
76+ H_prep = MPSKit. prepare_operator!! (H_eff)
77+ return @benchmarkable $ H_prep * x setup = x = randn ($ T, $ V)
5978end
6079
6180# Converters
0 commit comments