Corrected serious error in calcAcNonLocal

For values near the band edges, the discriminat under the root
which gives ktilde can be negative due to numerical inaccuracies.
Beside the wrong results, the resulting NaN could led a segfault
at a later time.

Updated longrange case in heisenberg.cpp