From ec73829940e624c790c2a811ec8711337ae44624 Mon Sep 17 00:00:00 2001 From: Susi Lehtola Date: Sun, 21 Jan 2024 12:59:06 +0200 Subject: [PATCH] Remove method of Eichkorn et al from density fitting code, instead always use the numerically stable method of pivoted Cholesky orthogonalization. --- src/density_fitting.cpp | 76 ++++++++--------------------------------- src/density_fitting.h | 7 +--- src/scf-base.cpp | 6 ++-- 3 files changed, 19 insertions(+), 70 deletions(-) diff --git a/src/density_fitting.cpp b/src/density_fitting.cpp index ee6c00d6..168a0b3b 100644 --- a/src/density_fitting.cpp +++ b/src/density_fitting.cpp @@ -48,11 +48,7 @@ void DensityFit::get_range_separation(double & w, double & a, double & b) const b=beta; } -bool DensityFit::Bmat_enabled() const { - return Bmat; -} - -size_t DensityFit::fill(const BasisSet & orbbas, const BasisSet & auxbas, bool dir, double erithr, double linthr, double cholthr, bool bmat) { +size_t DensityFit::fill(const BasisSet & orbbas, const BasisSet & auxbas, bool dir, double erithr, double linthr, double cholthr) { // Construct density fitting basis // Store amount of functions @@ -60,7 +56,6 @@ size_t DensityFit::fill(const BasisSet & orbbas, const BasisSet & auxbas, bool d Naux=auxbas.get_Nbf(); Nnuc=orbbas.get_Nnuc(); direct=dir; - Bmat=bmat; // Fill list of shell pairs arma::mat Q, M; @@ -124,15 +119,8 @@ size_t DensityFit::fill(const BasisSet & orbbas, const BasisSet & auxbas, bool d delete eri; } - if(Bmat) { - ab_invh = PartialCholeskyOrth(ab, cholthr, linthr); - ab_inv = ab_invh * ab_invh.t(); - //printf("%i auxiliary funtions out of %i are linearly independent\n",ab_invh.n_cols,ab_invh.n_rows); - } else { - // Just RI-J(K), so use faster method from Eichkorn et al to form ab_inv only - ab_inv=arma::inv(ab + DELTA*arma::eye(ab.n_rows,ab.n_cols)); - //printf("Using method of Eichkorn et al for ab_inv\n"); - } + ab_invh = PartialCholeskyOrth(ab, cholthr, linthr); + ab_inv = ab_invh * ab_invh.t(); // Then, compute the three-center integrals if(!direct) { @@ -384,12 +372,8 @@ void DensityFit::digest_K_incore(const arma::mat & C, const arma::vec & occs, ar } // K_uv = (ui|vi) = (a|ui) (a|b)^-1 (b|vi) - if(Bmat) { - aui = ab_invh.t()*aui; - K += occs[io]*arma::trans(aui)*aui; - } else { - K += occs[io]*arma::trans(aui)*ab_inv*aui; - } + aui = ab_invh.t()*aui; + K += occs[io]*arma::trans(aui)*aui; } } @@ -465,12 +449,8 @@ void DensityFit::digest_K_incore(const arma::cx_mat & C, const arma::vec & occs, } // K_uv = (ui|vi) = (a|ui) (a|b)^-1 (b|vi) - if(Bmat) { - aui = ab_invh.t()*aui; - K += occs[io]*arma::trans(aui)*aui; - } else { - K += occs[io]*arma::trans(aui)*ab_inv*aui; - } + aui = ab_invh.t()*aui; + K += occs[io]*arma::trans(aui)*aui; } } @@ -565,15 +545,9 @@ void DensityFit::digest_K_direct(const arma::mat & C, const arma::vec & occs, ar } // K_uv = (ui|vi) = (a|ui) (a|b)^-1 (b|vi) - if(Bmat) { - for(size_t io=0;io DensityFit::compute_expansion(const std::vector & P) const { @@ -760,18 +726,8 @@ std::vector DensityFit::compute_expansion(const std::vectorget_unique_shellpairs().size());