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
CompositeJK Part 3: SplitJK #2955
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Machinery pulled from the previous CompositeJK::build_linK() function.
@@ -1245,32 +1250,6 @@ class PSI_API CompositeJK : public JK { | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to respective SplitJK derived classes.
@@ -1289,31 +1268,6 @@ class PSI_API CompositeJK : public JK { | |||
/// Post-iteration Incfock processing | |||
void incfock_postiter(); | |||
|
|||
/// Build the coulomb (J) matrix using Direct DF-J |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to respective SplitJK derived classes, as build_G_component().
/** | ||
* Print header information regarding JK | ||
* type on output file | ||
*/ | ||
void print_header() const override; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to corresponding SplitJK derived classes, as print_header().
@@ -51,100 +51,6 @@ using namespace psi; | |||
|
|||
namespace psi { | |||
|
|||
Matrix compute_numeric_overlap(const DFTGrid &grid, const std::shared_ptr<BasisSet> &primary) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code block moved to libfock/COSK.cc.
} else { | ||
throw PSIEXCEPTION("Invalid Composite J algorithm selected!"); | ||
} | ||
|
||
// => Set up separate K algorithm <= // | ||
|
||
// Linear Exchange (LinK) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code block moved to libfock/LinK.cc.
linK_ints_cutoff_ = cutoff_; | ||
} | ||
|
||
// Chain-of-Spheres Exchange (COSX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code block moved to libfock/COSK.cc.
} | ||
outfile->Printf("\n"); | ||
} | ||
} | ||
|
||
void CompositeJK::print_DirectDFJ_header() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function moved to DirectDFJ::print_header()
in libfock/DirectDFJ.cc.
} | ||
} | ||
|
||
void CompositeJK::print_linK_header() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function moved to LinK::print_header()
in libfock/LinK.cc.
} | ||
} | ||
|
||
void CompositeJK::print_COSX_header() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function moved to COSK::print_header()
in libfock/COSK.cc.
@@ -532,1059 +291,4 @@ void CompositeJK::compute_JK() { | |||
|
|||
void CompositeJK::postiterations() {} | |||
|
|||
// build the J matrix using Weigend's integral-direct density fitting algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
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_component
member 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