ergo
integrator.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 
34 #ifndef _INTEGRATOR_H_
35 #define _INTEGRATOR_H_
36 
37 #include "basisinfo.h"
38 #include "matrix_typedefs.h"
39 #include "grid_stream.h"
40 #include "functionals.h"
41 
42 typedef ergo_real real;
44 
45 /* =================================================================== */
46 /* BLOCKED INTEGRATORS */
47 /* =================================================================== */
48 
49 typedef struct DftIntegratorBl_ {
50  /* private to integrator */
51  real (*coor)[3];
53  real* atv; /* the orbital values and their derivatives at given
54  * grid point. The vector is indexed by dftinf_.kso1, etc
55  * the dimensioning is (C syntax) [ntypso][nbast][bllen].
56  */
57  real dfthri; /* threshold on orbital values */
59  int (*shlblocks)[2]; /* shell blocks */
60  int (*basblocks)[2]; /* basis function blocks */
61 #define BASBLOCK(grid,isym) ((grid)->basblocks + (isym)*(grid)->shl_bl_cnt)
62 
63  int ntypso; /* how many different vectors are computed for each
64  * (point,orbital) pair. i.e whether only orbital values
65  * are computed (1), orbital values and first derivatives
66  * (4), etc. */
67 
68  int london_off; /* offset of the "london" orbital derivatives */
69  /* 1 - only values; 4 - values + (x,y,z) derivatives, etc */
70 
71  int ndmat; /* 1 for closed shell, 2 for open shell */
72  int nbast; /* number of basis functions */
73  /* for closed shell, only rho is set. For open shell, only rhoa and rhob
74  * is set. */
75  union {
76  real *rho; /* total density vector; used in closed shell code. */
77  struct { /* used in open-shell code. */
78  real *a, *b;
79  }ho;
80  }r;
81  union {
82  real (*grad)[3]; /*total density gradient; used in closed shell code.*/
83  struct {
84  real (*a)[3], (*b)[3];
85  }rad;
86  }g;
87  /* public, read only */
88  real tgrad[3];/* alpha, also used in closed-shell code */
89  int curr_point; /* index of the current point */
90  real curr_weight; /* the weight at current grid point */
93 
94 /* dft_integrate_ao_bl:
95  numerical integration in atomic orbitals, blocked scheme.
96 */
97 typedef void (*DftBlockCallback)(DftIntegratorBl* grid, real *tmp,
98  int bllen, int blstart, int blend,
99  void* cb_data);
100 
102 dft_integrator_bl_new(Functional* f, int ndmat,
103  int bllen, int needlondon, const BasisInfoStruct& bis);
104 
105 void
107 
108 class Molecule;
109 namespace Dft {
110 class FullMatrix;
111 class SparseMatrix;
112 
113 real integrate(int ndmat, const FullMatrix * const*dmat,
114  const BasisInfoStruct& bis,
115  const Molecule& mol, const Dft::GridParams& gss,
116  int nThreads, DftBlockCallback cb, void *cb_data);
117 
118 real integrate(int nDmat, const SparseMatrix * const *dmat,
119  const BasisInfoStruct& bis,
120  const Molecule& mol, const Dft::GridParams& gss,
121  int nThreads, DftBlockCallback cb, void *cb_data);
122 
123 }
124 
125 #endif /* _INTEGRATOR_H_ */
DftIntegratorBl_::bas_bl_cnt
int bas_bl_cnt[8]
Definition: integrator.h:58
DftIntegratorBl_::shlblocks
int(* shlblocks)[2]
Definition: integrator.h:59
sparse_matrix.h
BasisInfoStruct::noOfBasisFuncs
int noOfBasisFuncs
Definition: basisinfo.h:120
dft_common.h
Common DFT routines. Mostly functional mixing.
DftIntegratorBl_::a
real * a
Definition: integrator.h:78
DftIntegratorBl_::grad
real(* grad)[3]
Definition: integrator.h:82
DFT_MAX_BLLEN
#define DFT_MAX_BLLEN
Limit for the number of grid point batch length.
Definition: aos.h:41
ergo_real
double ergo_real
Definition: realtype.h:69
ErgoMolInfo
Ergo specific implementation of molecule-grid interface.
Definition: dft_common.h:95
DftIntegratorBl_::needlap
int needlap
Definition: integrator.h:91
dft_integrator_bl_free
void dft_integrator_bl_free(DftIntegratorBl *res)
Definition: integrator.cc:151
END_NAMESPACE
#define END_NAMESPACE(x)
Definition: sparse_pattern.h:42
createGridMatrix
Dft::Matrix * createGridMatrix(const Dft::FullMatrix &mat)
Definition: grid_reader.cc:78
DftIntegratorBl_::ho
struct DftIntegratorBl_::@0::@2 ho
DftIntegratorBl_::dogga
int dogga
Definition: integrator.h:91
SparseMatrix
Sparse matrix structure optimized for XC data access pattern.
Definition: sparse_matrix.h:56
Dft::integrate
real integrate(int ndmat, const FullMatrix *const *dmat, const BasisInfoStruct &bis, const Molecule &mol, const Dft::GridParams &gss, int nThreads, DftBlockCallback cb, void *cb_data)
DftIntegratorBl_::london_off
int london_off
Definition: integrator.h:68
Dft::FullMatrix
Definition: grid_matrix.h:53
BasisInfoStruct
Definition: basisinfo.h:112
real
ergo_real real
Definition: test.cc:46
dft_integrate
static real dft_integrate(int ndmat, const DensityType *const *dmat, const BasisInfoStruct &bis, const Molecule &mol, const Dft::GridParams &gss, int nThreads, DftBlockCallback cb, void *cb_data)
Definition: integrator.cc:187
DftIntegratorBl_::needgb
int needgb
Definition: integrator.h:91
dft_integrator_bl_new
DftIntegratorBl * dft_integrator_bl_new(Functional *f, int ndmat, int bllen, int needlondon, const BasisInfoStruct &bis)
Definition: integrator.cc:109
dft_get_orbs
void dft_get_orbs(int nvclen, ergo_real *gao, const ergo_real(*coor)[3], int nblcnt, int(*iblcks)[2], int nder, const BasisInfoStruct &bis)
Computes values of basis functions at specified points in space.
Definition: aos.cc:193
DftIntegratorBl_
Definition: integrator.h:49
DftIntegratorBl_::curr_point
int curr_point
Definition: integrator.h:89
DftIntegratorBl_::weight
real * weight
Definition: integrator.h:52
output_memory_usage
static void output_memory_usage(bool &a)
Definition: integrator.cc:173
DftIntegratorBl_::g
union DftIntegratorBl_::@1 g
Dft::GridParams
A structure describing the grid settings.
Definition: grid_params.h:59
DftIntegratorBl_::ntypso
int ntypso
Definition: integrator.h:63
DftIntegratorBl_::r
union DftIntegratorBl_::@0 r
DftIntegratorBl_::b
real * b
Definition: integrator.h:78
grid_stream.h
Streaming grid generator.
DftIntegratorBl_::curr_weight
real curr_weight
Definition: integrator.h:90
long_real
ergo_long_real long_real
Definition: integrator.h:43
real
ergo_real real
Definition: integrator.h:42
DftBlockCallback
void(* DftBlockCallback)(DftIntegratorBl *grid, real *tmp, int bllen, int blstart, int blend, void *cb_data)
Definition: integrator.h:97
dft_integrator_bl_new
DftIntegratorBl * dft_integrator_bl_new(Functional *f, int ndmat, int bllen, int needlondon, const BasisInfoStruct &bis)
Definition: integrator.cc:109
BasisInfoStruct::noOfShells
int noOfShells
Definition: basisinfo.h:118
DftIntegratorBl_::rad
struct DftIntegratorBl_::@1::@3 rad
dal_new
#define dal_new(sz, tp)
Definition: dft_common.h:125
sync_threads
int sync_threads(bool release, int nThreads)
creates or destroys a barrier for nThreads.
Definition: dft_common.cc:137
dal_malloc
#define dal_malloc(sz)
Definition: dft_common.h:128
grid_open_full
DftGridReader * grid_open_full(const class GridGenMolInfo *mol_info, const Dft::GridParams &gss, Dft::SparsePattern *pattern, const Dft::Matrix *dmat, const BasisInfoStruct &bis)
Returns a handle to a grid file.
Definition: grid_reader.cc:282
Functional_::is_gga
IsGGAFunc is_gga
Definition: functionals.h:403
Functional_
Definition: functionals.h:401
mat
Definition: allocate.cc:39
FSYM
#define FSYM(a)
Definition: dft.h:74
dft_integrator_bl_free
void dft_integrator_bl_free(DftIntegratorBl *res)
Definition: integrator.cc:151
matrix_typedefs.h
Header file with typedefs for matrix and vector types. The levels of hierarchic matrices are defined ...
basisinfo.h
Code for setting up basis functions starting from shells.
DftIntegratorBl_::nbast
int nbast
Definition: integrator.h:72
selected_func
Functional * selected_func
Definition: functionals.c:106
DftIntegratorBl_::rho
real * rho
Definition: integrator.h:76
grid_getchunk_blocked
int grid_getchunk_blocked(DftGridReader *rawgrid, int maxlen, int *nBlocks, int *shlBlocks, real(*coor)[3], real *weight)
grid_getchunk_blocked() reads grid data also with screening information if only nblocks and shlblocks...
Definition: grid_reader.cc:325
DftIntegratorBl_::dfthri
real dfthri
Definition: integrator.h:57
GRID_BUFF_SZ
#define GRID_BUFF_SZ
the DFT grid buffer length.
Definition: integrator.cc:91
output_current_memory_usage
void output_current_memory_usage(int logArea, const char *contextString)
Definition: output.cc:186
DftIntegratorBl_::atv
real * atv
Definition: integrator.h:53
DftGridReader
Definition: grid_reader.cc:166
DftIntegratorBl_::tgrad
real tgrad[3]
Definition: integrator.h:88
Molecule
Representation of a molecule as a set of nuclei and total charge.
Definition: molecule.h:87
DftIntegratorBl_::basblocks
int(* basblocks)[2]
Definition: integrator.h:60
integrator.h
rho-mat.h
integrate
real integrate(int ndmat, const FullMatrix *const *dmat, const BasisInfoStruct &bis, const Molecule &mol, const Dft::GridParams &gss, int nThreads, DftBlockCallback cb, void *cb_data)
reads the grid and calls the callback function for each group of grid points.
Definition: integrator.cc:292
grid_close
void grid_close(DftGridReader *rawgrid)
Closes the shared grid handle that is specifed as the argument.
Definition: grid_reader.cc:386
DftIntegratorBl
struct DftIntegratorBl_ DftIntegratorBl
blocksz_t
int blocksz_t
Definition: integrator.cc:84
Dft
Definition: grid_matrix.h:42
DftIntegratorBl_::ndmat
int ndmat
Definition: integrator.h:71
DftIntegratorBl_::nsym
int nsym
Definition: integrator.h:58
blgetsos_
void blgetsos_(int *nvclen, real GSO[], real COOR[], int *NBLCNT, int IBLCKS[], real WORK[], int *LWORK, int *NBAST, int *DOLND, int *DOGGA, real *DFTHRI, const int *IPRINT)
Dft::Matrix
Definition: grid_matrix.h:44
aos.h
grid_reader.h
Grid Generator interface. Functions for opening grid file, reading chunks from it,...
LOG_AREA_DFT
#define LOG_AREA_DFT
Definition: output.h:62
DftIntegratorBl_::coor
real(* coor)[3]
Definition: integrator.h:51
functionals.h
output.h
Functionality for writing output messages to a text file.
DftIntegratorBl_::shl_bl_cnt
int shl_bl_cnt
Definition: integrator.h:58
getrho_blocked_gga
void getrho_blocked_gga(int nbast, const real *dmat, const real *restrict gao, const int *nblocks, const int(*iblocks)[2], int ldaib, real *tmp, int nvclen, real *rho, real(*grad)[3])
Computes the expectation value <o|dmat|o'> and its derivatives for a symmetric matrix and given set o...
Definition: rho-mat.cc:187
getrho_blocked_lda
void getrho_blocked_lda(int nbast, const real *dmat, const real *restrict gao, const int *nblocks, const int(*iblocks)[2], int ldaib, real *tmp, int nvclen, real *rho)
Computes the expectation value <o|dmat|o'> for a symmetric matrix and given set of precomputed orbita...
Definition: rho-mat.cc:94
BEGIN_NAMESPACE
#define BEGIN_NAMESPACE(x)
Definition: sparse_pattern.h:41
ergo_long_real
double ergo_long_real
Definition: realtype.h:70
ergoShellsToOrbs
void ergoShellsToOrbs(const int *nshlbl, const int(*shlblock)[2], int *norbbl, int(*orbblock)[2], const BasisInfoStruct &bis)
transform shell block indices to orbital block indices.
Definition: dft_common.cc:708