ergo
xc_matrix_sparse.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 
37 #if !defined(_XC_MATRIX_SPARSE_H_)
38 #define _XC_MATRIX_SPARSE_H_ 1
39 
40 #define BEGIN_NAMESPACE(x) namespace x {
41 #define END_NAMESPACE(x) } /* x */
42 
43 #include "basisinfo.h"
44 #include "matrix_typedefs.h"
45 #include "realtype.h"
46 
47 
48 typedef ergo_real real;
49 
51 
52 real getXC_seq(const BasisInfoStruct& bis, const IntegralInfo& integralInfo,
53  const Molecule& mol, const Dft::GridParams& gss,
54  int nelectrons, const symmMatrix& dmat,
55  symmMatrix& ksm, real* edfty,
56  std::vector<int> const & permutationHML);
57 
58 real getXC_mt(const BasisInfoStruct& bis, const IntegralInfo& integralInfo,
59  const Molecule& mol, const Dft::GridParams& gss,
60  int nElectrons, const symmMatrix& dens,
61  symmMatrix& xcm, real* xcEnergy,
62  std::vector<int> const & permutationHML);
63 
64 real getUXC_seq(const BasisInfoStruct& bis, const IntegralInfo& integralInfo,
65  const Molecule& mol, const Dft::GridParams& gss, int nElectrons,
66  const symmMatrix& densA, const symmMatrix& densB,
67  symmMatrix& xcA, symmMatrix& xcB, real* xcEnergy,
68  std::vector<int> const & permutationHML);
69 
70 real getUXC_mt(const BasisInfoStruct& bis, const IntegralInfo& integralInfo,
71  const Molecule& mol, const Dft::GridParams& gss, int nElectrons,
72  const symmMatrix& densA, const symmMatrix& densB,
73  symmMatrix& xcA, symmMatrix& xcB, real* xcEnergy,
74  std::vector<int> const & permutationHML);
75 
77 
78 #endif /* _XC_MATRIX_SPARSE_H_ */
XCEvaluator::permutationHML
std::vector< int > const & permutationHML
Definition: xc_matrix_sparse.cc:78
XcData::nThreads
int nThreads
Definition: xc_matrix_sparse.cc:242
Dft::HiCuGridParams::maxError
ergo_real maxError
Definition: grid_params.h:47
getXC_mt
real getXC_mt(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nElectrons, const symmMatrix &dens, symmMatrix &xcm, real *xcEnergy, std::vector< int > const &permutationHML)
Definition: xc_matrix_sparse.cc:274
sparse_matrix.h
realtype.h
Definition of the main floating-point datatype used; the ergo_real type.
grid_hicu.h
Hierarchical Cubature (HiCu) grid generation.
dft_common.h
Common DFT routines. Mostly functional mixing.
XCEvaluator::pattern
Dft::SparsePattern * pattern
Definition: xc_matrix_sparse.cc:81
xc_matrix_sparse.h
The sparse XC matrix evaluator.
XCDistributorLda
distributes a LDA-type xc potential over the XC-matrix elements, with optimization for a closed shell...
Definition: xc_evaluators.h:56
uxc_data::gss
const Dft::GridParams * gss
Definition: xc_matrix.cc:523
xcCallbackLdaU
void xcCallbackLdaU(DftIntegratorBl *grid, real *restrict tmp, int bllen, int blstart, int blend, UksData< Matrix > *d)
modifies data->excmat by adding LDA-type xc contributions, for a general unrestricted case.
Definition: xc_evaluators.h:322
LOG_CAT_ERROR
#define LOG_CAT_ERROR
Definition: output.h:47
DFT_MAX_BLLEN
#define DFT_MAX_BLLEN
Limit for the number of grid point batch length.
Definition: aos.h:41
XCEvaluatorUnrestricted::dMat
SparseMatrix * dMat[2]
Definition: xc_matrix_sparse.cc:344
XcData::xcm
symmMatrix * xcm
Definition: xc_matrix_sparse.cc:239
ergo_real
double ergo_real
Definition: realtype.h:69
xcCallbackGgaU
static void xcCallbackGgaU(DftIntegratorBl *grid, real *restrict tmp, int bllen, int blstart, int blend, UksData< Matrix > *d)
modifes data->excmat by adding GGA-type xc contributions, for a general unrestricted case.
Definition: xc_evaluators.h:353
ErgoMolInfo
Ergo specific implementation of molecule-grid interface.
Definition: dft_common.h:95
KsData
structure describing the data needed by distributors.
Definition: xc_evaluators.h:36
createGridMatrix
Dft::Matrix * createGridMatrix(const Dft::FullMatrix &mat)
Definition: grid_reader.cc:78
XCEvaluatorUnrestricted::~XCEvaluatorUnrestricted
~XCEvaluatorUnrestricted()
Definition: xc_matrix_sparse.cc:358
SparseMatrix
Sparse matrix structure optimized for XC data access pattern.
Definition: sparse_matrix.h:56
BasisInfoStruct::permuteShells
BasisInfoStruct * permuteShells(const int *shellMap, const IntegralInfo &ii) const
a factory method generating new BasisInfo struct with permuted shells and basis functions.
Definition: basisinfo.cc:683
XcData::nElectrons
int nElectrons
Definition: xc_matrix_sparse.cc:238
symmMatrix
MatrixSymmetric< real, matri > symmMatrix
Definition: test_LanczosSeveralLargestEig.cc:69
XCEvaluatorRestricted::~XCEvaluatorRestricted
~XCEvaluatorRestricted()
Definition: xc_matrix_sparse.cc:180
XcData::xcEvaluator
const XCEvaluatorRestricted * xcEvaluator
Definition: xc_matrix_sparse.cc:237
XcData::xcEnergy
real xcEnergy
Definition: xc_matrix_sparse.cc:240
XCEvaluator::gss
const Dft::GridParams & gss
Definition: xc_matrix_sparse.cc:77
UksData
Definition: xc_evaluators.h:220
UksData::energy
real energy
Definition: xc_evaluators.h:224
BasisInfoStruct
Definition: basisinfo.h:112
real
ergo_real real
Definition: test.cc:46
XCEvaluator::bisOrig
const BasisInfoStruct & bisOrig
Definition: xc_matrix_sparse.cc:74
XCEvaluator::integralInfo
const IntegralInfo & integralInfo
Definition: xc_matrix_sparse.cc:75
XCDistributorGga
distributes a GGA-type xc potential over the XC-matrix elements.
Definition: xc_evaluators.h:126
SparseMatrix::addSymmetrizedTo
void addSymmetrizedTo(symmMatrix &sMat, const int *aoMap, std::vector< int > const &permutationHML) const
Assigns itself to a given hierarchic matrix.
Definition: sparse_matrix.cc:239
if
if(!(yy_init))
Definition: ergo_input_parser.c:784
XCEvaluator::bisPermuted
BasisInfoStruct * bisPermuted
Definition: xc_matrix_sparse.cc:80
DftIntegratorBl_
Definition: integrator.h:49
Dft::HiCuGridParams::start_box_size_debug
ergo_real start_box_size_debug
Definition: grid_params.h:49
KsData::energy
real energy
Definition: xc_evaluators.h:40
Dft::GridParams
A structure describing the grid settings.
Definition: grid_params.h:59
getUXC_seq
real getUXC_seq(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nElectrons, const symmMatrix &densA, const symmMatrix &densB, symmMatrix &xcA, symmMatrix &xcB, real *xcEnergy, std::vector< int > const &permutationHML)
Definition: xc_matrix_sparse.cc:418
Dft::GridParams::hicuParams
HiCuGridParams hicuParams
Definition: grid_params.h:74
dft_hicu_grid_init_mutex
static pthread_mutex_t dft_hicu_grid_init_mutex
Definition: xc_matrix_sparse.cc:48
XcData::el
real el
Definition: xc_matrix_sparse.cc:241
dft_get_num_threads
EXTERN_C int dft_get_num_threads(void)
Definition: dft_common.cc:203
DftBlockCallback
void(* DftBlockCallback)(DftIntegratorBl *grid, real *tmp, int bllen, int blstart, int blend, void *cb_data)
Definition: integrator.h:97
IntegralInfo
Contains coefficients needed for quick integral evaluation.
Definition: integral_info.h:94
grid_generate_sparse_pattern
void grid_generate_sparse_pattern(const BasisInfoStruct &bis, ergo_real maxError, ergo_real boxSize, ergo_real startBoxSizeDebug, Dft::SparsePattern &sparsePattern)
Definition: grid_hicu.cc:2814
BasisInfoStruct::noOfShells
int noOfShells
Definition: basisinfo.h:118
Dft::HiCuGridParams::box_size
ergo_real box_size
Definition: grid_params.h:48
sync_threads
int sync_threads(bool release, int nThreads)
creates or destroys a barrier for nThreads.
Definition: dft_common.cc:137
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
SparsePattern
A way to store sparse matrix patterns.
Definition: sparse_pattern.h:53
XCEvaluatorRestricted
Definition: xc_matrix_sparse.cc:165
uxc_data::mol
const Molecule * mol
Definition: xc_matrix.cc:522
Util::TimeMeter::print
void print(int area, const char *routine)
Definition: utilities.h:111
XCEvaluatorRestricted::densityMatrix
SparseMatrix * densityMatrix
Definition: xc_matrix_sparse.cc:166
real
ergo_real real
Definition: xc_matrix_sparse.h:48
XcData
Definition: xc_matrix_sparse.cc:236
utilities.h
Basic OS access utilities.
xcWorker
static void * xcWorker(void *data)
Definition: xc_matrix_sparse.cc:246
XCEvaluator::XCEvaluator
XCEvaluator(const BasisInfoStruct &bisOrig_, const IntegralInfo &integralInfo_, const Molecule &mol_, const Dft::GridParams &gss_, std::vector< int > const &permutationHML_, const symmMatrix &dens)
Definition: xc_matrix_sparse.cc:92
mat
Definition: allocate.cc:39
LOG_CAT_INFO
#define LOG_CAT_INFO
Definition: output.h:49
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.
XCEvaluator::~XCEvaluator
~XCEvaluator()
Definition: xc_matrix_sparse.cc:158
BEGIN_NAMESPACE
#define BEGIN_NAMESPACE(x)
Definition: xc_matrix_sparse.h:40
selected_func
Functional * selected_func
Definition: functionals.c:106
setupShellMap
void setupShellMap(const BasisInfoStruct &bis, int *shellMap, int *aoMap)
Definition: sparse_pattern.cc:446
Dft::GridParams::gridType
GridType gridType
Definition: grid_params.h:70
dft_prop_mutex
static pthread_mutex_t dft_prop_mutex
Definition: xc_matrix_sparse.cc:47
DftGridReader
Definition: grid_reader.cc:166
XCEvaluatorRestricted::getXC
real getXC(int nElectrons, symmMatrix &xcm, real *xcEnergy, int nThreads) const
Computes Fock matrix xcm corresponding to given density matrix dmat.
Definition: xc_matrix_sparse.cc:193
Molecule
Representation of a molecule as a set of nuclei and total charge.
Definition: molecule.h:87
XCEvaluator::mol
const Molecule & mol
Definition: xc_matrix_sparse.cc:76
integrator.h
XCEvaluatorRestricted::XCEvaluatorRestricted
XCEvaluatorRestricted(const BasisInfoStruct &bisOrig_, const IntegralInfo &integralInfo_, const Molecule &mol_, const Dft::GridParams &gss_, std::vector< int > const &permutationHML_, const symmMatrix &density)
Definition: xc_matrix_sparse.cc:168
getXC_seq
real getXC_seq(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nElectrons, const symmMatrix &dens, symmMatrix &xcm, real *xcEnergy, std::vector< int > const &permutationHML)
Definition: xc_matrix_sparse.cc:330
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
XCEvaluator::aoMap
int * aoMap
Definition: xc_matrix_sparse.cc:79
END_NAMESPACE
#define END_NAMESPACE(x)
Definition: xc_matrix_sparse.h:41
xc_evaluators.h
Dft
Definition: grid_matrix.h:42
XCEvaluator
Definition: xc_matrix_sparse.cc:72
Dft::GridParams::TYPE_HICU
@ TYPE_HICU
Definition: grid_params.h:68
do_output
void do_output(int logCategory, int logArea, const char *format,...)
Definition: output.cc:53
XCEvaluatorUnrestricted::getXC
real getXC(int nElectrons, symmMatrix &xcA, symmMatrix &xcB, real *xcEnergy, int nThreads) const
Definition: xc_matrix_sparse.cc:369
xcCallbackLdaR
void xcCallbackLdaR(DftIntegratorBl *grid, real *restrict tmp, int bllen, int blstart, int blend, KsData< Matrix > *data)
modifies data->excmat by adding LDA-type contributions from a given set of bllen grid points as saved...
Definition: xc_evaluators.h:100
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
XCEvaluatorUnrestricted
Definition: xc_matrix_sparse.cc:343
getXC_mt
real getXC_mt(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nElectrons, const symmMatrix &dens, symmMatrix &xcm, real *xcEnergy, std::vector< int > const &permutationHML)
Definition: xc_matrix_sparse.cc:274
Util::TimeMeter
Time-measuring class.
Definition: utilities.h:80
xcCallbackGgaR
void xcCallbackGgaR(DftIntegratorBl *grid, real *restrict tmp, int bllen, int blstart, int blend, KsData< Matrix > *data)
modifies data->excmat by adding GGA-type contributions from a given set of bllen grid points as saved...
Definition: xc_evaluators.h:182
output.h
Functionality for writing output messages to a text file.
grid_is_ready
bool grid_is_ready()
Definition: grid_reader.cc:160
getXC_seq
real getXC_seq(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nelectrons, const symmMatrix &dmat, symmMatrix &ksm, real *edfty, std::vector< int > const &permutationHML)
Definition: xc_matrix_sparse.cc:330
XCEvaluatorUnrestricted::XCEvaluatorUnrestricted
XCEvaluatorUnrestricted(const BasisInfoStruct &bisOrig_, const IntegralInfo &integralInfo_, const Molecule &mol_, const Dft::GridParams &gss_, std::vector< int > const &permutationHML_, const symmMatrix &densA, const symmMatrix &densB)
Definition: xc_matrix_sparse.cc:346
getUXC_mt
real getUXC_mt(const BasisInfoStruct &bis, const IntegralInfo &integralInfo, const Molecule &mol, const Dft::GridParams &gss, int nElectrons, const symmMatrix &densA, const symmMatrix &densB, symmMatrix &xcA, symmMatrix &xcB, real *xcEnergy, std::vector< int > const &permutationHML)
BEGIN_NAMESPACE
#define BEGIN_NAMESPACE(x)
Definition: sparse_pattern.h:41
restrict
#define restrict
Definition: xc_matrix_sparse.cc:66