CompositeJK Part 3: SplitJK - #2955
Conversation
2249f36 to
16ebc0e
Compare
133d799 to
44297ec
Compare
| return esp_bound; | ||
| } | ||
|
|
||
| COSK::COSK(std::shared_ptr<BasisSet> primary, Options& options) : SplitJK(primary, options) { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::common_init() function.
| return num_computed_shells_; | ||
| } | ||
|
|
||
| void COSK::print_header() const { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::print_COSX_header() function.
| // build the K matrix using Neeses's Chain-of-Spheres Exchange algorithm | ||
| // algorithm is originally proposed in https://doi.org/10.1016/j.chemphys.2008.10.036 | ||
| // overlap fitting is discussed in https://doi.org/10.1063/1.3646921 | ||
| void COSK::build_G_component(std::vector<std::shared_ptr<Matrix>>& D, std::vector<std::shared_ptr<Matrix>>& K, |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::build_COSK() function.
|
|
||
| namespace psi { | ||
|
|
||
| DirectDFJ::DirectDFJ(std::shared_ptr<BasisSet> primary, std::shared_ptr<BasisSet> auxiliary, Options& options) : SplitJK(primary, options), auxiliary_(auxiliary) { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::common_init() function.
| return num_computed_shells_; | ||
| } | ||
|
|
||
| void DirectDFJ::print_header() const { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::print_DirectDFJ_header() function.
|
|
||
| // build the J matrix using Weigend's integral-direct density fitting algorithm | ||
| // algorithm is in Figure 1 of https://doi.org/10.1039/B204199P | ||
| void DirectDFJ::build_G_component(std::vector<std::shared_ptr<Matrix>>& D, std::vector<std::shared_ptr<Matrix>>& J, |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::build_DirectDFJ() function.
|
|
||
| namespace psi { | ||
|
|
||
| LinK::LinK(std::shared_ptr<BasisSet> primary, Options& options) : SplitJK(primary, options) { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::common_init() function.
| return num_computed_shells_; | ||
| } | ||
|
|
||
| void LinK::print_header() const { |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::print_linK_header() function.
|
|
||
| // build the K matrix using Ochsenfelds's Linear Exchange (LinK) algorithm | ||
| // To follow this code, compare with figure 1 of DOI: 10.1063/1.476741 | ||
| void LinK::build_G_component(std::vector<std::shared_ptr<Matrix>>& D, std::vector<std::shared_ptr<Matrix>>& K, |
There was a problem hiding this comment.
Machinery pulled from the previous CompositeJK::build_linK() function.
| // Is the JK currently on the first SCF iteration of this SCF cycle? | ||
| bool initial_iteration_ = true; | ||
|
|
||
| // => Density Fitting Stuff, for Direct DF-J <= // |
There was a problem hiding this comment.
Moved to respective SplitJK derived classes.
| /// Post-iteration Incfock processing | ||
| void incfock_postiter(); | ||
|
|
||
| /// Build the coulomb (J) matrix using Direct DF-J |
There was a problem hiding this comment.
Moved to respective SplitJK derived classes, as build_G_component().
| * type on output file | ||
| */ | ||
| void print_header() const override; | ||
|
|
There was a problem hiding this comment.
Moved to corresponding SplitJK derived classes, as print_header().
|
|
||
| namespace psi { | ||
|
|
||
| Matrix compute_numeric_overlap(const DFTGrid &grid, const std::shared_ptr<BasisSet> &primary) { |
There was a problem hiding this comment.
Code block moved to libfock/COSK.cc.
|
|
||
| // => Set up separate K algorithm <= // | ||
|
|
||
| // Linear Exchange (LinK) |
There was a problem hiding this comment.
Code block moved to libfock/LinK.cc.
| linK_ints_cutoff_ = cutoff_; | ||
| } | ||
|
|
||
| // Chain-of-Spheres Exchange (COSX) |
There was a problem hiding this comment.
Code block moved to libfock/COSK.cc.
| } | ||
| } | ||
|
|
||
| void CompositeJK::print_DirectDFJ_header() const { |
There was a problem hiding this comment.
Function moved to DirectDFJ::print_header() in libfock/DirectDFJ.cc.
| } | ||
| } | ||
|
|
||
| void CompositeJK::print_linK_header() const { |
There was a problem hiding this comment.
Function moved to LinK::print_header() in libfock/LinK.cc.
| } | ||
| } | ||
|
|
||
| void CompositeJK::print_COSX_header() const { |
There was a problem hiding this comment.
Function moved to COSK::print_header() in libfock/COSK.cc.
|
|
||
| void CompositeJK::postiterations() {} | ||
|
|
||
| // build the J matrix using Weigend's integral-direct density fitting algorithm |
There was a problem hiding this comment.
Function moved to DirectDFJ::build_G_component() function in libfock/DirectDFJ.cc.
|
|
||
| } | ||
|
|
||
| // build the K matrix using Ochsenfelds's Linear Exchange (LinK) algorithm |
There was a problem hiding this comment.
Function moved to LinK::build_G_component() function in libfock/LinK.cc.
| // build the K matrix using Neeses's Chain-of-Spheres Exchange algorithm | ||
| // algorithm is originally proposed in https://doi.org/10.1016/j.chemphys.2008.10.036 | ||
| // overlap fitting is discussed in https://doi.org/10.1063/1.3646921 | ||
| void CompositeJK::build_COSK(std::vector<std::shared_ptr<Matrix>>& D, std::vector<std::shared_ptr<Matrix>>& K) { |
There was a problem hiding this comment.
Function moved to COSK::build_G_component() function in libfock/COSK.cc.
|
All right, I shall officially open this up for review. |
319c882 to
c6b1840
Compare
Description
The final step of the CompositeJK saga.
The previous PR in this chain, #2833, introduced the CompositeJK framework to Psi4, a class by which to enable arbitrary mixing and matching of different algorithms for constructing the J and K matrices separately, with front-end changes to match. The big issue with the current formulation of CompositeJK, is that every single separate J or K build algorithm in Psi4 (currently DF-DirJ, LinK, and COSX) is contained within CompositeJK itself. This runs a high risk of CompositeJK becoming monolithic, especially as more separate J/K build methods are added (e.g., CFMM).
This PR is meant to be the solution to that issue. Rather than storing every separate J or K build algorithm in CompositeJK itself, they are now implemented as derived classes of a new base class, SplitJK. SplitJK features the
build_G_componentmember function, which derived classes of SplitJK then implement to execute their own algorithm for building one of J or K. CompositeJK is reworked to match, featuring a pair of shared_ptrs to SplitJK classes, one representing the J algorithm, and one representing the K algorithm. Actual machinery for computing J or K, as well as other functionalities such as header printing, is then done through calling corresponding functions from the SplitJK pointers.My thought is for this PR to be added in v1.9.
User API & Changelog headlines
N/A
Dev notes & details
Questions
Checklist
Status