ergo
integrator.h
Go to the documentation of this file.
1 /* Ergo, version 3.2, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2012 Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU 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  * This program 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 General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Primary academic reference:
19  * Kohn−Sham Density Functional Theory Electronic Structure Calculations
20  * with Linearly Scaling Computational Time and Memory Usage,
21  * Elias Rudberg, Emanuel H. Rubensson, and Pawel Salek,
22  * J. Chem. Theory Comput. 7, 340 (2011),
23  * <http://dx.doi.org/10.1021/ct100611z>
24  *
25  * For further information about Ergo, see <http://www.ergoscf.org>.
26  */
27 
32 #ifndef _INTEGRATOR_H_
33 #define _INTEGRATOR_H_
34 
35 #include "basisinfo.h"
36 #include "matrix_typedefs.h"
37 #include "grid_stream.h"
38 #include "functionals.h"
39 
40 typedef ergo_real real;
42 
43 /* =================================================================== */
44 /* BLOCKED INTEGRATORS */
45 /* =================================================================== */
46 
47 typedef struct DftIntegratorBl_ {
48  /* private to integrator */
49  real (*coor)[3];
51  real* atv; /* the orbital values and their derivatives at given
52  * grid point. The vector is indexed by dftinf_.kso1, etc
53  * the dimensioning is (C syntax) [ntypso][nbast][bllen].
54  */
55  real dfthri; /* threshold on orbital values */
57  int (*shlblocks)[2]; /* shell blocks */
58  int (*basblocks)[2]; /* basis function blocks */
59 #define BASBLOCK(grid,isym) ((grid)->basblocks + (isym)*(grid)->shl_bl_cnt)
60 
61  int ntypso; /* how many different vectors are computed for each
62  * (point,orbital) pair. i.e whether only orbital values
63  * are computed (1), orbital values and first derivatives
64  * (4), etc. */
65 
66  int london_off; /* offset of the "london" orbital derivatives */
67  /* 1 - only values; 4 - values + (x,y,z) derivatives, etc */
68 
69  int ndmat; /* 1 for closed shell, 2 for open shell */
70  int nbast; /* number of basis functions */
71  /* for closed shell, only rho is set. For open shell, only rhoa and rhob
72  * is set. */
73  union {
74  real *rho; /* total density vector; used in closed shell code. */
75  struct { /* used in open-shell code. */
76  real *a, *b;
77  }ho;
78  }r;
79  union {
80  real (*grad)[3]; /*total density gradient; used in closed shell code.*/
81  struct {
82  real (*a)[3], (*b)[3];
83  }rad;
84  }g;
85  /* public, read only */
86  real tgrad[3];/* alpha, also used in closed-shell code */
87  int curr_point; /* index of the current point */
88  real curr_weight; /* the weight at current grid point */
91 
92 /* dft_integrate_ao_bl:
93  numerical integration in atomic orbitals, blocked scheme.
94 */
95 typedef void (*DftBlockCallback)(DftIntegratorBl* grid, real *tmp,
96  int bllen, int blstart, int blend,
97  void* cb_data);
98 
100 dft_integrator_bl_new(Functional* f, int ndmat,
101  int bllen, int needlondon, const BasisInfoStruct& bis);
102 
103 void
105 
106 class Molecule;
107 namespace Dft {
108 class FullMatrix;
109 class SparseMatrix;
110 
111 real integrate(int ndmat, const FullMatrix * const*dmat,
112  const BasisInfoStruct& bis,
113  const Molecule& mol, const Dft::GridParams& gss,
114  int nThreads, DftBlockCallback cb, void *cb_data);
115 
116 real integrate(int nDmat, const SparseMatrix * const *dmat,
117  const BasisInfoStruct& bis,
118  const Molecule& mol, const Dft::GridParams& gss,
119  int nThreads, DftBlockCallback cb, void *cb_data);
120 
121 }
122 
123 #endif /* _INTEGRATOR_H_ */