Error: "operator does not appear to be hermitian"

Hi ITensors team,
I have a simple Hamiltonian on “Fermion” type sites. But when I try to use the dmrg method I get an error message which is a little strange to me.

N = 4
sites = siteinds("Fermion",N)
ampo = OpSum()
for j in 1:N-1
    ampo += 1im,"C",j,"C",j+1
    ampo += -1im,"Cdag",j,"Cdag",j+1
end
H = MPO(ampo, sites)
psi0 = randomMPS(sites,10)
sweep = Sweeps(3)
setmaxdim!(sweep, 10,10,20)
setcutoff!(sweep,1E-10)
energy, psi = dmrg(H,psi0,sweep)

“operator does not appear to be hermitian: 0.07191559895344718 vs 0.07191559895344718”

How could I fix this error?

Thanks

In this case, the error is coming from the KrylovKit library that ITensor calls to solve Hermitian eigenvalue problems (this is inside the ‘core’ step of DMRG). The reason you are getting this error is that your H is not Hermitian. Here is how to define it so that it is Hermitian:

ampo = OpSum()
for j in 1:N-1
    ampo += 1im,"C",j,"C",j+1
    ampo += -1im,"Cdag",j+1,"Cdag",j
end

I believe you forgot to permute the order of the operators when taking the Hermitian conjugate of the first term to obtain the second term.

1 Like

What a waste of time!
I’ve been working on it for about two days!
You’re right, I’ve forgotten to permute the order of operators. Your solution works very well.

Thank you so much

1 Like