Scine::Sparrow  5.0.0
Library for fast and agile quantum chemical calculations with semiempirical methods.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Global2c2eMatrix.h
Go to the documentation of this file.
1 
8 #ifndef SPARROW_GLOBAL2C2EMATRIX_H
9 #define SPARROW_GLOBAL2C2EMATRIX_H
10 
11 #include "Global2c2eTerms.h"
12 #include "Local2c2eMatrix.h"
13 #include "multipoleTypes.h"
15 #include <Eigen/Core>
16 
17 namespace Scine {
18 namespace Sparrow {
19 
20 namespace nddo {
21 
22 namespace multipole {
23 class ChargeSeparationParameter;
24 class KlopmanParameter;
25 
32  public:
33  using orb_index_t = int;
34  using orbPair_index_t = int;
35 
45  Global2c2eMatrix(int l1, int l2, const ChargeSeparationParameter& D1, const ChargeSeparationParameter& D2,
46  const KlopmanParameter& r1, const KlopmanParameter& r2);
47 
52  void setSymmetric(bool sym) {
53  localZero_.setSymmetric(sym);
54  localOne_.setSymmetric(sym);
55  sameElement_ = sym;
56  }
57 
58  template<Utils::DerivativeOrder O>
59  void calculate(const Eigen::Vector3d& Rab);
60 
61  template<Utils::Derivative O>
62  Utils::AutomaticDifferentiation::DerivativeType<O> getDerivative(orb_index_t o1, orb_index_t o2, orb_index_t o3,
63  orb_index_t o4) const;
64  template<Utils::Derivative O>
65  Utils::AutomaticDifferentiation::DerivativeType<O> getDerivative(orbPair_index_t op1, orbPair_index_t op2) const;
66  double get(orb_index_t o1, orb_index_t o2, orb_index_t o3, orb_index_t o4) const;
67  double get(orbPair_index_t op1, orbPair_index_t op2) const;
68  orbPair_index_t getPairIndex(orb_index_t o1, orb_index_t o2) const;
69  const Eigen::MatrixXd& getGlobalMatrix() const;
70  void output() const;
71 
72  private:
73  Eigen::RowVector3d getFirstDerivative(orbPair_index_t op1, orbPair_index_t op2) const;
74  Utils::AutomaticDifferentiation::Second3D getSecondDerivative(orbPair_index_t op1, orbPair_index_t op2) const;
75 
76  template<Utils::DerivativeOrder O>
77  void evaluate();
78 
79  template<Utils::DerivativeOrder O>
80  Utils::AutomaticDifferentiation::Value3DType<O> evaluateMatrixElement(orbPair_index_t op1, orbPair_index_t op2);
81 
82  const int d1_, d2_;
83  Global2c2eTerms terms_;
84  const ChargeSeparationParameter &dist1, &dist2;
85  const KlopmanParameter &rho1, &rho2;
92  double R_, RNormX_, RNormY_, RNormZ_;
93  Utils::AutomaticDifferentiation::First3D nullDeriv, oneDeriv;
94  Eigen::MatrixXd globalMatrix_;
95  Eigen::Matrix<Utils::AutomaticDifferentiation::First3D, Eigen::Dynamic, Eigen::Dynamic> globalMatrixOne_;
96  Eigen::Matrix<Utils::AutomaticDifferentiation::Second3D, Eigen::Dynamic, Eigen::Dynamic> globalMatrixTwo_;
97  bool sameElement_;
98  TwoElectronIntegralIndexes pairIndexes_;
99 };
100 
101 inline Eigen::RowVector3d Global2c2eMatrix::getFirstDerivative(orbPair_index_t op1, orbPair_index_t op2) const {
102  if (op1 == 100 || op2 == 100)
103  return Utils::Gradient::Zero();
104 
105  return globalMatrixOne_(op1, op2).derivatives();
106 }
107 
108 inline Utils::AutomaticDifferentiation::Second3D Global2c2eMatrix::getSecondDerivative(orbPair_index_t op1,
109  orbPair_index_t op2) const {
110  if (op1 == 100 || op2 == 100)
111  return {};
112 
113  return globalMatrixTwo_(op1, op2);
114 }
115 
116 template<Utils::Derivative O>
117 Utils::AutomaticDifferentiation::DerivativeType<O> Global2c2eMatrix::getDerivative(orb_index_t o1, orb_index_t o2,
118  orb_index_t o3, orb_index_t o4) const {
119  return getDerivative<O>(getPairIndex(o1, o2), getPairIndex(o3, o4));
120 }
121 
122 template<>
123 inline Utils::AutomaticDifferentiation::DerivativeType<Utils::Derivative::First>
124 Global2c2eMatrix::getDerivative<Utils::Derivative::First>(orbPair_index_t op1, orbPair_index_t op2) const {
125  return getFirstDerivative(op1, op2);
126 }
127 
128 inline const Eigen::MatrixXd& Global2c2eMatrix::getGlobalMatrix() const {
129  return globalMatrix_;
130 }
131 
132 template<>
133 inline Utils::AutomaticDifferentiation::DerivativeType<Utils::Derivative::SecondAtomic>
134 Global2c2eMatrix::getDerivative<Utils::Derivative::SecondAtomic>(orbPair_index_t op1, orbPair_index_t op2) const {
135  return getSecondDerivative(op1, op2);
136 }
137 
138 template<>
139 inline Utils::AutomaticDifferentiation::DerivativeType<Utils::Derivative::SecondFull>
140 Global2c2eMatrix::getDerivative<Utils::Derivative::SecondFull>(orbPair_index_t op1, orbPair_index_t op2) const {
141  return getSecondDerivative(op1, op2);
142 }
143 
144 } // namespace multipole
145 
146 } // namespace nddo
147 
148 } // namespace Sparrow
149 } // namespace Scine
150 #endif // SPARROW_GLOBAL2C2EMATRIX_H
Definition: Global2c2eMatrix.h:31
This class initializes and stores as a static array the indices of the charge distributions on one ce...
Definition: TwoElectronIntegralIndexes.h:36
This class is the container for the Klopman-Ohno parameters used for the evaluation of the multipoles...
Definition: KlopmanParameter.h:29
Global2c2eMatrix(int l1, int l2, const ChargeSeparationParameter &D1, const ChargeSeparationParameter &D2, const KlopmanParameter &r1, const KlopmanParameter &r2)
constructor of the Global2c2eMatrix, constaining the 2 centers 2 electrons integrals between two atom...
Definition: Global2c2eMatrix.cpp:22
Definition: Global2c2eTerms.h:34
void setSymmetric(bool sym)
set whether the class refers to integrals within two elements of the same type.
Definition: Global2c2eMatrix.h:52
Charge separation D of semi-empirical models. It describes the separation between two charges of oppo...
Definition: ChargeSeparationParameter.h:29