# Errors in the Ground-State Energy in a Next NN 1D Spin Chain

Hello,

I was trying to implement this very simple Hamiltonian:

\mathcal{H} = \sum_{i=1}^{N} \left[ J \;S^+_{2i-1} S^-_{2i+1} + g \; S^+_{2i} \left( S^x_{2i-1} + S^x_{2i+1} \right) + \text{h.c} \right]

When, I run the g=0 case, I would expect to simply get the ground state energy of an XX chain, which should be 2J/\pi. However, I do not get the correct result, not even in the N=2, where one should get E=-J.

I am using the folllowing code:

function XXZ(Ncells,J,g):

sites = siteinds("S=1/2",2*Ncells)
index = 0

os = OpSum()
for i in 1:Ncells-1
os += J,"S+",2*i-1,"S-",2*i+1
os += J,"S-",2*i-1,"S+",2*i+1
os += g,"Sx",2*i-1,"S+",2*i
os += g,"Sx",2*i-1,"S-",2*i
os += g,"S+",2*i,"Sx",2*i+1
os += g,"S-",2*i,"Sx",2*i+1
end

H = MPO(os,sites)
psi0 = randomMPS(sites)
nsweeps = 5
maxdim = [200,50]
cutoff = [1E-10]
energy, psi = dmrg(H,psi0; nsweeps, maxdim, cutoff)
return energy
end


Thank you.

Hello!
Just to add to previous post. I’ve noticed that I get two different results by either doing:

    sites = siteinds("S=1/2",3)
os = OpSum()
os .+= (J,"S+",1,"S-",2)
os .+= (J,"S-",1,"S+",2)


VS

    sites = siteinds("S=1/2",3)
os = OpSum()
os .+= (J,"S+",1,"S-",3)
os .+= (J,"S-",1,"S+",3)


Why should this make a difference?

Regarding your first question, it’s a little hard to say. Are the answers you are getting very different from the exact value or only a little different? Is the exact value for an infinite system? If so, you are simulating a finite-size system so there will be finite-size corrections that make the exact answer from DMRG different from the exact infinite answer. Just as importantly, your DMRG results may not be fully converged.

To diagnose which of the above possibilities could be happening, it’s good that you are considering smaller systems or systems where a completely exact, finite-size solution is known or computable, as you’re doing in your second post.

As to why in your second post you are getting different energies, it almost certainly has to be a lack of convergence of DMRG, since the Hamiltonians should have the same ground state energy. We have an FAQ page of the documentation that gives different ideas for how you can help a DMRG calculation to converge better:
https://itensor.github.io/ITensors.jl/dev/faq/DMRG.html
Some that might help you here are using the “noise” parameter (noise term) and trying different initial states.

By the way, the randomMPS function accepts a parameter linkdims which you can use to make an MPS with larger link or bond dimensions, like this:

psi0 = randomMPS(sites; linkdims=4)


Doing that might help you to have a more ‘general’ initial state which might lead to better convergence, among the other things mentioned in the FAQ.