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.
Short Description
This PR reverts part of #2280 and restores the ability of
frac
to handle zero occupation number. At the cost of storing extra C matrices, this fixes a pre-#2280 bug in the handling of zero occupation number. Closes #2284.Long Description
The
frac
code is designed to allow SCF with fractional occupation numbers. Physically, this is an ensemble of Slater determinants, where the probabilities of a given orbital being occupied are uncorrelated. This is implemented by changing the C matrix from meaning "thing that contains orbitals" to "thing that produces the density", and incorporating the occupation numbers into the definition of the C matrix by multiplying by the occupation numbers. These are divided out after SCF to restore the original meaning of C.Now, in the case of zero occupation number, multiplying by zero cannot be inverted, so the pre-#2280 code just left the orbitals. This is nonsense behavior, and #2280 banned the case of zero occupation number: the orbital should never have been included in
frac
in the first place if your use case was to describe a single ensemble. What I didn't realize was that there were legitimate use cases for this: if you had multiple ensembles and wanted to track what happens as the occupation number of one goes to zero. This is used byfrac_traverse
, so I broke the test. This slipped through the cracks because the test wasn't labeled as a frac test.This PR allows frac to treat zero occupation number, and it corrects the previous pathological handling of the C matrix with zero occupation number by changing how we generate the restored C matrix: instead of inverting multiplication, we store the matrix where we never multiplied obitals by occupation numbers in the first place. This change keeps the symmetry fixes of #2280.
Checklist
Status