The sparse eigenvalue solver uses "shift-invert" mode to find the eigenvalues closest to zero. This involves solving for shifted eigenvalues w' = 1.0 / (w - s), where w are the original eigenvalues and s is the shift. We use zero for the shift, which causes a division by 0 when an eigenvalue is exactly 0, which isn't that rare.
This is something that the user can work around, usually by adding a constant term onto the input Hamiltonian - the dynamics aren't changed by a global phase rotation. That's not a particularly satisfying solution, though. Dense matrix algebra is immune to this problem, because the routines are far more robust, and safely calculate all the eigenvalues. This is impractical for large matrices.
Because the error happens inside the ARPACK routines, there is no ZeroDivisionError to be caught. The code throws a RuntimeError, but the entire routine fails and there seems to be no way to recover the other eigenvalues.
The sparse eigenvalue solver uses "shift-invert" mode to find the eigenvalues closest to zero. This involves solving for shifted eigenvalues
w' = 1.0 / (w - s), whereware the original eigenvalues andsis the shift. We use zero for the shift, which causes a division by 0 when an eigenvalue is exactly 0, which isn't that rare.This is something that the user can work around, usually by adding a constant term onto the input Hamiltonian - the dynamics aren't changed by a global phase rotation. That's not a particularly satisfying solution, though. Dense matrix algebra is immune to this problem, because the routines are far more robust, and safely calculate all the eigenvalues. This is impractical for large matrices.
Because the error happens inside the ARPACK routines, there is no
ZeroDivisionErrorto be caught. The code throws aRuntimeError, but the entire routine fails and there seems to be no way to recover the other eigenvalues.