Skip to content

Conversation

@JonathonMisiewicz
Copy link
Contributor

Description

#2476 and #2594 indicate a major problem in Psi's SCF code: the simplistic formula nalphapi = doccpi + soccpi and nbetapi = doccpi is incapable of describing references where there are more beta than alpha orbitals of a given irrep. This occurs in MOM (where we instead use ugly hacks) and in UHF (where we crash). Furthermore, storing all of these irrep quantities is redundant.

This PR remedies the situation by only storing nalphapi and nbetapi. doccpi and soccpi can be computed from these when needed. The Py-side API is unchanged doccpi(), soccpi(), while the C-side API changes from doccpi_, soccpi_ to doccpi(), soccpi(). While we are doing some extra work to compute docc and socc every time they're needed, the computational cost is negligible in comparison to Fock diagonalizations, integral transforms, and tensor contractions.

To prevent scope creep, this PR aims solely to change the wavefunction. This is a major undertaking and should not be done lightly. A subsequent PR will fix the linked issues (if not fixed by this PR) and add them as test cases once the fix is confirmed.

Obligatory @susilehtola ping.

Todos

  • DOCC and SOCC are now computed rather than stored
  • MOM simplified
  • Lots of docc/socc replaced with alphapi/betapi where more appropriate
  • More auto
  • More dimension, fewer raw arrays

Checklist

  • Passes ctest and pytest (all, except addons)

Status

  • Ready for review
  • Ready for merge

@JonathonMisiewicz JonathonMisiewicz added wavefunction For issues that are on the wavefunction itself. cleanup For issues where the goal is to make Psi4 a little cleaner. labels Jun 21, 2022
@JonathonMisiewicz
Copy link
Contributor Author

Eco failure is, quite predictably, because it breaks v2rdm.

@JonathonMisiewicz
Copy link
Contributor Author

After discussion with Lori, work on getting this PR through will resume after MQM. We also have a plan to deal with plugin incompatibilities.

Feel free to review earlier if you wish.

@JonathonMisiewicz JonathonMisiewicz force-pushed the cleanup branch 2 times, most recently from e9760c7 to 673acfc Compare July 11, 2022 18:30
@JonathonMisiewicz JonathonMisiewicz added this to the Psi4 1.7 milestone Jul 12, 2022
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.

quite an undertaking, lgtm!

@JonathonMisiewicz
Copy link
Contributor Author

@susilehtola There was a request among core devs for you to sign off on this PR before we get a third review.

nalpha_ = doccpi_.sum() + soccpi_.sum();
nbeta_ = doccpi_.sum();
nalpha_ = nalphapi_.sum();
nbeta_ = nbetapi_.sum();
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there be a spin state check here?

Copy link
Contributor Author

@JonathonMisiewicz JonathonMisiewicz Aug 4, 2022

Choose a reason for hiding this comment

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

I don't know. The force functions are marked as intended for expert use only because careless use can produce inconsistencies. Nothing in Psi uses them. I can't tell whether the potential to cause a spin state violation is a bug or a feature. Maybe a warning is in order if the number of unpaired electrons changes?

Copy link
Member

Choose a reason for hiding this comment

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

OK, in that case we can forget about it

Copy link
Member

Choose a reason for hiding this comment

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

Actually... I think the force functions may break with these changes, since socc and docc are recomputed. One would have to override socc and docc simultaneously lest the occupations be changed in the other code.

Copy link
Member

Choose a reason for hiding this comment

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

I would remove the force functions altogether, since it sounds like they aren't even used..

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give that a look. Do we have FockCI test coverage?

possibly not, 😳 . She was working on two plugins, old and new. It was near a psi release, and I got very confused and packaged the wrong one. She added https://github.com/psi4/psi4/blob/master/doc/sphinxman/source/plugin_psi4fockci.rst though, so the internal build and that input might work.

What does "internal build" mean?

Copy link
Member

Choose a reason for hiding this comment

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

toggle ENABLE_psi4fockci=ON in <objdir>/CMakeCache.txt and rebuild. hopefully cmake will pull a copy and install it into stage/ so it's ready to run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@loriab It doesn't look like FockCI has any tests registered with Psi. Am I mistaken?

Copy link
Member

Choose a reason for hiding this comment

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

@JonathonMisiewicz
Copy link
Contributor Author

FYI, I'm in the process of revising the PR and am marking comment as resolved as I fix them locally.

@JonathonMisiewicz
Copy link
Contributor Author

All comments except FockCI testing addressed.

@JonathonMisiewicz
Copy link
Contributor Author

@susilehtola Comments added.

Per discussion with @loriab , I'll leave a comment on the FockCI repo letting them know about this API-breaking change. It sounds like that repo has its own issues that need to be dealt with, beyond the scope of this PR.

@susilehtola
Copy link
Member

@JonathonMisiewicz as far as I can see, this should be OK now except the one wrong printout above.

Copy link
Contributor

@zachglick zachglick left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for working on this. Any reason for not adding a test or two?

@JonathonMisiewicz
Copy link
Contributor Author

LGTM, thanks for working on this. Any reason for not adding a test or two?

No tests came to mind as worth adding. If you have suggestions, I'll probably take them.

@zachglick
Copy link
Contributor

No suggestions, merge when ready.

@JonathonMisiewicz JonathonMisiewicz merged commit e817142 into psi4:master Aug 10, 2022
@JonathonMisiewicz JonathonMisiewicz deleted the cleanup branch August 10, 2022 17:11
@JonathonMisiewicz
Copy link
Contributor Author

PRd to FockCI, so I can wash my hands of the force_.occpi changes.

@susilehtola
Copy link
Member

LGTM, thanks for working on this. Any reason for not adding a test or two?

No tests came to mind as worth adding. If you have suggestions, I'll probably take them.

Any one of the various failing SCF calculations where occupations break old invalid assumptions?

@JonathonMisiewicz
Copy link
Contributor Author

A subsequent PR will fix the linked issues (if not fixed by this PR) and add them as test cases once the fix is confirmed.

On my to-do list, I just wasn't confident those would already be fixed by this PR. Thanks for the reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup For issues where the goal is to make Psi4 a little cleaner. wavefunction For issues that are on the wavefunction itself.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants