GQCP
Loading...
Searching...
No Matches
LibcintInterfacer.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
22#include "Molecule/Molecule.hpp"
28
29#include <functional>
30
31
32extern "C" {
33
34
35#include <cint.h>
36
37
38/*
39 * The following functions are not inside the include header <cint.h>, so we should define them in order to be able to use them in our source code
40 */
41FINT cint1e_kin_cart(double* buf, const int* shls, const int* atm, int natm, const int* bas, int nbas, const double* env); // kinetic energy
42FINT cint1e_nuc_cart(double* buf, const int* shls, const int* atm, int natm, const int* bas, int nbas, const double* env); // nuclear attraction energy
43FINT cint1e_ovlp_cart(double* buf, const int* shls, const int* atm, int natm, const int* bas, int nbas, const double* env); // overlap
44FINT cint1e_r_cart(double* buf, const int* shls, const int* atm, int natm, const int* bas, int nbas, const double* env); // dipole integrals
45
46
47} // extern "C"
48
49
50namespace GQCP {
51
52
53inline FINT cint2e_cart_const(double* buf, const int* shls, const int* atm, int natm, const int* bas, int nbas, const double* env, const CINTOpt* opt) {
54 return cint2e_cart(buf, const_cast<int*>(shls), const_cast<int*>(atm), natm, const_cast<int*>(bas), nbas, const_cast<double*>(env), const_cast<CINTOpt*>(opt));
55}
56
57inline void cint2e_cart_optimizer_const(CINTOpt** opt, const int* atm, int natm, const int* bas, int nbas, const double* env) {
58 cint2e_cart_optimizer(opt, const_cast<int*>(atm), natm, const_cast<int*>(bas), nbas, const_cast<double*>(env));
59}
60
61/*
62 * Aliases for functions that are used in Libcint
63 */
64
65using Libcint1eFunction = std::function<int(double*, const int*, const int*, int, const int*, int, const double*)>;
66using Libcint2eFunction = std::function<int(double*, const int*, const int*, int, const int*, int, const double*, const CINTOpt*)>;
67using Libcint2eOptimizerFunction = std::function<void(CINTOpt**, const int*, int, const int*, int, const double*)>;
68
69
70/*
71 * Forward declarations
72 */
73
74namespace libcint {
75
76
77class RawContainer;
78
79
80} // namespace libcint
81
82
87public:
88 // PUBLIC METHODS - INTERFACING
89
95 libcint::RawContainer convert(const ShellSet<GTOShell>& shell_set) const;
96
103 void setCommonOrigin(libcint::RawContainer& raw_container, const Vector<double, 3>& origin) const;
104
105
106 // PUBLIC METHODS - INTEGRAL FUNCTIONS
107
114
121
128
135
142
149};
150
151
152namespace libcint {
153
154
158static constexpr int ptr_common_orig = PTR_COMMON_ORIG; // an offset for the origin of vector operators
159static constexpr int ptr_env_start = PTR_ENV_START; // an offset such that libcint can retrieve the correct index inside the environment, starts at 20
160
161static constexpr int atm_slots = ATM_SLOTS; // the number of 'slots' (i.e. 'members') for an atom
162static constexpr int charge_of = CHARGE_OF; // slot offset for atomic charge
163static constexpr int ptr_coord = PTR_COORD; // slot offset for a 'pointer' of the atom inside the libcint environment
164
165
166static constexpr int bas_slots = BAS_SLOTS; // the number of 'slots' (i.e. 'members') for a basis function
167static constexpr int atom_of = ATOM_OF; // slot offset for the corresponding atom in the basis function
168static constexpr int ang_of = ANG_OF; // slot offset for the angular momentum
169static constexpr int nprim_of = NPRIM_OF; // slot offset for the number of primitives inside the basis function
170static constexpr int nctr_of = NCTR_OF; // slot offset for the number of contractions
171static constexpr int ptr_exp = PTR_EXP; // slot offset for a 'pointer' to the exponents of the shell inside the libcint environment
172static constexpr int ptr_coeff = PTR_COEFF; // slot offset for a 'pointer' to the contraction coefficients inside the libcint environment
173
174
181private:
182 int natm; // number of atoms
183 int nbf; // number of basis functions
184 int nsh; // the number of shells
185
186 int* libcint_atm; // information about the atoms
187 int* libcint_bas; // information about the basis functions
188 double* libcint_env; // a raw block of doubles in which libcint (probably) places intermediary calculations
189
190
191public:
192 /*
193 * CONSTRUCTORS
194 */
195
203 RawContainer(const size_t natm, const size_t nbf, const size_t nsh) :
204 natm {static_cast<int>(natm)},
205 nbf {static_cast<int>(nbf)},
206 nsh {static_cast<int>(nsh)},
207 libcint_atm {new int[this->natm * atm_slots]},
208 libcint_bas {new int[this->nbf * bas_slots]},
209 libcint_env {new double[10000]} {}
210
211
212 /*
213 * DESTRUCTOR
214 */
215
220 delete[] this->libcint_atm;
221 delete[] this->libcint_bas;
222 delete[] this->libcint_env;
223 }
224
225
226 /*
227 * PUBLIC METHODS
228 */
229
233 const int* atmData() const { return this->libcint_atm; }
234
238 const int* basData() const { return this->libcint_bas; }
239
243 const double* envData() const { return this->libcint_env; }
244
248 int numberOfAtoms() const { return this->natm; }
249
253 int numberOfBasisFunctions() const { return this->nbf; }
254
258 int numberOfShells() const { return this->nsh; }
259
260
261 /*
262 * FRIENDS
263 */
265};
266
267
268} // namespace libcint
269} // namespace GQCP
FINT cint1e_nuc_cart(double *buf, const int *shls, const int *atm, int natm, const int *bas, int nbas, const double *env)
FINT cint1e_r_cart(double *buf, const int *shls, const int *atm, int natm, const int *bas, int nbas, const double *env)
FINT cint1e_kin_cart(double *buf, const int *shls, const int *atm, int natm, const int *bas, int nbas, const double *env)
FINT cint1e_ovlp_cart(double *buf, const int *shls, const int *atm, int natm, const int *bas, int nbas, const double *env)
Definition: CoulombRepulsionOperator.hpp:31
Definition: ElectronicDipoleOperator.hpp:33
Definition: KineticOperator.hpp:31
Definition: LibcintInterfacer.hpp:86
void setCommonOrigin(libcint::RawContainer &raw_container, const Vector< double, 3 > &origin) const
Definition: LibcintInterfacer.cpp:116
Libcint1eFunction oneElectronFunction(const NuclearAttractionOperator &op) const
Definition: LibcintInterfacer.hpp:127
Libcint1eFunction oneElectronFunction(const ElectronicDipoleOperator &op) const
Definition: LibcintInterfacer.hpp:113
libcint::RawContainer convert(const ShellSet< GTOShell > &shell_set) const
Definition: LibcintInterfacer.cpp:33
Libcint2eOptimizerFunction twoElectronOptimizerFunction(const CoulombRepulsionOperator &op) const
Definition: LibcintInterfacer.hpp:148
Libcint2eFunction twoElectronFunction(const CoulombRepulsionOperator &op) const
Definition: LibcintInterfacer.hpp:141
Libcint1eFunction oneElectronFunction(const OverlapOperator &op) const
Definition: LibcintInterfacer.hpp:134
Libcint1eFunction oneElectronFunction(const KineticOperator &op) const
Definition: LibcintInterfacer.hpp:120
Definition: Matrix.hpp:47
Definition: NuclearAttractionOperator.hpp:33
Definition: OverlapOperator.hpp:31
Definition: ShellSet.hpp:41
Definition: LibcintInterfacer.hpp:180
RawContainer(const size_t natm, const size_t nbf, const size_t nsh)
Definition: LibcintInterfacer.hpp:203
const int * atmData() const
Definition: LibcintInterfacer.hpp:233
const int * basData() const
Definition: LibcintInterfacer.hpp:238
int numberOfAtoms() const
Definition: LibcintInterfacer.hpp:248
~RawContainer()
Definition: LibcintInterfacer.hpp:219
int numberOfShells() const
Definition: LibcintInterfacer.hpp:258
const double * envData() const
Definition: LibcintInterfacer.hpp:243
int numberOfBasisFunctions() const
Definition: LibcintInterfacer.hpp:253
Definition: BaseOneElectronIntegralBuffer.hpp:25
FINT cint2e_cart_const(double *buf, const int *shls, const int *atm, int natm, const int *bas, int nbas, const double *env, const CINTOpt *opt)
Definition: LibcintInterfacer.hpp:53
void cint2e_cart_optimizer_const(CINTOpt **opt, const int *atm, int natm, const int *bas, int nbas, const double *env)
Definition: LibcintInterfacer.hpp:57
std::function< int(double *, const int *, const int *, int, const int *, int, const double *, const CINTOpt *)> Libcint2eFunction
Definition: LibcintInterfacer.hpp:66
std::function< int(double *, const int *, const int *, int, const int *, int, const double *)> Libcint1eFunction
Definition: LibcintInterfacer.hpp:65
std::function< void(CINTOpt **, const int *, int, const int *, int, const double *)> Libcint2eOptimizerFunction
Definition: LibcintInterfacer.hpp:67