PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
Solving Kohn-Sham density functional theory: I

The simplest way to use PEXSI to solve Kohn-Sham density functional theory is to use the PPEXSIDFTDriver routine. This routine uses built-in heuristics to obtain values of some parameters in PEXSI and provides a relatively small set of adjustable parameters for users to tune. This routine estimates the chemical potential self-consistently using a combined approach of inertia counting procedure and Newton's iteration through PEXSI. Some heuristic approach is also implemented in this routine for dynamic adjustment of the chemical potential and some stopping criterion.

An example routine is given in driver_ksdft.c, which solves a fake DFT problem by taking a Hamiltonian matrix from examples/lap2dr.matrix.

Here is the structure of the code using the simple driver routine.

...
{
/* Setup the input matrix in distributed compressed sparse column (CSC) format */
...;
/* Initialize PEXSI.
* PPEXSIPlan is a handle communicating with the C++ internal data structure */
PPEXSIPlan plan;
/* Set the outputFileIndex to be the pole index */
/* The first processor for each pole outputs information */
if( mpirank % (nprow * npcol) == 0 ){
outputFileIndex = mpirank / (nprow * npcol);
}
else{
outputFileIndex = -1;
}
MPI_COMM_WORLD,
nprow,
npcol,
outputFileIndex,
&info );
/* Tuning parameters of PEXSI. See PPEXSIOption for explanation of the
* parameters */
PPEXSIOptions options;
options.numPole = 60;
options.temperature = 0.019; // 3000K
options.muPEXSISafeGuard = 0.2;
options.numElectronPEXSITolerance = 0.001;
/* Load the matrix into the internal data structure */
plan,
options,
nrows,
nnz,
nnzLocal,
numColLocal,
colptrLocal,
rowindLocal,
HnzvalLocal,
isSIdentity,
SnzvalLocal,
&info );
/* Call the simple DFT driver using PEXSI */
plan,
options,
numElectronExact,
&muPEXSI,
&numElectronPEXSI,
&muMinInertia,
&muMaxInertia,
&numTotalInertiaIter,
&numTotalPEXSIIter,
&info );
/* Retrieve the density matrix and other quantities from the plan */
plan,
DMnzvalLocal,
EDMnzvalLocal,
FDMnzvalLocal,
&totalEnergyH,
&totalEnergyS,
&totalFreeEnergy,
&info );
/* Clean up */
plan,
&info );
}