# I think diagHermitian may not be working properly.

Here is some code that is essentially what I am doing. H is an XYZ model with different couplings in all directions. psi is the ground state of the Heisenberg model. N(L) = 4. NumCenter = 1 for the LocalMPO as well.

/* psi is ground state with QNs removed,
MaxDim=10. */
sites = SpinHalf(N);
auto ampo = AutoMPO(sites);
for(auto j : range1(N-1))
{
ampo += 0.5,"S+",j,"S-",j+1;
ampo += -0.5,"S-",j,"S+",j+1;
ampo += 0.317,"Sz",j,"Sz",j+1;
}
auto H = removeQNs(toMPO(ampo));
psi.position(1);
LocalMPO PH(H,*args);
PH.numCenter(1);
PH.position(1,psi);
auto R = PH.R();
auto Heff = PH.H()(1)*R;
ITensor d;
ITensor U;
diagHermitian(Heff,U,d);
auto res = U*d*prime(U);
PrintData(Heff);
PrintData(res);
auto dif = res - Heff;
PrintData(norm(dif));


The result for the printouts are

Heff =
{norm=0.69 (Dense Real)}
(1,1,1,1) -0.026417
(2,2,1,1) -0.170760
(1,2,2,1) -0.455342
(2,1,1,2) 0.4553418
(1,1,2,2) -0.170760
(2,2,2,2) -0.026417

res =
{norm=0.69 (Dense Real)}
(1,1,1,1) -0.026417
(2,1,2,1) -0.170760
(1,2,2,1) 0.4553418
(2,1,1,2) 0.4553418
(1,2,1,2) -0.170760
(2,2,2,2) -0.026417

norm(dif) = 0.910684


We see the error lies in the (1,2,2,1) element.

I've tried leaving QNs on the tensors, and different equivalent forms for res, and I'm not sure what's wrong here. Any help would be greatly appreciated.

Best,
Nick

+1 vote

Simple mistake, I used S+ and S- instead of Sx and Sy, and so my Hamiltonian was in fact not Hermitian. Fixing this solved the issue.

commented by (70.1k points)
Thanks for letting us know, and for posting the question