@@ -59,17 +59,38 @@ function make_time_mpo(H::MPOHamiltonian, dt::Number, alg::TaylorCluster;
59
59
N = alg. N
60
60
τ = - 1im * dt
61
61
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
+
62
83
# 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 )
65
86
linds = LinearIndices (ntuple (i -> V, N))
66
87
cinds = CartesianIndices (linds)
67
88
68
89
# extension step: Algorithm 3
69
90
# incorporate higher order terms
70
91
# TODO : don't need to fully construct H_next...
71
92
if alg. extension
72
- H_next = H_n * H
93
+ H_next = H_n * H′
73
94
linds_next = LinearIndices (ntuple (i -> V, N + 1 ))
74
95
for (i, slice) in enumerate (parent (H_n))
75
96
for a in cinds, b in cinds
0 commit comments