Problems with add_local_term and H.c

General discussions on the ideas behind the algorithm.
Post Reply
Fabio_Mendez
Posts: 4
Joined: 01 Feb 2022, 01:50

Problems with add_local_term and H.c

Post by Fabio_Mendez »

Hi,
I'm trying to decrease the number of terms appearing in the Hamiltonian MPO by using H. c. in add_coupling_term. However, when I use plus_hc I always get an error. I have tried this with different models, and I get the same error. I provide an example below.
I have a ladder of SpinHalfFermions on a Chain lattice with the following hopping coupling terms:
self.add_local_term(-adj_mat[i, j], [('Cdu', (i, 0)), ('Cu', (j, 0))])
self.add_local_term(adj_mat[i, j], [('Cu', (i, 0)), ('Cdu', (j, 0))])
self.add_local_term(-adj_mat[i, j], [('Cdd', (i, 0)), ('Cd', (j, 0))])
self.add_local_term(adj_mat[i, j], [('Cd', (i, 0)), ('Cdd', (j, 0))])
This case works without any problem. However, when I change to:
self.add_local_term(-adj_mat[i, j], [('Cdu', (i, 0)), ('Cu', (j, 0))],plus_hc=True)
self.add_local_term(adj_mat[i, j], [('Cd', (i, 0)), ('Cdd', (j, 0))],plus_hc=True)
I receive the error:
IndexError: tuple index out of range
Am I doing something wrong?

F. P. M. Méndez-Cordoba.
User avatar
Johannes
Site Admin
Posts: 413
Joined: 21 Jul 2018, 12:52
Location: TU Munich

Re: Problems with add_local_term and H.c

Post by Johannes »

This case wasn't tested properly, so a bug could sneak in...
I've just fixed it in 72f79cce1f7dd04607027322763db2a6b80466e3 and added proper tests.

The index error indicates that you didn't actually set the option explicit_plus_hc=True, otherwise it would not have occured...
You need to do that as well to actually save MPO bond dimension.

PS: for the future, questions like this should probably go into the HowTo section...
Post Reply