Skip to content

Commit fbe1aff

Browse files
Revert "remove all square-forcing code"
This reverts commit bc37174.
1 parent dd33988 commit fbe1aff

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/algorithms/timestep/timeevmpo.jl

+24-3
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,38 @@ function make_time_mpo(H::MPOHamiltonian, dt::Number, alg::TaylorCluster;
5959
N = alg.N
6060
τ = -1im * dt
6161

62+
# Hack to store FiniteMPOhamiltonians in "square" MPO tensors
63+
if H isa FiniteMPOHamiltonian
64+
H′ = copy(H)
65+
H′[1] = similar(H[2])
66+
H′[end] = similar(H[end - 1])
67+
68+
for i in nonzero_keys(H[1])
69+
H′[1][i] = H[1][i]
70+
end
71+
for i in nonzero_keys(H[end])
72+
H′[end][:, 1, 1, end] = H[end][:, 1, 1, 1]
73+
end
74+
H′[1][end, 1, 1, end] += add_util_leg(id(space(H[1][end, 1, 1, end], 2)))
75+
H′[end][1, 1, 1, 1] += add_util_leg(id(space(H[end][1, 1, 1, 1], 2)))
76+
else
77+
H′ = H
78+
end
79+
80+
# Check if mpo has the same size everywhere. This is assumed in the following.
81+
@assert allequal(size.(H′)) "make_time_mpo assumes all mpo tensors to have equal size. A fix for this is yet to be implemented"
82+
6283
# start with H^N
63-
H_n = H^N
64-
V = size(H[1], 1)
84+
H_n = H^N
85+
V = size(H[1], 1)
6586
linds = LinearIndices(ntuple(i -> V, N))
6687
cinds = CartesianIndices(linds)
6788

6889
# extension step: Algorithm 3
6990
# incorporate higher order terms
7091
# TODO: don't need to fully construct H_next...
7192
if alg.extension
72-
H_next = H_n * H
93+
H_next = H_n * H
7394
linds_next = LinearIndices(ntuple(i -> V, N + 1))
7495
for (i, slice) in enumerate(parent(H_n))
7596
for a in cinds, b in cinds

0 commit comments

Comments
 (0)