GQCP
Loading...
Searching...
No Matches
LibcintOneElectronIntegralEngine.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
24#include "Utilities/complex.hpp"
27
28
29namespace GQCP {
30
31
45template <typename _Shell, size_t _N, typename _IntegralScalar>
46class LibcintOneElectronIntegralEngine: public BaseOneElectronIntegralEngine<_Shell, _N, _IntegralScalar> {
47public:
48 using Shell = _Shell; // the type of shell the integral engine is able to handle
49 using IntegralScalar = _IntegralScalar; // the scalar representation of an integral
50 static constexpr auto N = _N; // the number of components the operator has
51
52
53private:
54 Libcint1eFunction libcint_function; // the libcint one-electron integral function
55
56 // Data that has to be kept as a member (see the class note).
57 libcint::RawContainer libcint_raw_container; // the raw libcint data
58 ShellSet<Shell> shell_set; // the corresponding shell set
59
60 // Parameters to pass to the buffer.
61 IntegralScalar scaling_factor = 1.0; // a factor that is multiplied to all of the calculated integrals
62
63
64public:
65 /*
66 * CONSTRUCTORS
67 */
68
76 libcint_function {LibcintInterfacer().oneElectronFunction(op)},
77 libcint_raw_container {LibcintInterfacer().convert(shell_set)},
78 shell_set {shell_set},
79 scaling_factor {-1.0} { // apply the minus sign which comes from the charge of the electrons -e
80
81 LibcintInterfacer().setCommonOrigin(this->libcint_raw_container, op.reference());
82 }
83
91 libcint_function {LibcintInterfacer().oneElectronFunction(op)},
92 libcint_raw_container {LibcintInterfacer().convert(shell_set)},
93 shell_set {shell_set} {}
94
102 libcint_function {LibcintInterfacer().oneElectronFunction(op)},
103 libcint_raw_container {LibcintInterfacer().convert(shell_set)},
104 shell_set {shell_set} {}
105
113 libcint_function {LibcintInterfacer().oneElectronFunction(op)},
114 libcint_raw_container {LibcintInterfacer().convert(shell_set)},
115 shell_set {shell_set} {}
116
117
118 /*
119 * PUBLIC OVERRIDDEN METHODS
120 */
121
126 std::shared_ptr<BaseOneElectronIntegralBuffer<IntegralScalar, N>> calculate(const GTOShell& shell1, const GTOShell& shell2) override {
127
128 // Find to which indices in the RawContainer the given shells correspond
129 int shell_indices[2];
130 shell_indices[0] = static_cast<int>(findElementIndex(this->shell_set.asVector(), shell1));
131 shell_indices[1] = static_cast<int>(findElementIndex(this->shell_set.asVector(), shell2));
132
133
134 // Pre-allocate a raw buffer, because libcint functions expect a data pointer
135 const size_t nbf1 = shell1.numberOfBasisFunctions();
136 const size_t nbf2 = shell2.numberOfBasisFunctions();
137 double libcint_buffer[2 * N * nbf1 * nbf2];
138
139
140 // Let libcint compute the integrals and return the corresponding buffer
141 const auto result = this->libcint_function(libcint_buffer, shell_indices, libcint_raw_container.atmData(), libcint_raw_container.numberOfAtoms(), libcint_raw_container.basData(), libcint_raw_container.numberOfBasisFunctions(), libcint_raw_container.envData());
142
143 const std::vector<double> buffer_converted {libcint_buffer, libcint_buffer + N * nbf1 * nbf2}; // std::vector constructor from .begin() and .end()
144
145 return std::make_shared<LibcintOneElectronIntegralBuffer<IntegralScalar, N>>(buffer_converted, nbf1, nbf2, result, this->scaling_factor);
146 }
147};
148
149
150} // namespace GQCP
Definition: BaseOneElectronIntegralEngine.hpp:37
const Vector< double, 3 > & reference() const
Definition: BaseReferenceDependentOperator.hpp:66
Definition: ElectronicDipoleOperator.hpp:33
Definition: GTOShell.hpp:32
size_t numberOfBasisFunctions() const
Definition: GTOShell.cpp:173
Definition: KineticOperator.hpp:31
Definition: LibcintInterfacer.hpp:86
void setCommonOrigin(libcint::RawContainer &raw_container, const Vector< double, 3 > &origin) const
Definition: LibcintInterfacer.cpp:116
Definition: LibcintOneElectronIntegralEngine.hpp:46
static constexpr auto N
Definition: LibcintOneElectronIntegralEngine.hpp:50
std::shared_ptr< BaseOneElectronIntegralBuffer< IntegralScalar, N > > calculate(const GTOShell &shell1, const GTOShell &shell2) override
Definition: LibcintOneElectronIntegralEngine.hpp:126
LibcintOneElectronIntegralEngine(const NuclearAttractionOperator &op, const ShellSet< Shell > &shell_set)
Definition: LibcintOneElectronIntegralEngine.hpp:101
LibcintOneElectronIntegralEngine(const KineticOperator &op, const ShellSet< Shell > &shell_set)
Definition: LibcintOneElectronIntegralEngine.hpp:90
LibcintOneElectronIntegralEngine(const ElectronicDipoleOperator &op, const ShellSet< Shell > &shell_set)
Definition: LibcintOneElectronIntegralEngine.hpp:75
_Shell Shell
Definition: LibcintOneElectronIntegralEngine.hpp:48
_IntegralScalar IntegralScalar
Definition: LibcintOneElectronIntegralEngine.hpp:49
LibcintOneElectronIntegralEngine(const OverlapOperator &op, const ShellSet< Shell > &shell_set)
Definition: LibcintOneElectronIntegralEngine.hpp:112
Definition: NuclearAttractionOperator.hpp:33
Definition: OverlapOperator.hpp:31
Definition: ShellSet.hpp:41
const std::vector< Shell > & asVector() const
Definition: ShellSet.hpp:180
Definition: LibcintInterfacer.hpp:180
const int * atmData() const
Definition: LibcintInterfacer.hpp:233
const int * basData() const
Definition: LibcintInterfacer.hpp:238
int numberOfAtoms() const
Definition: LibcintInterfacer.hpp:248
const double * envData() const
Definition: LibcintInterfacer.hpp:243
int numberOfBasisFunctions() const
Definition: LibcintInterfacer.hpp:253
Definition: BaseOneElectronIntegralBuffer.hpp:25
size_t findElementIndex(const std::vector< T > &vector, const T &value)
Definition: miscellaneous.hpp:44
std::function< int(double *, const int *, const int *, int, const int *, int, const double *)> Libcint1eFunction
Definition: LibcintInterfacer.hpp:65