PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
c_pexsi_interface.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 The Regents of the University of California,
3  through Lawrence Berkeley National Laboratory.
4 
5  Author: Lin Lin
6 
7  This file is part of PEXSI. All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  (1) Redistributions of source code must retain the above copyright notice, this
13  list of conditions and the following disclaimer.
14  (2) Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  (3) Neither the name of the University of California, Lawrence Berkeley
18  National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
19  be used to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  You are under no obligation whatsoever to provide any bug fixes, patches, or
34  upgrades to the features, functionality or performance of the source code
35  ("Enhancements") to anyone; however, if you choose to make your Enhancements
36  available either publicly, or directly to Lawrence Berkeley National
37  Laboratory, without imposing a separate written license agreement for such
38  Enhancements, then you hereby grant the following license: a non-exclusive,
39  royalty-free perpetual license to install, use, modify, prepare derivative
40  works, incorporate into other computer software, distribute, and sublicense
41  such enhancements or derivative works thereof, in binary and source code form.
42 */
50 #ifndef _PEXSI_C_PEXSI_INTERFACE_H_
51 #define _PEXSI_C_PEXSI_INTERFACE_H_
52 #include "mpi.h"
53 #include <stdint.h>
54 
55 #ifdef __cplusplus
56 extern "C"{
57 #endif
58 
71  char* filename,
72  int* size,
73  int* nnz,
74  int* nnzLocal,
75  int* numColLocal,
76  MPI_Comm comm );
77 
98  char* filename,
99  int size,
100  int nnz,
101  int nnzLocal,
102  int numColLocal,
103  int* colptrLocal,
104  int* rowindLocal,
105  double* nzvalLocal,
106  MPI_Comm comm );
107 
108 
121  char* filename,
122  int* size,
123  int* nnz,
124  int* nnzLocal,
125  int* numColLocal,
126  MPI_Comm comm );
127 
151  char* filename,
152  int size,
153  int nnz,
154  int nnzLocal,
155  int numColLocal,
156  int* colptrLocal,
157  int* rowindLocal,
158  double* nzvalLocal,
159  MPI_Comm comm );
160 
161 
162 
163 // *********************************************************************
164 // The following routines belong to the second version of the interface
165 // *********************************************************************
166 
174 typedef intptr_t PPEXSIPlan;
175 
180 typedef struct {
184  double temperature;
188  double gap;
192  double deltaE;
196  int numPole;
209  double muMin0;
213  double muMax0;
254  int ordering;
267 } PPEXSIOptions;
268 
269 
279  PPEXSIOptions* options );
280 
281 
319 PPEXSIPlan PPEXSIPlanInitialize(
320  MPI_Comm comm,
321  int numProcRow,
322  int numProcCol,
323  int outputFileIndex,
324  int* info );
325 
326 
357  PPEXSIPlan plan,
358  PPEXSIOptions options,
359  int nrows,
360  int nnz,
361  int nnzLocal,
362  int numColLocal,
363  int* colptrLocal,
364  int* rowindLocal,
365  double* HnzvalLocal,
366  int isSIdentity,
367  double* SnzvalLocal,
368  int* info );
369 
382  PPEXSIPlan plan,
383  PPEXSIOptions options,
384  int* info );
385 
398  PPEXSIPlan plan,
399  PPEXSIOptions options,
400  int* info );
401 
402 
425  /* Input parameters */
426  PPEXSIPlan plan,
427  PPEXSIOptions options,
428  int numShift,
429  double* shiftList,
430  /* Output parameters */
431  double* inertiaList,
432  int* info );
433 
434 
492  PPEXSIPlan plan,
493  PPEXSIOptions options,
494  double mu,
495  double numElectronExact,
496  double* numElectronPEXSI,
497  double* numElectronDrvMuPEXSI,
498  int* info );
499 
500 
519  PPEXSIPlan plan,
520  PPEXSIOptions options,
521  double* AnzvalLocal,
522  double* AinvnzvalLocal,
523  int* info );
524 
525 
547  PPEXSIPlan plan,
548  PPEXSIOptions options,
549  double* AnzvalLocal,
550  double* AinvnzvalLocal,
551  int* info );
552 
553 
576  PPEXSIPlan plan,
577  PPEXSIOptions options,
578  double* AnzvalLocal,
579  double* AinvnzvalLocal,
580  int* info );
581 
582 
663 void PPEXSIDFTDriver(
664  PPEXSIPlan plan,
665  PPEXSIOptions options,
666  double numElectronExact,
667  double* muPEXSI,
668  double* numElectronPEXSI,
669  double* muMinInertia,
670  double* muMaxInertia,
671  int* numTotalInertiaIter,
672  int* numTotalPEXSIIter,
673  int* info );
674 
694  PPEXSIPlan plan,
695  double* DMnzvalLocal,
696  double* EDMnzvalLocal,
697  double* FDMnzvalLocal,
698  double* totalEnergyH,
699  double* totalEnergyS,
700  double* totalFreeEnergy,
701  int* info );
702 
703 
704 
705 
715 void PPEXSIPlanFinalize(
716  PPEXSIPlan plan,
717  int* info );
718 
719 
720 #ifdef __cplusplus
721 }// extern "C"
722 #endif
723 
724 #endif // _PEXSI_C_PEXSI_INTERFACE_H_
void PPEXSIInertiaCountRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int numShift, double *shiftList, double *inertiaList, int *info)
Directly compute the negative inertia at a set of shifts.
Definition: interface.cpp:448
double muMin0
Initial guess of lower bound for mu.
Definition: c_pexsi_interface.h:209
void ReadDistSparseMatrixFormattedInterface(char *filename, int size, int nnz, int nnzLocal, int numColLocal, int *colptrLocal, int *rowindLocal, double *nzvalLocal, MPI_Comm comm)
Reading the data of a formatted DistSparseMatrix.
Definition: interface.cpp:120
void PPEXSILoadRealSymmetricHSMatrix(PPEXSIPlan plan, PPEXSIOptions options, int nrows, int nnz, int nnzLocal, int numColLocal, int *colptrLocal, int *rowindLocal, double *HnzvalLocal, int isSIdentity, double *SnzvalLocal, int *info)
Load the real symmetric H and S matrices into the PEXSI internal data structure.
Definition: interface.cpp:306
void PPEXSIPlanFinalize(PPEXSIPlan plan, int *info)
Release the memory used by PEXSI.
Definition: interface.cpp:711
double muInertiaExpansion
If the chemical potential is not in the initial interval, the interval is expanded by muInertiaExpans...
Definition: c_pexsi_interface.h:223
int ordering
Ordering strategy for factorization and selected inversion.
Definition: c_pexsi_interface.h:254
double numElectronPEXSITolerance
Stopping criterion of the PEXSI iteration in terms of the number of electrons compared to numElectron...
Definition: c_pexsi_interface.h:233
intptr_t PPEXSIPlan
A handle for holding the internal PEXSI data structure.
Definition: c_pexsi_interface.h:174
double muInertiaTolerance
Stopping criterion in terms of the chemical potential for the inertia counting procedure.
Definition: c_pexsi_interface.h:218
PPEXSIPlan PPEXSIPlanInitialize(MPI_Comm comm, int numProcRow, int numProcCol, int outputFileIndex, int *info)
Initialize the PEXSI plan.
Definition: interface.cpp:274
double muMax0
Initial guess of upper bound for mu.
Definition: c_pexsi_interface.h:213
void PPEXSISetDefaultOptions(PPEXSIOptions *options)
Set the default options for DFT driver.
Definition: interface.cpp:251
void PPEXSIDFTDriver(PPEXSIPlan plan, PPEXSIOptions options, double numElectronExact, double *muPEXSI, double *numElectronPEXSI, double *muMinInertia, double *muMaxInertia, int *numTotalInertiaIter, int *numTotalPEXSIIter, int *info)
Simplified driver for solving Kohn-Sham DFT.
Definition: interface.cpp:604
Structure for the input parameters in DFT calculations.
Definition: c_pexsi_interface.h:180
void PPEXSICalculateFermiOperatorReal(PPEXSIPlan plan, PPEXSIOptions options, double mu, double numElectronExact, double *numElectronPEXSI, double *numElectronDrvMuPEXSI, int *info)
Compute the density matrices and number of electrons for a given chemical potential.
Definition: interface.cpp:495
void PPEXSISelInvRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, double *AinvnzvalLocal, int *info)
Simplified driver interface for computing the selected elements of a real symmetric matrix...
Definition: interface.cpp:538
int npSymbFact
Number of processors for PARMETIS/PT-SCOTCH. Only used if the ordering == 0.
Definition: c_pexsi_interface.h:259
void PPEXSISymbolicFactorizeRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
Definition: interface.cpp:354
void ReadDistSparseMatrixFormattedHeadInterface(char *filename, int *size, int *nnz, int *nnzLocal, int *numColLocal, MPI_Comm comm)
Read the sizes of a DistSparseMatrix in formatted form (txt) for allocating memory in C...
Definition: interface.cpp:63
int isInertiaCount
Whether inertia counting is used at the very beginning.
Definition: c_pexsi_interface.h:200
void PPEXSISymbolicFactorizeComplexSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for complex...
Definition: interface.cpp:401
void ReadDistSparseMatrixHeadInterface(char *filename, int *size, int *nnz, int *nnzLocal, int *numColLocal, MPI_Comm comm)
Read the sizes of a DistSparseMatrix in unformatted form (csc) for allocating memory in C...
Definition: interface.cpp:153
int maxPEXSIIter
Maximum number of PEXSI iterations after each inertia counting procedure.
Definition: c_pexsi_interface.h:205
void ParaReadDistSparseMatrixInterface(char *filename, int size, int nnz, int nnzLocal, int numColLocal, int *colptrLocal, int *rowindLocal, double *nzvalLocal, MPI_Comm comm)
Actual reading the data of a DistSparseMatrix using MPI-IO, assuming that the arrays have been alloca...
Definition: interface.cpp:214
void PPEXSISelInvComplexSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, double *AinvnzvalLocal, int *info)
Simplified driver interface for computing the selected elements of a complex symmetric matrix...
Definition: interface.cpp:571
double deltaE
An upper bound for the spectral radius of .
Definition: c_pexsi_interface.h:192
int isSymbolicFactorize
Whether to perform symbolic factorization.
Definition: c_pexsi_interface.h:243
int matrixType
matrixType (global) Type of input H and S matrices.
Definition: c_pexsi_interface.h:239
double temperature
Temperature, in the same unit as H.
Definition: c_pexsi_interface.h:184
void PPEXSIRetrieveRealSymmetricDFTMatrix(PPEXSIPlan plan, double *DMnzvalLocal, double *EDMnzvalLocal, double *FDMnzvalLocal, double *totalEnergyH, double *totalEnergyS, double *totalFreeEnergy, int *info)
Retrieve the output matrices after running PPEXSIDFTDriver.
Definition: interface.cpp:664
double gap
Spectral gap. Note This can be set to be 0 in most cases.
Definition: c_pexsi_interface.h:188
double muPEXSISafeGuard
Safe guard criterion in terms of the chemical potential to reinvoke the inertia counting procedure...
Definition: c_pexsi_interface.h:228
int verbosity
The level of output information.
Definition: c_pexsi_interface.h:266
int numPole
Number of terms in the pole expansion.
Definition: c_pexsi_interface.h:196