ergo
integrals_2el_utils.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
38 #ifndef INTEGRALS_2EL_UTILS_HEADER
39 #define INTEGRALS_2EL_UTILS_HEADER
40 
41 
42 #include "organize_distrs.h"
43 #include "organize_distrs_mm.h"
44 #include "box_system.h"
45 
46 
47 #define MAX_NO_OF_BRANCHES 10
48 
49 
50 /* Struct used for storing result matrix contributions when e.g. the J
51  kernel routine is used with Chunks and Tasks. */
53  struct RowColVal {
54  int row;
55  int col;
57  };
58  static const int nVectorsMax = 40;
63  std::vector<RowColVal> * vList[nVectorsMax];
66  void addContrib(int row, int col, ergo_real value);
67  const RowColVal & fetchNextContrib(int & currVecIndexForFetch, int & indexInCurrVecForFetch) const;
68 };
69 
70 
71 struct box_struct {
72  // General stuff
74  // Stuff related to J
78  // Stuff related to K
80  // Constructor
81  box_struct();
82 };
83 
84 
90  ergo_real* partial_dmat_2; // used in non-symmetric case
92  ergo_real* partial_K_2; // used in non-symmetric case
93 };
94 
95 
96 ergo_real get_max_abs_vector_element(int n, const ergo_real* vector);
97 
98 void
100  int maxNoOfMonomials,
101  int basisFuncListCount_max,
102  JK_contribs_buffer_struct* bufferStruct);
103 
104 void
106 
107 int
108 get_related_integrals_h(const IntegralInfo & integralInfo,
109  const JK::ExchWeights & CAM_params,
110  int n1max, int noOfMonomials_1,
111  int n2max, int noOfMonomials_2,
112  ergo_real dx0,
113  ergo_real dx1,
114  ergo_real dx2,
115  ergo_real alpha1,
116  ergo_real alpha2,
117  ergo_real alpha0,
118  ergo_real* primitiveIntegralList,
119  ergo_real* primitiveIntegralList_work,
120  ergo_real resultPreFactor);
121 
122 void
125  ergo_real threshold,
126  ergo_real maxLimitingFactor,
127  ergo_real maxabsDmatelement);
128 
129 int
131  const IntegralInfo & integralInfo,
132  ergo_real threshold,
133  ergo_real* resultMaxLimitingFactor,
134  ergo_real maxDensityMatrixElement);
135 
136 int
138  const IntegralInfo & integralInfo,
139  ergo_real threshold,
140  DistributionSpecStructLabeled* resultList,
141  int maxCountDistrs,
142  ergo_real maxLimitingFactor,
143  const ergo_real* dens,
144  ergo_real maxDensityMatrixElement);
145 
146 int
149  ergo_real toplevelBoxSize,
150  BoxSystem & boxSystem);
151 
152 
153 
154 #endif
template_blas_sqrt
Treal template_blas_sqrt(Treal x)
IntegratorWithMemory
Definition: integrals_2el_repeating.h:59
box_struct
Definition: integrals_2el_utils.h:71
JK_contribs_buffer_struct::summedIntegralList
ergo_real * summedIntegralList
Definition: integrals_2el_utils.h:86
get_list_of_labeled_distrs
int get_list_of_labeled_distrs(const BasisInfoStruct &basisInfo, const IntegralInfo &integralInfo, ergo_real threshold, DistributionSpecStructLabeled *resultList, int maxCountDistrs, ergo_real maxLimitingFactor, const ergo_real *dens, ergo_real maxDensityMatrixElement)
Definition: integrals_2el_utils.cc:369
BasisInfoStruct::noOfBasisFuncs
int noOfBasisFuncs
Definition: basisinfo.h:120
get_list_of_labeled_distrs_maxLimitingFactor
int get_list_of_labeled_distrs_maxLimitingFactor(const BasisInfoStruct &basisInfo, const IntegralInfo &integralInfo, ergo_real threshold, ergo_real *resultMaxLimitingFactor, ergo_real maxDensityMatrixElement)
Definition: integrals_2el_utils.cc:269
DistributionSpecStruct
Definition: basisinfo.h:50
basis_func_extent.h
Code for determining extent of basis functions, for 2-electron integral evaluation.
box_item_struct::originalIndex
int originalIndex
Definition: box_system.h:48
ResultMatContrib::RowColVal::row
int row
Definition: integrals_2el_utils.h:54
DistributionSpecStructLabeled::basisFuncIndex_1
int basisFuncIndex_1
Definition: basisinfo.h:59
create_box_system_and_reorder_distrs
int create_box_system_and_reorder_distrs(int distrCount, DistributionSpecStructLabeled *distrList, ergo_real toplevelBoxSize, BoxSystem &boxSystem)
Definition: integrals_2el_utils.cc:508
DistributionSpecStructLabeled::pairIndex
int pairIndex
Definition: basisinfo.h:61
LOG_CAT_ERROR
#define LOG_CAT_ERROR
Definition: output.h:47
box_struct::basicBox
box_struct_basic basicBox
Definition: integrals_2el_utils.h:73
ergo_real
double ergo_real
Definition: realtype.h:69
create_item_list_from_list_of_distributions
static void create_item_list_from_list_of_distributions(int n, const DistributionSpecStructLabeled *distrList, box_item_struct *itemList)
Definition: integrals_2el_utils.cc:494
compute_extent_for_list_of_distributions
void compute_extent_for_list_of_distributions(int n, DistributionSpecStructLabeled *distrList, ergo_real threshold, ergo_real maxLimitingFactor, ergo_real maxabsDmatelement)
Definition: integrals_2el_utils.cc:252
IntegralInfo::multiply_by_hermite_conversion_matrix_from_left
int multiply_by_hermite_conversion_matrix_from_left(int n1max, int n2max, ergo_real a, ergo_real *A, ergo_real *result) const
Definition: integral_info.cc:261
box_system.h
BoxSystem class representing a hierarchical data structure of boxes in 3D space (an oct-tree).
template_blas_common.h
template_blas_erfc
Treal template_blas_erfc(Treal x)
integrals_general.h
General functionality related to computation of integrals involving Gaussian basis functions.
BasisInfoStruct
Definition: basisinfo.h:112
ResultMatContrib::addContrib
void addContrib(int row, int col, ergo_real value)
Definition: integrals_2el_utils.cc:67
ResultMatContrib::indexInCurrVec
int indexInCurrVec
Definition: integrals_2el_utils.h:61
get_product_simple_primitives
int get_product_simple_primitives(const BasisInfoStruct &basisInfoA, int iA, const BasisInfoStruct &basisInfoB, int iB, DistributionSpecStruct resultList[], int maxCount, ergo_real threshold)
Definition: integrals_general.cc:268
JK_contribs_buffer_struct::partial_dmat_2
ergo_real * partial_dmat_2
Definition: integrals_2el_utils.h:90
template_blas_fabs
Treal template_blas_fabs(Treal x)
DistributionSpecStructLabeled::basisFuncIndex_2
int basisFuncIndex_2
Definition: basisinfo.h:60
compute_extent_for_list_of_distributions
void compute_extent_for_list_of_distributions(int n, DistributionSpecStructLabeled *distrList, ergo_real threshold, ergo_real maxLimitingFactor, ergo_real maxabsDmatelement)
Definition: integrals_2el_utils.cc:252
allocate_buffers_needed_by_integral_code
void allocate_buffers_needed_by_integral_code(const IntegralInfo &integralInfo, int maxNoOfMonomials, int basisFuncListCount_max, JK_contribs_buffer_struct *bufferStruct)
Definition: integrals_2el_utils.cc:126
allocate_buffers_needed_by_integral_code
void allocate_buffers_needed_by_integral_code(const IntegralInfo &integralInfo, int maxNoOfMonomials, int basisFuncListCount_max, JK_contribs_buffer_struct *bufferStruct)
Definition: integrals_2el_utils.cc:126
ResultMatContrib::fetchNextContrib
const RowColVal & fetchNextContrib(int &currVecIndexForFetch, int &indexInCurrVecForFetch) const
Definition: integrals_2el_utils.cc:86
ResultMatContrib::RowColVal::col
int col
Definition: integrals_2el_utils.h:55
ResultMatContrib::currContribCount
int currContribCount
Definition: integrals_2el_utils.h:60
ResultMatContrib::nVectorsMax
static const int nVectorsMax
Definition: integrals_2el_utils.h:58
ResultMatContrib::vList
std::vector< RowColVal > * vList[nVectorsMax]
Definition: integrals_2el_utils.h:63
box_struct::branchCountListForJ
int branchCountListForJ[MAX_NO_OF_BRANCHES]
Definition: integrals_2el_utils.h:77
JK_contribs_buffer_struct::partial_K_2
ergo_real * partial_K_2
Definition: integrals_2el_utils.h:92
create_box_system_and_reorder_distrs
int create_box_system_and_reorder_distrs(int distrCount, DistributionSpecStructLabeled *distrList, ergo_real toplevelBoxSize, BoxSystem &boxSystem)
Definition: integrals_2el_utils.cc:508
get_related_integrals_hermite
int get_related_integrals_hermite(const IntegralInfo &integralInfo, const JK::ExchWeights &paramsCAM, int n1max, int noOfMonomials_1, int n2max, int noOfMonomials_2, ergo_real dx0, ergo_real dx1, ergo_real dx2, ergo_real alpha0, ergo_real resultPreFactor, ergo_real *primitiveIntegralList)
Definition: integrals_hermite.cc:53
IntegralInfo
Contains coefficients needed for quick integral evaluation.
Definition: integral_info.h:94
DistributionSpecStructLabeled
Definition: basisinfo.h:58
box_item_struct
Definition: box_system.h:46
integrals_2el_utils.h
Code for various utilities used by 2-electron integral computation (i.e. computation of J and K matri...
get_max_abs_vector_element
ergo_real get_max_abs_vector_element(int n, const ergo_real *vector)
Definition: integrals_2el_utils.cc:103
MAX_NO_OF_BRANCHES
#define MAX_NO_OF_BRANCHES
Definition: integrals_2el_utils.h:47
MAX_NO_OF_BASIS_FUNC_PAIRS_PER_BATCH
#define MAX_NO_OF_BASIS_FUNC_PAIRS_PER_BATCH
Definition: organize_distrs.h:97
get_related_integrals_h
int get_related_integrals_h(const IntegralInfo &integralInfo, const JK::ExchWeights &CAM_params, int n1max, int noOfMonomials_1, int n2max, int noOfMonomials_2, ergo_real dx0, ergo_real dx1, ergo_real dx2, ergo_real alpha1, ergo_real alpha2, ergo_real alpha0, ergo_real *primitiveIntegralList, ergo_real *primitiveIntegralList_work, ergo_real resultPreFactor)
Definition: integrals_2el_utils.cc:176
compute_extent_for_all_basis_funcs_2el
int compute_extent_for_all_basis_funcs_2el(const IntegralInfo &integralInfo, const BasisInfoStruct &basisInfo, ergo_real *basisFuncExtentList, ergo_real threshold, ergo_real maxAbsDensMatElement)
Definition: basis_func_extent.cc:125
IntegratorWithMemory::do_2e_integral
ergo_real do_2e_integral(const DistributionSpecStruct *psi)
Definition: integrals_2el_repeating.cc:90
ResultMatContrib::RowColVal
Definition: integrals_2el_utils.h:53
get_list_of_labeled_distrs
int get_list_of_labeled_distrs(const BasisInfoStruct &basisInfo, const IntegralInfo &integralInfo, ergo_real threshold, DistributionSpecStructLabeled *resultList, int maxCountDistrs, ergo_real maxLimitingFactor, const ergo_real *dens, ergo_real maxDensityMatrixElement)
Definition: integrals_2el_utils.cc:369
box_struct::distrListForK
distr_list_description_struct distrListForK
Definition: integrals_2el_utils.h:79
free_buffers_needed_by_integral_code
void free_buffers_needed_by_integral_code(JK_contribs_buffer_struct *bufferStruct)
Definition: integrals_2el_utils.cc:152
get_list_of_labeled_distrs_maxLimitingFactor
int get_list_of_labeled_distrs_maxLimitingFactor(const BasisInfoStruct &basisInfo, const IntegralInfo &integralInfo, ergo_real threshold, ergo_real *resultMaxLimitingFactor, ergo_real maxDensityMatrixElement)
Definition: integrals_2el_utils.cc:269
ResultMatContrib::RowColVal::value
ergo_real value
Definition: integrals_2el_utils.h:56
BasisInfoStruct::basisFuncList
BasisFuncStruct * basisFuncList
Definition: basisinfo.h:121
ResultMatContrib
Definition: integrals_2el_utils.h:52
BasisFuncStruct::centerCoords
Vector3D centerCoords
Definition: basisinfo.h:90
integrals_hermite.h
Code for computation of Coulomb integrals of Hermite Gaussians, using the the McMurchie-Davidson sche...
LOG_AREA_INTEGRALS
#define LOG_AREA_INTEGRALS
Definition: output.h:60
JK::ExchWeights
Definition: integral_info.h:148
box_struct::box_struct
box_struct()
Definition: integrals_2el_utils.cc:118
JK_contribs_buffer_struct::primitiveIntegralList_work
ergo_real * primitiveIntegralList_work
Definition: integrals_2el_utils.h:88
distr_list_description_struct
Definition: organize_distrs_mm.h:63
integrals_2el_repeating.h
Functionality for keeping track of certain kinds of integrals that are computed repeatedly,...
ResultMatContrib::currVecIndex
int currVecIndex
Definition: integrals_2el_utils.h:59
JK_contribs_buffer_struct
Definition: integrals_2el_utils.h:85
box_struct_basic
Definition: box_system.h:53
ResultMatContrib::~ResultMatContrib
~ResultMatContrib()
Definition: integrals_2el_utils.cc:62
BoxSystem
Definition: box_system.h:71
organize_distrs.h
Code for organizing a given set of primitive Gaussian distributions (typically coming from basis func...
BoxSystem::get_items_near_point
int get_items_near_point(const box_item_struct *itemList, const ergo_real *coords, ergo_real distance, int *resultOrgIndexList) const
Goes through existning box system to find all items within specified distance from given reference po...
Definition: box_system.cc:430
erfc_inverse
static ergo_real erfc_inverse(ergo_real x, ergo_real requested_accuracy)
Definition: integrals_2el_utils.cc:220
JK_contribs_buffer_struct::partial_dmat_1
ergo_real * partial_dmat_1
Definition: integrals_2el_utils.h:89
ResultMatContrib::ResultMatContrib
ResultMatContrib()
Definition: integrals_2el_utils.cc:51
distance
static ergo_real distance(const ergo_real *a, const ergo_real *b)
Coomputes distance between two points, they do not need to be of the Vector3D type.
Definition: dft_common.cc:526
get_related_integrals_h
int get_related_integrals_h(const IntegralInfo &integralInfo, const JK::ExchWeights &CAM_params, int n1max, int noOfMonomials_1, int n2max, int noOfMonomials_2, ergo_real dx0, ergo_real dx1, ergo_real dx2, ergo_real alpha1, ergo_real alpha2, ergo_real alpha0, ergo_real *primitiveIntegralList, ergo_real *primitiveIntegralList_work, ergo_real resultPreFactor)
Definition: integrals_2el_utils.cc:176
DistributionSpecStructLabeled::distr
DistributionSpecStruct distr
Definition: basisinfo.h:65
IntegralInfo::multiply_by_hermite_conversion_matrix_from_right
int multiply_by_hermite_conversion_matrix_from_right(int n1max, int n2max, ergo_real a, ergo_real *A, ergo_real *result) const
Definition: integral_info.cc:253
do_output
void do_output(int logCategory, int logArea, const char *format,...)
Definition: output.cc:53
JK_contribs_buffer_struct::partial_K_1
ergo_real * partial_K_1
Definition: integrals_2el_utils.h:91
get_max_abs_vector_element
ergo_real get_max_abs_vector_element(int n, const ergo_real *vector)
Definition: integrals_2el_utils.cc:103
ResultMatContrib::currVecReservedSize
int currVecReservedSize
Definition: integrals_2el_utils.h:62
DistributionSpecStruct::extent
ergo_real extent
Definition: basisinfo.h:53
box_struct::branchListForJ
distr_list_description_struct branchListForJ[MAX_NO_OF_BRANCHES]
Definition: integrals_2el_utils.h:75
JK_contribs_buffer_struct::primitiveIntegralList
ergo_real * primitiveIntegralList
Definition: integrals_2el_utils.h:87
DistributionSpecStructLabeled::limitingFactor
ergo_real limitingFactor
Definition: basisinfo.h:63
DistributionSpecStructLabeled::dmatElement
ergo_real dmatElement
Definition: basisinfo.h:64
organize_distrs_mm.h
Code for organizing a given set of primitive Gaussian distributions (typically coming from basis func...
BoxSystem::create_box_system
int create_box_system(box_item_struct *itemList, int noOfItems, ergo_real toplevelBoxSize)
Creates the box system.
Definition: box_system.cc:74
box_struct::branchIndexListForJ
int branchIndexListForJ[MAX_NO_OF_BRANCHES]
Definition: integrals_2el_utils.h:76
free_buffers_needed_by_integral_code
void free_buffers_needed_by_integral_code(JK_contribs_buffer_struct *bufferStruct)
Definition: integrals_2el_utils.cc:152