I'm trying to calculate the entanglement entropy of an Ising spin chain but I'm having trouble getting consistent results from the calculation. I think I should see an entropy of order ln2 when the interaction parameter (lambda) is large, since the ground state is 2-fold degenerate. However, I see only small entropies in most cases and sometimes (inconsistently) something of order ln2. I've tried changing the sweep parameters, which seems to change the results but doesn't give me something consistent. The energy is stable with the sweep parameters, but the entanglement entropy isn't. I think I'm calculating it incorrectly, or my idea that it should be ln2 is incorrect. I've also tried larger chains, up to N=200.

I've uploaded my code below. It prints the interaction parameter, followed by the entropy and the ground and first excited states.

https://pastebin.com/uGqFmRZ5