ergo
integrator.cc File Reference
#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

DftIntegratorBldft_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)
 

Detailed Description

The DFT integrator. (c) Pawel Salek, pawsa.nosp@m.@the.nosp@m.ochem.nosp@m..kth.nosp@m..se. 2001.07.13

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.

Macro Definition Documentation

◆ __CVERSION__

#define __CVERSION__

◆ GRID_BUFF_SZ

#define GRID_BUFF_SZ   100000

the DFT grid buffer length.

grid_getchunk_blocked() will never try to read buffers longer than this.

◆ max

#define max (   a,
 
)    ((a)>(b)? (a):(b))

Typedef Documentation

◆ blocksz_t

typedef int blocksz_t

Function Documentation

◆ 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_integrate()

◆ dft_integrator_bl_free()

◆ dft_integrator_bl_new()

◆ integrate() [1/2]

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.

Parameters
ndmatnumber of density matrices to evaluate
dmatsquare density matrices.
bisa structure describing the used basis set.
mola structure describing the molecule.
gssa structure describing the grid settings.
nThreads- how many threads will execute this function simultaneously. Needed for synchronisation purposes.
cbfunction to be evaluated for each batch of grid points
cb_dataits closure.

References dft_integrate().

Referenced by XCEvaluatorUnrestricted::getXC(), and XCEvaluatorRestricted::getXC().

◆ integrate() [2/2]

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().

◆ output_memory_usage()

static void output_memory_usage ( bool &  a)
static