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;
262  int ordering;
296 } PPEXSIOptions;
297 
298 
308  PPEXSIOptions* options );
309 
310 
348 PPEXSIPlan PPEXSIPlanInitialize(
349  MPI_Comm comm,
350  int numProcRow,
351  int numProcCol,
352  int outputFileIndex,
353  int* info );
354 
355 
386  PPEXSIPlan plan,
387  PPEXSIOptions options,
388  int nrows,
389  int nnz,
390  int nnzLocal,
391  int numColLocal,
392  int* colptrLocal,
393  int* rowindLocal,
394  double* HnzvalLocal,
395  int isSIdentity,
396  double* SnzvalLocal,
397  int* info );
398 
411  PPEXSIPlan plan,
412  PPEXSIOptions options,
413  int* info );
414 
427  PPEXSIPlan plan,
428  PPEXSIOptions options,
429  int* info );
430 
431 
454  /* Input parameters */
455  PPEXSIPlan plan,
456  PPEXSIOptions options,
457  int numShift,
458  double* shiftList,
459  /* Output parameters */
460  double* inertiaList,
461  int* info );
462 
463 
464 
465 
466 
467 
468 
469 
470 
501  PPEXSIPlan plan,
502  PPEXSIOptions options,
503  int nrows,
504  int nnz,
505  int nnzLocal,
506  int numColLocal,
507  int* colptrLocal,
508  int* rowindLocal,
509  double* HnzvalLocal,
510  int isSIdentity,
511  double* SnzvalLocal,
512  int* info );
513 
527  PPEXSIPlan plan,
528  PPEXSIOptions options,
529  double* AnzvalLocal,
530  int* info );
531 
545  PPEXSIPlan plan,
546  PPEXSIOptions options,
547  double* AnzvalLocal,
548  int* info );
549 
550 
572 /*
573 void PPEXSIInertiaCountRealUnsymmetricMatrix(
574  PPEXSIPlan plan,
575  PPEXSIOptions options,
576  int numShift,
577  double* shiftList,
578  double* inertiaList,
579  int* info );
580 */
581 
582 
583 
584 
585 
586 
587 
588 
589 
590 
591 
592 
650  PPEXSIPlan plan,
651  PPEXSIOptions options,
652  double mu,
653  double numElectronExact,
654  double* numElectronPEXSI,
655  double* numElectronDrvMuPEXSI,
656  int* info );
657 
658 
677  PPEXSIPlan plan,
678  PPEXSIOptions options,
679  double* AnzvalLocal,
680  double* AinvnzvalLocal,
681  int* info );
682 
683 
705  PPEXSIPlan plan,
706  PPEXSIOptions options,
707  double* AnzvalLocal,
708  double* AinvnzvalLocal,
709  int* info );
710 
711 
730  PPEXSIPlan plan,
731  PPEXSIOptions options,
732  double* AnzvalLocal,
733  double* AinvnzvalLocal,
734  int* info );
735 
736 
758  PPEXSIPlan plan,
759  PPEXSIOptions options,
760  double* AnzvalLocal,
761  double* AinvnzvalLocal,
762  int* info );
763 
764 
765 
846 void PPEXSIDFTDriver(
847  PPEXSIPlan plan,
848  PPEXSIOptions options,
849  double numElectronExact,
850  double* muPEXSI,
851  double* numElectronPEXSI,
852  double* muMinInertia,
853  double* muMaxInertia,
854  int* numTotalInertiaIter,
855  int* numTotalPEXSIIter,
856  int* info );
857 
926 void PPEXSIDFTDriver2(
927  PPEXSIPlan plan,
928  PPEXSIOptions options,
929  double numElectronExact,
930  double* muPEXSI,
931  double* numElectronPEXSI,
932  double* muMinInertia,
933  double* muMaxInertia,
934  int* numTotalInertiaIter,
935  int* info );
936 
956  PPEXSIPlan plan,
957  double* DMnzvalLocal,
958  double* EDMnzvalLocal,
959  double* FDMnzvalLocal,
960  double* totalEnergyH,
961  double* totalEnergyS,
962  double* totalFreeEnergy,
963  int* info );
964 
965 
966 
967 
977 void PPEXSIPlanFinalize(
978  PPEXSIPlan plan,
979  int* info );
980 
992 void PPEXSIGetPoleDM(
993  double* zshift,
994  double* zweight,
995  int Npole,
996  double temp,
997  double gap,
998  double deltaE,
999  double mu );
1000 
1012 void PPEXSIGetPoleEDM(
1013  double* zshift,
1014  double* zweight,
1015  int Npole,
1016  double temp,
1017  double gap,
1018  double deltaE,
1019  double mu );
1020 
1032 void PPEXSIGetPoleFDM(
1033  double* zshift,
1034  double* zweight,
1035  int Npole,
1036  double temp,
1037  double gap,
1038  double deltaE,
1039  double mu );
1040 
1041 #ifdef __cplusplus
1042 }// extern "C"
1043 #endif
1044 
1045 #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:644
double muMin0
Initial guess of lower bound for mu.
Definition: c_pexsi_interface.h:209
int isConstructCommPattern
Whether to construct PSelInv communication pattern.
Definition: c_pexsi_interface.h:251
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:319
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:1074
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:262
int rowOrdering
row permutation strategy for factorization and selected inversion.
Definition: c_pexsi_interface.h:271
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:282
PPEXSIPlan PPEXSIPlanInitialize(MPI_Comm comm, int numProcRow, int numProcCol, int outputFileIndex, int *info)
Initialize the PEXSI plan.
Definition: interface.cpp:287
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 PPEXSIGetPoleDM(double *zshift, double *zweight, int Npole, double temp, double gap, double deltaE, double mu)
Pole expansion for density matrix (DM).
Definition: interface.cpp:1099
int transpose
Transpose.
Definition: c_pexsi_interface.h:288
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:911
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:739
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:782
int npSymbFact
Number of processors for PARMETIS/PT-SCOTCH. Only used if the ordering == 0.
Definition: c_pexsi_interface.h:276
void PPEXSISymbolicFactorizeRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
Definition: interface.cpp:420
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:533
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...
Definition: interface.cpp:878
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.
Definition: interface.cpp:368
void PPEXSIGetPoleEDM(double *zshift, double *zweight, int Npole, double temp, double gap, double deltaE, double mu)
Pole expansion for energy density matrix (EDM).
Definition: interface.cpp:1125
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:846
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...
Definition: interface.cpp:814
void PPEXSISymbolicFactorizeComplexUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for complex...
Definition: interface.cpp:579
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:1027
double gap
Spectral gap. Note This can be set to be 0 in most cases.
Definition: c_pexsi_interface.h:188
void PPEXSISymbolicFactorizeRealUnsymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, double *AnzvalLocal, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
Definition: interface.cpp:466
double muPEXSISafeGuard
Safe guard criterion in terms of the chemical potential to reinvoke the inertia counting procedure...
Definition: c_pexsi_interface.h:232
void PPEXSIDFTDriver2(PPEXSIPlan plan, PPEXSIOptions options, double numElectronExact, double *muPEXSI, double *numElectronPEXSI, double *muMinInertia, double *muMaxInertia, int *numTotalInertiaIter, int *info)
Simplified driver for solving Kohn-Sham DFT. Version 2. This is still in test phase.
Definition: interface.cpp:970
void PPEXSIGetPoleFDM(double *zshift, double *zweight, int Npole, double temp, double gap, double deltaE, double mu)
Pole expansion for free energy density matrix (FDM).
Definition: interface.cpp:1151
int verbosity
The level of output information.
Definition: c_pexsi_interface.h:295
int numPole
Number of terms in the pole expansion.
Definition: c_pexsi_interface.h:196