votca 2026-dev
Loading...
Searching...
No Matches
ERIs.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_ERIS_H
22#define VOTCA_XTP_ERIS_H
23
24// Local VOTCA includes
25#include "threecenter.h"
26
27namespace votca {
28namespace xtp {
29
35class ERIs {
36
37 public:
40 void Initialize(const AOBasis& dftbasis, const AOBasis& auxbasis,
41 double pair_threshold = 0.0);
42 void Initialize_4c(const AOBasis& dftbasis);
43
44 Eigen::MatrixXd CalculateERIs_3c(const Eigen::MatrixXd& DMAT) const;
45
46 std::array<Eigen::MatrixXd, 2> CalculateERIs_EXX_3c(
47 const Eigen::MatrixXd& occMos, const Eigen::MatrixXd& DMAT) const {
48 std::array<Eigen::MatrixXd, 2> result;
49 result[0] = CalculateERIs_3c(DMAT);
50 result[1] = CalculateEXX_3c(occMos, DMAT);
51 return result;
52 }
53
56 Eigen::MatrixXd CalculateEXX_3c(const Eigen::MatrixXd& occMos,
57 const Eigen::MatrixXd& DMAT) const {
58 if (occMos.rows() > 0 && occMos.cols() > 0) {
59 assert(occMos.rows() == DMAT.rows() && "occMos.rows()==DMAT.rows()");
60 return CalculateEXX_mos(occMos);
61 }
62 return CalculateEXX_dmat(DMAT);
63 }
64
66 Index AuxSize() const { return threecenter_.size(); }
68 Index StoredPairs() const { return threecenter_.StoredPairs(); }
69 Index AllPairs() const { return threecenter_.AllPairs(); }
71 double MetricSeconds() const { return threecenter_.MetricSeconds(); }
72
73 Eigen::MatrixXd CalculateERIs_4c(const Eigen::MatrixXd& DMAT,
74 double error) const {
75 return Compute4c<false>(DMAT, error)[0];
76 }
77
78 std::array<Eigen::MatrixXd, 2> CalculateERIs_EXX_4c(
79 const Eigen::MatrixXd& DMAT, double error) const {
80 return Compute4c<true>(DMAT, error);
81 }
82
83 Index Removedfunctions() const { return threecenter_.Removedfunctions(); }
84
85 static double CalculateEnergy(const Eigen::MatrixXd& DMAT,
86 const Eigen::MatrixXd& matrix_operator) {
87 return matrix_operator.cwiseProduct(DMAT).sum();
88 }
89
90 private:
91 std::vector<libint2::Shell> basis_;
92 std::vector<Index> starts_;
93
94 std::vector<std::vector<Index>> shellpairs_;
95 std::vector<std::vector<libint2::ShellPair>> shellpairdata_;
98
101 static constexpr double kDensityRankCutoff = 1e-12;
102 Eigen::MatrixXd CalculateEXX_dmat(const Eigen::MatrixXd& DMAT) const;
103 Eigen::MatrixXd CalculateEXX_mos(const Eigen::MatrixXd& occMos) const;
106 Eigen::MatrixXd ExchangeFromFactors(const Eigen::MatrixXd& factors,
107 Index npos) const;
109 static constexpr Index kExchangeBatchRows = 1024;
110
111 std::vector<std::vector<libint2::ShellPair>> ComputeShellPairData(
112 const std::vector<libint2::Shell>& basis,
113 const std::vector<std::vector<Index>>& shellpairs) const;
114
115 Eigen::MatrixXd ComputeSchwarzShells(const AOBasis& dftbasis) const;
116 Eigen::MatrixXd ComputeShellBlockNorm(const Eigen::MatrixXd& dmat) const;
117
118 template <bool with_exchange>
119 std::array<Eigen::MatrixXd, 2> Compute4c(const Eigen::MatrixXd& dmat,
120 double error) const;
121
123
124 Eigen::MatrixXd schwarzscreen_; // Square matrix containing <ab|ab> for all
125 // shells
126}; // namespace xtp
127
128} // namespace xtp
129} // namespace votca
130
131#endif // VOTCA_XTP_ERIS_H
Container to hold Basisfunctions for all atoms.
Definition aobasis.h:42
Takes a density matrix and and an auxiliary basis set and calculates the electron repulsion integrals...
Definition ERIs.h:35
Eigen::MatrixXd CalculateERIs_3c(const Eigen::MatrixXd &DMAT) const
Definition ERIs.cc:89
void Initialize(const AOBasis &dftbasis, const AOBasis &auxbasis, double pair_threshold=0.0)
Definition ERIs.cc:33
Index Removedfunctions() const
Definition ERIs.h:83
std::vector< std::vector< libint2::ShellPair > > shellpairdata_
Definition ERIs.h:95
std::vector< libint2::Shell > basis_
Definition ERIs.h:91
Eigen::MatrixXd ComputeSchwarzShells(const AOBasis &dftbasis) const
double MetricSeconds() const
Wall time spent on the aux Coulomb metric and its inverse square root.
Definition ERIs.h:71
static constexpr double kDensityRankCutoff
Definition ERIs.h:101
std::vector< std::vector< Index > > shellpairs_
Definition ERIs.h:94
std::array< Eigen::MatrixXd, 2 > CalculateERIs_EXX_4c(const Eigen::MatrixXd &DMAT, double error) const
Definition ERIs.h:78
Index StoredPairs() const
Stored basis-function pairs of the 3c tensor and all N(N+1)/2 pairs.
Definition ERIs.h:68
static constexpr Index kExchangeBatchRows
Rows of B_P X collected per thread before one rank update.
Definition ERIs.h:109
void Initialize_4c(const AOBasis &dftbasis)
Definition ERIs.cc:39
Eigen::MatrixXd CalculateEXX_3c(const Eigen::MatrixXd &occMos, const Eigen::MatrixXd &DMAT) const
Definition ERIs.h:56
Index AllPairs() const
Definition ERIs.h:69
static double CalculateEnergy(const Eigen::MatrixXd &DMAT, const Eigen::MatrixXd &matrix_operator)
Definition ERIs.h:85
std::array< Eigen::MatrixXd, 2 > Compute4c(const Eigen::MatrixXd &dmat, double error) const
std::array< Eigen::MatrixXd, 2 > CalculateERIs_EXX_3c(const Eigen::MatrixXd &occMos, const Eigen::MatrixXd &DMAT) const
Definition ERIs.h:46
Index maxL_
Definition ERIs.h:97
std::vector< std::vector< libint2::ShellPair > > ComputeShellPairData(const std::vector< libint2::Shell > &basis, const std::vector< std::vector< Index > > &shellpairs) const
Definition ERIs.cc:53
Eigen::MatrixXd CalculateERIs_4c(const Eigen::MatrixXd &DMAT, double error) const
Definition ERIs.h:73
Eigen::MatrixXd ExchangeFromFactors(const Eigen::MatrixXd &factors, Index npos) const
Definition ERIs.cc:174
Eigen::MatrixXd schwarzscreen_
Definition ERIs.h:124
Eigen::MatrixXd ComputeShellBlockNorm(const Eigen::MatrixXd &dmat) const
Definition ERIs.cc:70
std::vector< Index > starts_
Definition ERIs.h:92
Eigen::MatrixXd CalculateEXX_dmat(const Eigen::MatrixXd &DMAT) const
Definition ERIs.cc:122
TCMatrix_dft threecenter_
Definition ERIs.h:122
Index AuxSize() const
Number of auxiliary functions the 3c tensor is stored for.
Definition ERIs.h:66
Index maxnprim_
Definition ERIs.h:96
Eigen::MatrixXd CalculateEXX_mos(const Eigen::MatrixXd &occMos) const
Definition ERIs.cc:162
RI three-centre tensor of the DFT code, B_P,mu nu = sum_Q V^-1/2_PQ (Q|mu nu).
Definition threecenter.h:74
Charge transport classes.
Definition ERIs.h:28
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26