Refactor JK_deriv2#2994
Conversation
loriab
left a comment
There was a problem hiding this comment.
Looks reasonable (and a lot more readable) to me. I'm curious if there was an intended generalization by the c1/c2 setup.
| // temporary intermediates in a loop. In the (likely) event the allocation time cost is | ||
| // negligible in comparison to the J/K build, simplify away. | ||
| C_DGEMM('N','N',nso,naocc,nso,1.0,J[2*a]->pointer()[0],nso,Caop[0],naocc,0.0,Tap[0],naocc); | ||
| C_DGEMM('T','N',nmo,naocc,nso,1.0,Cap[0],nmo,Tap[0],naocc,0.0,Uap[0],naocc); |
There was a problem hiding this comment.
Change of constants from -1,1 to 1,0 deliberate?
There was a problem hiding this comment.
Yes.
In the old code, we backtransform four times and then add the pieces together. In the new code, we add the four pieces together and backtransform once. The job that those constants used to do is now fulfilled by J[2*a]->add(J[2*a+1]); J[2*a]->scale(-1); a few lines above.
Yes, and getting rid of that intended generalization is precisely the point of this PR. The intended generalization of the c1/c2 setup was that you could pass in alpha and then beta to compute the alpha block, or you could pass in beta and then alpha to compute the beta block. We're now computing both at once, so we don't need that. Having c1/c2 now is just confusing. Instead, we make explicit that alpha comes before beta. |
Description
The
JK_deriv2function exists to compute the overlap-derivative-times-TEI part of the right side of the CPHF equation. It's a J-term and a K-like term. with overlap derivative integrals instead of a density.[1] The previous algorithm to do this first computed the alpha spin part in one function call, and then the beta spin part in another function call. This approach was redundant. The first function call had all the intermediates necessary to compute the beta part, but didn't use them. As a result, the function re-computed JK.This PR refactors
JK_deriv2so it computes both spin cases in a single function call.[1] = There's also a Vx term, but its implementation was both unused and buggy. Now it's just unused. Trying to use it in the old way would be even more redundant.
User API & Changelog headlines
Dev notes & details
JK_deriv2to compute both spin cases in a single function call.JK_deriv2comply withcompute_Vx's expected function signatureChecklist
ctest -R scf-hesspassesStatus