34 double pair_threshold) {
54 const std::vector<libint2::Shell>& basis,
55 const std::vector<std::vector<Index>>& shellpairs)
const {
56 std::vector<std::vector<libint2::ShellPair>> shellpairdata(basis.size());
57 const double ln_max_engine_precision =
58 std::log(std::numeric_limits<double>::epsilon() * 1
e-10);
60#pragma omp parallel for schedule(dynamic)
61 for (
Index s1 = 0; s1 <
Index(shellpairs.size()); s1++) {
62 for (
Index s2 : shellpairs[s1]) {
63 shellpairdata[s1].emplace_back(
64 libint2::ShellPair(basis[s1], basis[s2], ln_max_engine_precision));
71 Eigen::MatrixXd result =
73#pragma omp parallel for schedule(dynamic)
77 for (
Index s2 = 0l; s2 <= s1; ++s2) {
81 result(s2, s1) = dmat.block(bf2, bf1, n2, n1).cwiseAbs().maxCoeff();
84 return result.selfadjointView<Eigen::Upper>();
91 "Please call Initialize before running this");
94 const Eigen::VectorXd dpacked =
threecenter_.PackWeighted(DMAT);
95 Eigen::VectorXd c(data.cols());
96#pragma omp parallel for schedule(static)
97 for (
Index P = 0;
P < data.cols(); ++
P) {
98 c(
P) = data.col(
P).dot(dpacked);
100 Eigen::VectorXd jpacked(data.rows());
102 const Index blocksize = (data.rows() + nblocks - 1) / nblocks;
103#pragma omp parallel for schedule(static)
104 for (
Index blk = 0; blk < nblocks; ++blk) {
105 const Index row = blk * blocksize;
106 const Index len = std::min(blocksize, data.rows() - row);
108 jpacked.segment(row, len).noalias() = data.middleRows(row, len) * c;
124 "Please call Initialize before running this");
125 Eigen::MatrixXd EXX = Eigen::MatrixXd::Zero(DMAT.rows(), DMAT.cols());
129 const Eigen::VectorXd& lambda = es.
values;
130 if (lambda.size() == 0) {
135 std::vector<Index> positive;
136 std::vector<Index> negative;
137 for (
Index k = 0; k < lambda.size(); ++k) {
138 if (lambda(k) > cutoff) {
139 positive.push_back(k);
140 }
else if (lambda(k) < -cutoff) {
141 negative.push_back(k);
146 if (npos + nneg == 0) {
150 Eigen::MatrixXd factors(DMAT.rows(), npos + nneg);
151 for (
Index c = 0; c < npos; ++c) {
152 const Index k = positive[c];
153 factors.col(c) = std::sqrt(lambda(k)) * es.
vectors.col(k);
155 for (
Index c = 0; c < nneg; ++c) {
156 const Index k = negative[c];
157 factors.col(npos + c) = std::sqrt(-lambda(k)) * es.
vectors.col(k);
164 "Please call Initialize before running this");
176 const Index n = factors.rows();
177 const Index nneg = factors.cols() - npos;
178 Eigen::MatrixXd EXX = Eigen::MatrixXd::Zero(n, n);
179 if (factors.cols() == 0) {
184 const Eigen::MatrixXd xt = factors.leftCols(npos).transpose();
185 const Eigen::MatrixXd yt = factors.rightCols(nneg).transpose();
189 Eigen::MatrixXd local = Eigen::MatrixXd::Zero(n, n);
191 Eigen::MatrixXd b = Eigen::MatrixXd::Zero(n, n);
192 Eigen::MatrixXd tx(batch * npos, n);
193 Eigen::MatrixXd ty(batch * nneg, n);
199 local.selfadjointView<Eigen::Lower>().rankUpdate(
200 tx.topRows(filled * npos).transpose(), -1.0);
202 local.selfadjointView<Eigen::Lower>().rankUpdate(
203 ty.topRows(filled * nneg).transpose(), 1.0);
207#pragma omp for schedule(dynamic)
211 tx.middleRows(filled * npos, npos).noalias() = xt * b;
214 ty.middleRows(filled * nneg, nneg).noalias() = yt * b;
216 if (++filled == batch) {
223 EXX.triangularView<Eigen::Lower>() += local;
226 return EXX.selfadjointView<Eigen::Lower>();
Container to hold Basisfunctions for all atoms.
std::vector< Index > getMapToBasisFunctions() const
Index getMaxNprim() const
std::vector< std::vector< Index > > ComputeShellPairs(double threshold=1e-20) const
std::vector< libint2::Shell > GenerateLibintBasis() const
Eigen::MatrixXd CalculateERIs_3c(const Eigen::MatrixXd &DMAT) const
void Initialize(const AOBasis &dftbasis, const AOBasis &auxbasis, double pair_threshold=0.0)
std::vector< std::vector< libint2::ShellPair > > shellpairdata_
std::vector< libint2::Shell > basis_
Eigen::MatrixXd ComputeSchwarzShells(const AOBasis &dftbasis) const
static constexpr double kDensityRankCutoff
std::vector< std::vector< Index > > shellpairs_
static constexpr Index kExchangeBatchRows
Rows of B_P X collected per thread before one rank update.
void Initialize_4c(const AOBasis &dftbasis)
std::vector< std::vector< libint2::ShellPair > > ComputeShellPairData(const std::vector< libint2::Shell > &basis, const std::vector< std::vector< Index > > &shellpairs) const
Eigen::MatrixXd ExchangeFromFactors(const Eigen::MatrixXd &factors, Index npos) const
Eigen::MatrixXd schwarzscreen_
Eigen::MatrixXd ComputeShellBlockNorm(const Eigen::MatrixXd &dmat) const
std::vector< Index > starts_
Eigen::MatrixXd CalculateEXX_dmat(const Eigen::MatrixXd &DMAT) const
TCMatrix_dft threecenter_
Eigen::MatrixXd CalculateEXX_mos(const Eigen::MatrixXd &occMos) const
Charge transport classes.
SymmetricEigenSystem SymmetricEigen(const Eigen::MatrixXd &A, bool vectors=true)
With vectors = false only the eigenvalues are computed.
Provides a means for comparing floating point numbers.