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 =
ITensor ord=4: (dim=2|id=213|"n=1,Site,S=1/2") (dim=2|id=213|"n=1,Site,S=1/2")' (dim=2|id=925|"l=1,Link") (dim=2|id=925|"l=1,Link")'
{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 =
ITensor ord=4: (dim=2|id=213|"n=1,Site,S=1/2")' (dim=2|id=925|"l=1,Link")' (dim=2|id=213|"n=1,Site,S=1/2") (dim=2|id=925|"l=1,Link")
{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