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;
258  int ordering;
271 } PPEXSIOptions;
272 
273 
283  PPEXSIOptions* options );
284 
285 
323 PPEXSIPlan PPEXSIPlanInitialize(
324  MPI_Comm comm,
325  int numProcRow,
326  int numProcCol,
327  int outputFileIndex,
328  int* info );
329 
330 
361  PPEXSIPlan plan,
362  PPEXSIOptions options,
363  int nrows,
364  int nnz,
365  int nnzLocal,
366  int numColLocal,
367  int* colptrLocal,
368  int* rowindLocal,
369  double* HnzvalLocal,
370  int isSIdentity,
371  double* SnzvalLocal,
372  int* info );
373 
386  PPEXSIPlan plan,
387  PPEXSIOptions options,
388  int* info );
389 
402  PPEXSIPlan plan,
403  PPEXSIOptions options,
404  int* info );
405 
406 
429  /* Input parameters */
430  PPEXSIPlan plan,
431  PPEXSIOptions options,
432  int numShift,
433  double* shiftList,
434  /* Output parameters */
435  double* inertiaList,
436  int* info );
437 
438 
496  PPEXSIPlan plan,
497  PPEXSIOptions options,
498  double mu,
499  double numElectronExact,
500  double* numElectronPEXSI,
501  double* numElectronDrvMuPEXSI,
502  int* info );
503 
504 
523  PPEXSIPlan plan,
524  PPEXSIOptions options,
525  double* AnzvalLocal,
526  double* AinvnzvalLocal,
527  int* info );
528 
529 
551  PPEXSIPlan plan,
552  PPEXSIOptions options,
553  double* AnzvalLocal,
554  double* AinvnzvalLocal,
555  int* info );
556 
557 
580  PPEXSIPlan plan,
581  PPEXSIOptions options,
582  double* AnzvalLocal,
583  double* AinvnzvalLocal,
584  int* info );
585 
586 
667 void PPEXSIDFTDriver(
668  PPEXSIPlan plan,
669  PPEXSIOptions options,
670  double numElectronExact,
671  double* muPEXSI,
672  double* numElectronPEXSI,
673  double* muMinInertia,
674  double* muMaxInertia,
675  int* numTotalInertiaIter,
676  int* numTotalPEXSIIter,
677  int* info );
678 
698  PPEXSIPlan plan,
699  double* DMnzvalLocal,
700  double* EDMnzvalLocal,
701  double* FDMnzvalLocal,
702  double* totalEnergyH,
703  double* totalEnergyS,
704  double* totalFreeEnergy,
705  int* info );
706 
707 
708 
709 
719 void PPEXSIPlanFinalize(
720  PPEXSIPlan plan,
721  int* info );
722 
723 
724 #ifdef __cplusplus
725 }// extern "C"
726 #endif
727 
728 #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:449
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:307
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:713
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:258
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
PPEXSIPlan PPEXSIPlanInitialize(MPI_Comm comm, int numProcRow, int numProcCol, int outputFileIndex, int *info)
Initialize the PEXSI plan.
Definition: interface.cpp:275
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:605
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:496
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:539
int npSymbFact
Number of processors for PARMETIS/PT-SCOTCH. Only used if the ordering == 0.
Definition: c_pexsi_interface.h:263
void PPEXSISymbolicFactorizeRealSymmetricMatrix(PPEXSIPlan plan, PPEXSIOptions options, int *info)
Separately perform symbolic factorization to prepare factorization and selected inversion for real ar...
Definition: interface.cpp:355
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:402
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:572
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
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:666
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:270
int numPole
Number of terms in the pole expansion.
Definition: c_pexsi_interface.h:196