Skip to content

CompositeJK Bonus: J-Only SCF_TYPE Specification for DFT - #3001

Merged
loriab merged 12 commits into
psi4:masterfrom
davpoolechem:dpoole34/compositejk-scftype
Jul 10, 2023
Merged

loriab merged 12 commits into
psi4:masterfrom
davpoolechem:dpoole34/compositejk-scftype

Conversation

@davpoolechem

@davpoolechem davpoolechem commented Jul 3, 2023 •

Copy link
Copy Markdown
Contributor

Description

The idea here was suggested by @CDSherrill, and implemented in this PR.

What is this "idea"? Currently, CompositeJK methods are accessed through SCF_TYPE options of the form J_algo+K_algo, with J_algo and K_algo being the respective composite J and K build algorithms to be used for the calculation. Meanwhile, one notable benefit of the CompositeJK class is that, for DFT calculations that use non-hybrid functionals, composite methods can be used to specify an algorithm specifically optimized for J matrix construction, in contrast to general algorithms which need to also account for the K matrix. Since non-hybrid DFT calculations only require the J matrix, CompositeJK can lead to speedups in such cases. But in those cases where only the J algorithm is needed, the current SCF_TYPE specification for CompositeJK has a problem - the composite K algorithm that must be specified, is unnecessary and unused.

This PR allows for the specification of CompositeJK algorithms via only the J algorithm for cases such as non-hybrid DFT, where only the J matrix is needed. If CompositeJK is called without a K algorithm in cases where a K algorithm is needed, such as HF or hybrid DFT, an exception is thrown. Additionally, if the J_algo+K_algo SCF_TYPE specification for CompositeJK is used in conjunction with a non-hybrid functional, a note is given to the user, letting them know that the K algorithm won't be used.

User API & Changelog headlines

  • Adds a new SCF_TYPE option, DFDIRJ, for usage in non-hybrid DFT calculations.

Dev notes & details

  • Adjusts the CompositeJK class so that it can be called and used with only the J algorithm as the SCF_TYPE keyword. This can be useful in non-hybrid DFT calculations, where the K matrix is unnecessary.
  • If only a J algorithm is specified in cases where a K matrix is required, the code throws an exception.
  • If the old CompositeJK SCF_TYPE notation is used when the K matrix is not required, a note is given to the user.

Questions

  • N/A

Checklist

Status

  • Ready for review
  • Ready for merge

@davpoolechem
davpoolechem marked this pull request as ready for review July 3, 2023 13:13
@davpoolechem
davpoolechem force-pushed the dpoole34/compositejk-scftype branch from b606940 to 07ee3ba Compare July 3, 2023 17:02

@loriab loriab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is real trouble if a K-needing method doesn't get a K, maybe add a test of scf_type=dfdirj parametrized over BP86 and B3LYP that checks that the former runs and the latter errors informatively.

Comment thread psi4/src/psi4/libfock/jk.cc Outdated
Comment on lines +74 to +75
bool is_composite = jk_type.find("+") != std::string::npos; // does SCF_TYPE contain +?
is_composite = is_composite || options.get_str("SCF_TYPE") == "DFDIRJ"; // is SCF_TYPE equal to DFDIRJ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is starting to look piecemeal. Is there a clean c++ for is_composite = any([piece in options.get_str("SCF_TYPE") for piece in {"DFDIRJ", "COSX", "LINK"}])

@davpoolechem davpoolechem Jul 3, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just added a new implementation for is_composite that uses std::any_of to handle it more elegantly! It will technically evaluate true if SCF_TYPE is set to COSX or LINK (i.e., without DFDIRJ in front of it), but those are never accessible options via SCF_TYPE normally anyway. Still worth testing for those cases, too, to make sure the code throws right.

Comment thread psi4/src/psi4/libfock/CompositeJK.cc Resolved
@davpoolechem

Copy link
Copy Markdown
Contributor Author

Since this is real trouble if a K-needing method doesn't get a K, maybe add a test of scf_type=dfdirj parametrized over BP86 and B3LYP that checks that the former runs and the latter errors informatively.

Yeah, I can do that!

@hokru

hokru commented Jul 3, 2023

Copy link
Copy Markdown
Member

This is great! Another big advantage is that one can use the smaller J fitting basis sets (def2-universal-JFIT) as default like other QC programs and save memory (plus a small speed up). Don't want to feature creep this PR though :)

@davpoolechem
davpoolechem force-pushed the dpoole34/compositejk-scftype branch from 5136adb to ca7df3a Compare July 10, 2023 14:13

@loriab loriab left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks for the extra tests!

@loriab loriab added this to the Psi4 1.9 milestone Jul 10, 2023
@davpoolechem

Copy link
Copy Markdown
Contributor Author

thanks for the extra tests!

You're welcome! I think the new tests should be good to go now.

This is great! Another big advantage is that one can use the smaller J fitting basis sets (def2-universal-JFIT) as default like other QC programs and save memory (plus a small speed up). Don't want to feature creep this PR though :)

Thank you! What you describe should already be doable in Psi4 v1.8. This PR just makes the specification of SCF_TYPE for such uses, cleaner and more sensible.

@loriab
loriab added this pull request to the merge queue Jul 10, 2023
Merged via the queue into psi4:master with commit eed5177 Jul 10, 2023
@davpoolechem davpoolechem mentioned this pull request Nov 16, 2023
7 of 8 tasks
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.

4 participants