Skip to content

Conversation

davpoolechem
Copy link
Contributor

@davpoolechem davpoolechem commented Jun 9, 2023

Description

Currently, COSX in Psi4 uses a two-grid scheme to complete the SCF - the SCF is first converged on a smaller grid, and then a single iteration is performed on a larger grid, a scheme proposed by Neese. This scheme works quite well for energies; but since the SCF isn't converged on the larger grid, it may not be as ideal if wavefunction properties (e.g., gradients) are desired.

This PR fixes that by adding a new keyword, COSX_MAXITER_FINAL, an integer that determines the maximum number of SCF iterations to run on the final COSX grid. By default, this keyword is set to 1, mimicking the current behavior of the code. A more detailed description of behavior can be broken down as follows:

  • If COSX_MAXITER_FINAL < 0; the SCF will attempt to fully converge on the final COSX grid (within the constraints provided by MAXITER, of course).
  • If COSX_MAXITER_FINAL == 0; the SCF will not run on the final grid at all, effectively turning the COSX algorithm into a single-grid implementation.
  • If COSX_MAXITER_FINAL > 0; the SCF will run on the final grid for a maximum number of iterations specified by the keyword.
    • If the SCF converges on the final grid before the iteration count specified by COSX_MAXITER_FINAL, the SCF will exit upon convergence.
    • If the iteration count specified by COSX_MAXITER_FINAL is reached before the SCF is converged on the final grid, the SCF will exit, treated as a success.
    • If the MAXITER SCF iteration limit is hit before the COSX_MAXITER_FINAL limit is reached, the calculation will fail.

Also of note, this PR changes CompositeJK so that early_screening is disabled for LinK-based composite methods. Practically, this means that LinK-based methods do not run the extra post-early-screening SCF iteration that is present in COSX-based methods.

User API & Changelog headlines

  • Adds a new keyword, COSX_MAXITER_FINAL, for controlling the maximum number of SCF iterations to run on the final COSX grid.

Dev notes & details

  • Adds a new keyword, COSX_MAXITER_FINAL, for controlling the maximum number of SCF iterations to run on the final COSX grid. The keyword can be used to run a preset number of SCF iterations or fully converge the SCF on the final grid, or to skip the final grid entirely.
  • Changes the early screening feature so that it is only turned on for COSX-based composite methods.

Questions

  • N/A

Checklist

Status

  • Ready for review
  • Ready for merge

@davpoolechem davpoolechem force-pushed the dpoole34/cosx-full-conv branch from d381344 to 4259de1 Compare June 9, 2023 18:03
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.

nice additional flexibility

@@ -1681,6 +1681,8 @@ int read_options(const std::string &name, Options &options, bool suppress_printi
options.add_int("COSX_RADIAL_POINTS_FINAL", 35);
/*- Screening criteria for integrals and intermediates in COSX -*/
options.add_double("COSX_INTS_TOLERANCE", 1.0E-11);
/*- Maximum number of SCF iterations to run on on larger (i.e., final) COSX grid -*/
Copy link
Member

Choose a reason for hiding this comment

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

Maybe be more expansive about the >1, ==1, ==0, <0 values here since this is what gets slurped for the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's fair, since COSX_MAXITER_FINAL is a bit more complex than it appears at a first glance. I will do so!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also done! Hopefully, the new description in the code makes sense.

@@ -270,13 +270,16 @@ def scf_iterate(self, e_conv=None, d_conv=None):

# does the JK algorithm use severe screening approximations for early SCF iterations?
early_screening = self.jk().get_early_screening()
# maximum number of scf iterations to run after early screening is disabled
scf_maxiter_post_screening = core.get_option('SCF', 'COSX_MAXITER_FINAL')
Copy link
Member

Choose a reason for hiding this comment

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

Is there any practical difference between cosx_maxiter_final == -1 and -10? If the total total limit is still controlled by SCF_MAXITER, then no? If that's the case, maybe only allow -1.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, there is no difference between -1 and -10 (or any other negative number) for COSX_MAXITER_FINAL. I will change this as you suggested!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done!

@loriab loriab added this to the Psi4 1.9 milestone Jun 17, 2023
@loriab loriab added the scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF... label Jun 17, 2023
@davpoolechem davpoolechem force-pushed the dpoole34/cosx-full-conv branch from 4259de1 to a7931b8 Compare June 20, 2023 13:03
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.

See if you like the proposed changes.

David Poole and others added 3 commits June 20, 2023 13:38
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
Co-authored-by: Lori A. Burns <lori.burns@gmail.com>
@davpoolechem
Copy link
Contributor Author

See if you like the proposed changes.

I do! I accepted all of them. Thank you for the suggestions!

@jturney jturney added this pull request to the merge queue Jun 22, 2023
Merged via the queue into psi4:master with commit d536aa3 Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants