Skip to content

Conversation

Awallace3
Copy link
Contributor

@Awallace3 Awallace3 commented Dec 16, 2024

Description

Previously, SAPT(DFT) scf_helper() calls would re-compute integrals for SAPT0 dimer and monomer computations. Furthermore, the DFT scf_helper() calls would also recompute 3-index integrals by regenerating the JK-object. This PR enables developers to pass in a jk object to scf_helper to not re-compute 3-index DF integrals if desired. This change was largely drafted during a meeting between @cdsgroup with @konpat on Dec. 13th, 2024. Further tested in a 7 Feb 2025 meetup.

closes #3173

User API & Changelog headlines

  • SAPT(DFT) and SAPT(HF) computations will be faster through re-using integrals on SCF's

Dev notes & details

  • Added kwargs option of passing a JK-object to scf_helper() to prevent re-computing integrals for SCF.

Questions

  • Question1

Checklist

Status

  • Ready for review
  • Ready for merge

@JonathonMisiewicz
Copy link
Contributor

Is this ready for review? If so, please check "Ready for review" in the front page. If not, please mark this PR as a draft.

@Awallace3
Copy link
Contributor Author

Is this ready for review? If so, please check "Ready for review" in the front page. If not, please mark this PR as a draft.

Yes, it is ready for review. Thank you for letting me know that I needed to check that box.

@@ -541,7 +549,7 @@ def run_sf_sapt(name, **kwargs):
core.IO.set_default_namespace('dimer')
data = {}

if (core.get_global_option('SCF_TYPE') == 'DF'):
if (core.get_global_option('SCF_TYPE') == 'DISK_DF'):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this and only this specific to DISK_DF?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch seeing this in another function. I have corrected this to match the other sections of the code.

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.

Looks good! @Awallace3 can you look at my comment regarding the DF_INTS_IO option? (See https://github.com/psi4/psi4/blob/master/psi4/src/psi4/libfock/jk.cc#L239)
The best way to test this is to make sure that MemDF will still run when JK is reused.

# We want to try to re-use itegrals for the dimer and monomer SCF's.
# If we are using Disk based DF (DISK_DF) then we can use the
# DF_INTS_IO option. MemDF does not know about this option but setting
# it will be harmless there.
core.set_global_option('DF_INTS_IO', 'SAVE')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you double check that setting this does not change the DF algorithm to DiskDF? In the options docs for DF_INTS_IO it says IO caching for CP corrections, etc. Changing this selects Disk_DF over Mem_DF. Note that setting this forces DiskDFJK when SCF_TYPE=DF.

(see https://github.com/psi4/psi4/blob/master/psi4/src/read_options.cc#L1674)

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.

Thanks for addressing my concerns! LGTM!

@Awallace3
Copy link
Contributor Author

Thanks for addressing my concerns! LGTM!

Thanks Andy! Your careful consideration helped remove some undesirable functionality of DF_INTS_IO when trying to prefer MemDF over DiskDF in the SAPT(DFT) code (when applicable).

@loriab loriab added this to the Psi4 1.10 milestone Feb 14, 2025
@loriab loriab added scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF... sapt For issues about SAPT and its many flavors. labels Feb 14, 2025
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 getting this sorted out! A local full tests is clean (Austin, the failure I mentioned seeing was due to unrelated local edits).

@@ -237,22 +237,16 @@ std::shared_ptr<JK> JK::build_JK(std::shared_ptr<BasisSet> primary, std::shared_
Options& options, bool do_wK, size_t doubles) {
std::string jk_type = options.get_str("SCF_TYPE");
if (jk_type == "DF") {
// logic for MemDFJK vs DiskDFJK
if (options["DF_INTS_IO"].has_changed()) {
Copy link
Member

Choose a reason for hiding this comment

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

For reference, the old behavior of touching DF_INTS_IO forces DISK_DF was a deliberate change made here
2b53daa that seems non-intuitive in retrospect.

@loriab loriab added this pull request to the merge queue Feb 14, 2025
Merged via the queue into psi4:master with commit cda088e Feb 14, 2025
5 of 6 checks passed
@loriab loriab mentioned this pull request Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sapt For issues about SAPT and its many flavors. scf Involves general SCF: convergence algorithms, RHF/UHF/ROHF/CUHF...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants