Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0 Frac Occupancy #2290

Merged
merged 1 commit into from
Sep 10, 2021
Merged

Fix 0 Frac Occupancy #2290

merged 1 commit into from
Sep 10, 2021

Conversation

JonathonMisiewicz
Copy link
Contributor

@JonathonMisiewicz JonathonMisiewicz commented Sep 3, 2021

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 by frac_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

  • frac tests pass

Status

  • Ready for review
  • Ready for merge

Copy link
Member

@loriab loriab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the exposition on the PR -- it helped me considerably.

if (val < 0.0)
throw PSIEXCEPTION(
"Fractional Occupation SCF: Psi4 is not configured for positrons. Please annihilate and start "
"again");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked this errormsg.

Copy link
Contributor

@fevangelista fevangelista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! Very helpful explanations and nice streamlining of the code.

@JonathonMisiewicz JonathonMisiewicz merged commit d96c2ae into psi4:master Sep 10, 2021
@loriab loriab added this to the Psi4 1.5 milestone Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

frac_traverse broken
4 participants