Improve sparse diagonalization routine #100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a fix for issue #98.
scipy
's sparse eigenvalue solver works better (both faster and more reliable) when fewer eigenvalues are requested, so this PR gives a better estimate for the lowest eigenvalue (for a given spin and quantum numberl
), when previously it was just 0 (creating problems for very low lying core states).The routines to find the eigenvalues now include a "guess" option which performs a full diagonalization of the Hamiltonian (finding all eigenvalues), on a much smaller number of grid points to obtain an initial estimate for the eigenvalues. The lowest eigenvalues are then fed into the sparse matrix diagonalization routine, making we can reduce significantly the number of eigenvalues requested (since before we were finding lots of eigenvalues with energies >0 which were mostly discarded). The full diagonalization is only performed for the first 3 SCF iterations, since after that the estimates should be accurate enough for the rest of the cycle.
Attached are some output files to demonstrate examples of when the old code failed compared to now when it works, and an example of a speed increase.
Al_new_no_error.txt
Al_new_faster.txt
Al_old_error.txt
Al_old_slow.txt