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

Orbitals should be multiplied by sqrt(occ) not occ #3138

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

susilehtola
Copy link
Member

Description

Fixes a bug in sad.cc: pseudo-orbitals should be obtained by multiplying the orbital with the square root of their occupation to reproduce the correct density matrix C occ C^T.

Closes #3137.

User API & Changelog headlines

  • RN 1
  • RN 2

Dev notes & details

  • Feature1
  • Feature2

Questions

  • Question1

Checklist

Status

  • Ready for review
  • Ready for merge

Copy link
Contributor

@TiborGY TiborGY left a comment

Choose a reason for hiding this comment

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

Would it be possible to add a test that fails before but passes after this change? Clearly there is a testing gap, given how long this bug has been present, and how something like this can be changed without having to change any of tests.

@susilehtola
Copy link
Member Author

Yes, by testing the guess energy for H atom.

@susilehtola
Copy link
Member Author

Looks like there are some unrelated test failures, but this one is ready to go. As shown by the changes in the pytest guess energies, the new code reaches a considerably lower SAD guess energy for the HF molecule: -100.02909951427 vs -99.63941801281894. Large improvements are expected especially for systems containing hydrogen atoms, since the existing code only includes 0.5 electrons on those atoms.

"sap": -99.50144270485751,
"core": -88.99202896495,
"gwh": -94.35585144645,
"sad": -99.34836107817,
Copy link
Member

Choose a reason for hiding this comment

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

Is it a concern that with the change SAD UHF & ROHF (and often sadno, *huckel) guess energies are less deep?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, the issue is that the test here is FH+, which has orbitals that are more compact than the neutral FH. It is logical that the proper guess for the neutral molecule yields a slightly higher energy for the cation.

Like I mention above, right now the SAD code is placing $n_i^2$ electrons on each orbital that should have a fractional occupation of $n_i$. For hydrogen this means that currently the guess has 0.5 electrons for the hydrogen atom, whereas fluorine probably has 7 electrons distributed evenly on 4 spatial orbitals [no symmetry, this is the key feature in the OpenOrbitalOptimizer guess in #3136] which means that its number of electrons is also wrong by -0.875. Therefore, the current guess is spuriously good for FH+ as it corresponds to a cation with charge 1.375.

@susilehtola susilehtola force-pushed the fix_sad_occ branch 2 times, most recently from 14c9a6f to dc01cc9 Compare June 14, 2024 09:22
@susilehtola susilehtola added this pull request to the merge queue Jun 14, 2024
@susilehtola susilehtola removed this pull request from the merge queue due to a manual request Jun 14, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jun 14, 2024
* Orbitals should be multiplied by sqrt(occ) not occ, since otherwise the density matrix becomes C occ^2 C^T.

* Update pytest reference values

* Update number of screened shells based on SAD guess

* Specify occupation in large atoms test

* Increase gradient test tolerance due to very small mismatch

* clang-format

* Relax test criteria due to small failures

* Update test variable to remove deprecation warning

* SAD guess energy check is for SAD energy not first variational energy

* There is a 1e-7 change to the orbital energy in the HF/DZ test on SH2.

* Wave function needs to be converged more tightly for test to pass

* Increase test limit

* Bump tolerance also for other gradient tests
Copy link
Contributor

@andyj10224 andyj10224 left a comment

Choose a reason for hiding this comment

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

LGTM! Anything holding this PR up from merging?

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.

Potential bug in sad.cc: definition of pseudo-orbitals
6 participants