ergo
|
The DFT integrator. More...
#include <assert.h>
#include <cmath>
#include <pthread.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "aos.h"
#include "integrator.h"
#include "functionals.h"
#include "output.h"
#include "rho-mat.h"
#include "sparse_matrix.h"
#include "grid_reader.h"
#include "dft_common.h"
Macros | |
#define | __CVERSION__ |
#define | max(a, b) ((a)>(b)? (a):(b)) |
#define | GRID_BUFF_SZ 100000 |
the DFT grid buffer length. More... | |
Typedefs | |
typedef int | blocksz_t |
Functions | |
DftIntegratorBl * | dft_integrator_bl_new (Functional *f, int ndmat, int bllen, int needlondon, const BasisInfoStruct &bis) |
void | dft_integrator_bl_free (DftIntegratorBl *res) |
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) |
static void | output_memory_usage (bool &a) |
template<typename DensityType > | |
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) |
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. More... | |
real | integrate (int nDmat, const SparseMatrix *const *dmat, const BasisInfoStruct &bis, const Molecule &mol, const Dft::GridParams &gss, int nThreads, DftBlockCallback cb, void *cb_data) |
The DFT integrator.
(c) Pawel Salek, pawsa. 2001.07.13 @the ochem .kth .se
The WRKMEM memory block is not used since it should be deprecated. It might be therefore useful to enable memory overcommiting. On linux-2.4.x it can be done with echo 1 > /proc/sys/vm/overcommit_memory or a sysctl call. We use it only to pass it to other Fortran routines we call.
OPTIMIZATIONS: ordinary calculation uses approximately only 4% total CPU time in this code. Most likely, the optimizations should be sought somewhere else. The simple optimization path is though to use block structure of kappa matrices to reduce time by 2 for larger matrices.
integrator.cc provides dft_integrator() routine. It is passed some standard parameters and a table of callbacks and associated closures (callback data). The callback gets the grid data for current point as well as its own closure.
The grid file is assumed to be available on call to dft_integrator(). Otherwise, it is a black-box implementation.
#define __CVERSION__ |
#define GRID_BUFF_SZ 100000 |
the DFT grid buffer length.
grid_getchunk_blocked() will never try to read buffers longer than this.
Referenced by dft_integrate(), and dft_integrator_bl_new().
#define max | ( | a, | |
b | |||
) | ((a)>(b)? (a):(b)) |
Referenced by mat::bisection(), mat::arn::LanczosSeveralLargestEig< Treal, Tmatrix, Tvector >::computeEigenPairTri(), PurificationGeneral< MatrixType >::find_eig_gaps_every_iter(), get_eucl_diff_with_adapted_accuracy(), PurificationGeneral< MatrixType >::get_max_double(), Purification_sp2acc< MatrixType >::return_constant_C(), and template_blas_get_num_limit_max().
typedef int blocksz_t |
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 | ||
) |
|
static |
References DftIntegratorBl_::atv, DftIntegratorBl_::bas_bl_cnt, DftIntegratorBl_::basblocks, DftIntegratorBl_::coor, createGridMatrix(), DftIntegratorBl_::curr_point, dal_new, dft_get_orbs(), dft_integrator_bl_free(), dft_integrator_bl_new(), DFT_MAX_BLLEN, DftIntegratorBl_::dogga, ergoShellsToOrbs(), free(), FSYM, DftIntegratorBl_::g, getrho_blocked_gga(), getrho_blocked_lda(), GRID_BUFF_SZ, grid_close(), grid_getchunk_blocked(), grid_open_full(), BasisInfoStruct::noOfBasisFuncs, output_memory_usage(), DftIntegratorBl_::r, DftIntegratorBl_::rad, DftIntegratorBl_::rho, selected_func, DftIntegratorBl_::shl_bl_cnt, DftIntegratorBl_::shlblocks, sync_threads(), and DftIntegratorBl_::weight.
Referenced by Dft::integrate(), and integrate().
void dft_integrator_bl_free | ( | DftIntegratorBl * | res | ) |
References DftIntegratorBl_::atv, DftIntegratorBl_::basblocks, DftIntegratorBl_::coor, free(), DftIntegratorBl_::g, DftIntegratorBl_::grad, DftIntegratorBl_::r, DftIntegratorBl_::rho, DftIntegratorBl_::shlblocks, and DftIntegratorBl_::weight.
Referenced by compute_grid_thread_func(), and dft_integrate().
DftIntegratorBl* dft_integrator_bl_new | ( | Functional * | f, |
int | ndmat, | ||
int | bllen, | ||
int | needlondon, | ||
const BasisInfoStruct & | bis | ||
) |
References DftIntegratorBl_::atv, DftIntegratorBl_::basblocks, DftIntegratorBl_::coor, dal_malloc, dal_new, DftIntegratorBl_::dfthri, DftIntegratorBl_::dogga, DftIntegratorBl_::g, DftIntegratorBl_::grad, GRID_BUFF_SZ, DftIntegratorBl_::ho, Functional_::is_gga, DftIntegratorBl_::london_off, DftIntegratorBl_::nbast, DftIntegratorBl_::ndmat, DftIntegratorBl_::needgb, DftIntegratorBl_::needlap, BasisInfoStruct::noOfBasisFuncs, BasisInfoStruct::noOfShells, DftIntegratorBl_::nsym, DftIntegratorBl_::ntypso, DftIntegratorBl_::r, DftIntegratorBl_::rad, DftIntegratorBl_::rho, DftIntegratorBl_::shlblocks, and DftIntegratorBl_::weight.
Referenced by compute_grid_thread_func(), and 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 | ||
) |
reads the grid and calls the callback function for each group of grid points.
As a courtesy, evaluates first for each batch the density.
ndmat | number of density matrices to evaluate |
dmat | square density matrices. |
bis | a structure describing the used basis set. |
mol | a structure describing the molecule. |
gss | a structure describing the grid settings. |
nThreads | - how many threads will execute this function simultaneously. Needed for synchronisation purposes. |
cb | function to be evaluated for each batch of grid points |
cb_data | its closure. |
References dft_integrate().
Referenced by XCEvaluatorRestricted::getXC(), and XCEvaluatorUnrestricted::getXC().
real integrate | ( | int | nDmat, |
const SparseMatrix *const * | dmat, | ||
const BasisInfoStruct & | bis, | ||
const Molecule & | mol, | ||
const Dft::GridParams & | gss, | ||
int | nThreads, | ||
DftBlockCallback | cb, | ||
void * | cb_data | ||
) |
References dft_integrate().
|
static |
References LOG_AREA_DFT, and output_current_memory_usage().
Referenced by dft_integrate().