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;
217  double mu0;
263  int ordering;
282 } PPEXSIOptions;
283 
284 
294  PPEXSIOptions* options );
295 
296 
341 PPEXSIPlan PPEXSIPlanInitialize(
342  MPI_Comm comm,
343  int numProcRow,
344  int numProcCol,
345  int outputFileIndex,
346  int* info );
347 
348 
379  PPEXSIPlan plan,
380  PPEXSIOptions options,
381  int nrows,
382  int nnz,
383  int nnzLocal,
384  int numColLocal,
385  int* colptrLocal,
386  int* rowindLocal,
387  double* HnzvalLocal,
388  int isSIdentity,
389  double* SnzvalLocal,
390  int* info );
391 
404  PPEXSIPlan plan,
405  PPEXSIOptions options,
406  int* info );
407 
420  PPEXSIPlan plan,
421  PPEXSIOptions options,
422  int* info );
423 
424 
447  /* Input parameters */
448  PPEXSIPlan plan,
449  PPEXSIOptions options,
450  int numShift,
451  double* shiftList,
452  /* Output parameters */
453  double* inertiaList,
454  int* info );
455 
456 
457 
458 
459 
460 
461 
462 
463 
494  PPEXSIPlan plan,
495  PPEXSIOptions options,
496  int nrows,
497  int nnz,
498  int nnzLocal,
499  int numColLocal,
500  int* colptrLocal,
501  int* rowindLocal,
502  double* HnzvalLocal,
503  int isSIdentity,
504  double* SnzvalLocal,
505  int* info );
506 
519  PPEXSIPlan plan,
520  PPEXSIOptions options,
521  int* info );
522 
535  PPEXSIPlan plan,
536  PPEXSIOptions options,
537  int* info );
538 
539 
561 /*
562 void PPEXSIInertiaCountRealUnsymmetricMatrix(
563  PPEXSIPlan plan,
564  PPEXSIOptions options,
565  int numShift,
566  double* shiftList,
567  double* inertiaList,
568  int* info );
569 */
570 
571 
572 
573 
574 
575 
576 
577 
578 
579 
580 
581 
639  PPEXSIPlan plan,
640  PPEXSIOptions options,
641  double mu,
642  double numElectronExact,
643  double* numElectronPEXSI,
644  double* numElectronDrvMuPEXSI,
645  int* info );
646 
647 
666  PPEXSIPlan plan,
667  PPEXSIOptions options,
668  double* AnzvalLocal,
669  double* AinvnzvalLocal,
670  int* info );
671 
672 
694  PPEXSIPlan plan,
695  PPEXSIOptions options,
696  double* AnzvalLocal,
697  double* AinvnzvalLocal,
698  int* info );
699 
700 
719  PPEXSIPlan plan,
720  PPEXSIOptions options,
721  double* AnzvalLocal,
722  double* AinvnzvalLocal,
723  int* info );
724 
725 
747  PPEXSIPlan plan,
748  PPEXSIOptions options,
749  double* AnzvalLocal,
750  double* AinvnzvalLocal,
751  int* info );
752 
753 
754 
835 void PPEXSIDFTDriver(
836  PPEXSIPlan plan,
837  PPEXSIOptions options,
838  double numElectronExact,
839  double* muPEXSI,
840  double* numElectronPEXSI,
841  double* muMinInertia,
842  double* muMaxInertia,
843  int* numTotalInertiaIter,
844  int* numTotalPEXSIIter,
845  int* info );
846 
866  PPEXSIPlan plan,
867  double* DMnzvalLocal,
868  double* EDMnzvalLocal,
869  double* FDMnzvalLocal,
870  double* totalEnergyH,
871  double* totalEnergyS,
872  double* totalFreeEnergy,
873  int* info );
874 
875 
876 
877 
887 void PPEXSIPlanFinalize(
888  PPEXSIPlan plan,
889  int* info );
890 
891 
892 #ifdef __cplusplus
893 }// extern "C"
894 #endif
895 
896 #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:457
void PPEXSISymbolicFactorizeComplexUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for complex...
double muMin0
Initial guess of lower bound for mu.
Definition: c_pexsi_interface.h:209
int isConstructCommPattern
Whether to construct PSelInv communication pattern. This option is NOT used for now (v0...
Definition: c_pexsi_interface.h:252
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:123
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:317
void PPEXSISymbolicFactorizeRealUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
double mu0
Initial guess for mu (for the solver) (AG)
Definition: c_pexsi_interface.h:217
void PPEXSIPlanFinalize(PPEXSIPlan plan, int *info)
Release the memory used by PEXSI.
Definition: interface.cpp:719
double muInertiaExpansion
If the chemical potential is not in the initial interval, the interval is expanded by muInertiaExpans...
Definition: c_pexsi_interface.h:227
int ordering
Ordering strategy for factorization and selected inversion.
Definition: c_pexsi_interface.h:263
double numElectronPEXSITolerance
Stopping criterion of the PEXSI iteration in terms of the number of electrons compared to numElectron...
Definition: c_pexsi_interface.h:237
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:222
int symmetric
Matrix structure.
Definition: c_pexsi_interface.h:274
PPEXSIPlan PPEXSIPlanInitialize(MPI_Comm comm, int numProcRow, int numProcCol, int outputFileIndex, int *info)
Initialize the PEXSI plan.
Definition: interface.cpp:285
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:260
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:611
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)
Directly compute the negative inertia at a set of shifts.
Definition: interface.cpp:504
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:547
int npSymbFact
Number of processors for PARMETIS/PT-SCOTCH. Only used if the ordering == 0.
Definition: c_pexsi_interface.h:268
void PPEXSISymbolicFactorizeRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
Definition: interface.cpp:365
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:411
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:156
void PPEXSISelInvComplexUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, double *AinvnzvalLocal, int *info)
Simplified driver interface for computing the selected elements of a complex unsymmetric matrix...
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:223
void PPEXSILoadRealUnsymmetricHSMatrix(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 unsymmetric H and S matrices into the PEXSI internal data structure.
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:579
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:247
int matrixType
matrixType (global) Type of input H and S matrices.
Definition: c_pexsi_interface.h:243
void PPEXSISelInvRealUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, double *AinvnzvalLocal, int *info)
Simplified driver interface for computing the selected elements of a real unsymmetric matrix...
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:672
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:232
int verbosity
The level of output information.
Definition: c_pexsi_interface.h:281
int numPole
Number of terms in the pole expansion.
Definition: c_pexsi_interface.h:196