00001 /* Ergo, version 3.7, a program for linear scaling electronic structure 00002 * calculations. 00003 * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, 00004 * and Anastasia Kruchinina. 00005 * 00006 * This program is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 * 00019 * Primary academic reference: 00020 * Ergo: An open-source program for linear-scaling electronic structure 00021 * calculations, 00022 * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia 00023 * Kruchinina, 00024 * SoftwareX 7, 107 (2018), 00025 * <http://dx.doi.org/10.1016/j.softx.2018.03.005> 00026 * 00027 * For further information about Ergo, see <http://www.ergoscf.org>. 00028 */ 00029 00034 #ifndef _INTEGRATOR_H_ 00035 #define _INTEGRATOR_H_ 00036 00037 #include "basisinfo.h" 00038 #include "matrix_typedefs.h" 00039 #include "grid_stream.h" 00040 #include "functionals.h" 00041 00042 typedef ergo_real real; 00043 typedef ergo_long_real long_real; 00044 00045 /* =================================================================== */ 00046 /* BLOCKED INTEGRATORS */ 00047 /* =================================================================== */ 00048 00049 typedef struct DftIntegratorBl_ { 00050 /* private to integrator */ 00051 real (*coor)[3]; 00052 real* weight; 00053 real* atv; /* the orbital values and their derivatives at given 00054 * grid point. The vector is indexed by dftinf_.kso1, etc 00055 * the dimensioning is (C syntax) [ntypso][nbast][bllen]. 00056 */ 00057 real dfthri; /* threshold on orbital values */ 00058 int nsym, shl_bl_cnt, bas_bl_cnt[8]; 00059 int (*shlblocks)[2]; /* shell blocks */ 00060 int (*basblocks)[2]; /* basis function blocks */ 00061 #define BASBLOCK(grid,isym) ((grid)->basblocks + (isym)*(grid)->shl_bl_cnt) 00062 00063 int ntypso; /* how many different vectors are computed for each 00064 * (point,orbital) pair. i.e whether only orbital values 00065 * are computed (1), orbital values and first derivatives 00066 * (4), etc. */ 00067 00068 int london_off; /* offset of the "london" orbital derivatives */ 00069 /* 1 - only values; 4 - values + (x,y,z) derivatives, etc */ 00070 00071 int ndmat; /* 1 for closed shell, 2 for open shell */ 00072 int nbast; /* number of basis functions */ 00073 /* for closed shell, only rho is set. For open shell, only rhoa and rhob 00074 * is set. */ 00075 union { 00076 real *rho; /* total density vector; used in closed shell code. */ 00077 struct { /* used in open-shell code. */ 00078 real *a, *b; 00079 }ho; 00080 }r; 00081 union { 00082 real (*grad)[3]; /*total density gradient; used in closed shell code.*/ 00083 struct { 00084 real (*a)[3], (*b)[3]; 00085 }rad; 00086 }g; 00087 /* public, read only */ 00088 real tgrad[3];/* alpha, also used in closed-shell code */ 00089 int curr_point; /* index of the current point */ 00090 real curr_weight; /* the weight at current grid point */ 00091 int dogga, needlap, needgb; 00092 } DftIntegratorBl; 00093 00094 /* dft_integrate_ao_bl: 00095 numerical integration in atomic orbitals, blocked scheme. 00096 */ 00097 typedef void (*DftBlockCallback)(DftIntegratorBl* grid, real *tmp, 00098 int bllen, int blstart, int blend, 00099 void* cb_data); 00100 00101 DftIntegratorBl* 00102 dft_integrator_bl_new(Functional* f, int ndmat, 00103 int bllen, int needlondon, const BasisInfoStruct& bis); 00104 00105 void 00106 dft_integrator_bl_free(DftIntegratorBl *res); 00107 00108 class Molecule; 00109 namespace Dft { 00110 class FullMatrix; 00111 class SparseMatrix; 00112 00113 real integrate(int ndmat, const FullMatrix * const*dmat, 00114 const BasisInfoStruct& bis, 00115 const Molecule& mol, const Dft::GridParams& gss, 00116 int nThreads, DftBlockCallback cb, void *cb_data); 00117 00118 real integrate(int nDmat, const SparseMatrix * const *dmat, 00119 const BasisInfoStruct& bis, 00120 const Molecule& mol, const Dft::GridParams& gss, 00121 int nThreads, DftBlockCallback cb, void *cb_data); 00122 00123 } 00124 00125 #endif /* _INTEGRATOR_H_ */