ergo
|
An interface file for writing and reading density matrices to/from a file, including basis set information. More...
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include <string>
#include "density_description_file.h"
#include "densfromf_full.h"
#include "integrals_general.h"
#include "matrix_algebra.h"
#include "memorymanag.h"
#include "output.h"
#include "utilities.h"
Classes | |
struct | densityFileHeaderStruct |
Macros | |
#define | _LARGEFILE_SOURCE 1 |
#define | MATRIX_STORAGE_TYPE_FULL 1 |
#define | MATRIX_STORAGE_TYPE_TRIANGLE 2 |
#define | MATRIX_STORAGE_TYPE_VECTORS 3 |
Functions | |
static void | ddf_store_triangular_matrix (char *p, int n, const ergo_real *matrix) |
stores the upper triangle of a square matrix in the specified memory block. More... | |
static void | ddf_store_triangular_matrix_sparse (char *p, long n, matrix_description_struct *matrix) |
stores the upper triangle of the matrix given by the matrix_description_struct in the specified memory block. More... | |
static void | ddf_get_triangular_matrix_from_storage (const char *p, long n, ergo_real *resultMatrix) |
static void | ddf_get_triangular_matrix_from_storage_sparse (const char *p, int n, int *rowind, int *colind, ergo_real *values) |
static int | ddf_get_nvalues_symm_matrix (int n, const ergo_real *matrix) |
static int | ddf_store_matrix_as_vectors (char *p, int n, const ergo_real *matrix, size_t sizeInBytes) |
static int | ddf_store_matrix_as_vectors_sparse (char *p, int n, matrix_description_struct *matrix, size_t sizeInBytes) |
static int | ddf_get_matrix_from_vector_storage (const char *p, size_t sizeInBytes, int n, ergo_real *resultMatrix) |
static int | ddf_get_matrix_from_vector_storage_sparse (const char *p, size_t sizeInBytes, int n, int *rowind2, int *colind2, ergo_real *values2) |
static size_t | ddf_get_matrix_storage_size (int storageType, int n, const ergo_real *matrix) |
static size_t | ddf_get_matrix_storage_size_sparse (int storageType, int n, matrix_description_struct *matrix) |
static int | ddf_store_matrix (char *p, size_t sizeInBytes, int n, const ergo_real *matrix, int storageType) |
static int | ddf_store_matrix_sparse (char *p, size_t sizeInBytes, int n, matrix_description_struct *matrix, int storageType) |
static int | ddf_get_matrix_nvalues_from_storage (const char *p, size_t sizeInBytes, int n, long *result_nvalues, int storageType) |
static int | ddf_get_matrix_from_storage (const char *p, size_t sizeInBytes, int n, ergo_real *resultMatrix, int storageType) |
static int | ddf_get_matrix_from_storage_sparse (const char *p, size_t sizeInBytes, int n, int *rowind, int *colind, ergo_real *values, int storageType) |
int | ddf_writeShellListAndDensityMatricesToFile (const BasisInfoStruct &basisInfo, int noOfDensityMatrices, ergo_real **densityMatrixList, const char *fileName) |
int | ddf_writeShellListAndDensityMatricesToFile_sparse (const BasisInfoStruct &basisInfo, int noOfDensityMatrices, matrix_description_struct *densityMatrixList, const char *fileName) |
Writes basisInfo and sparse matrices in a format that can be later read by ddf_load_density. More... | |
static int | ddf_load_density_getSizes (const char *fileName, int *result_noOfShells, int *result_noOfBasisFuncs, int *result_noOfDensitiesOnFile, long *result_noOfValuesList) |
static int | ddf_read_shells_and_density_matrices (BasisInfoStruct *basisInfo, int noOfDensityMatrices, ergo_real **densityMatrixList, const char *fileName) |
ddf_read_shells_and_density_matrices() reads the basis set information and requested number of density matrices from a specified file. More... | |
static int | ddf_read_shells_and_density_matrices_sparse (BasisInfoStruct **basisInfo, int noOfDensityMatrices, int **rowindList, int **colindList, ergo_real **valuesList, const char *fileName) |
int | ddf_load_density (const char *densityFileName, int noOfDensityMatrices, const IntegralInfo &integralInfo, BasisInfoStruct **basisInfo, ergo_real **densityMatrix) |
Function opens fileName, fills in basisInfo (which has to be allocated and nullified), allocates densityMatrixList and reads density matrix or at most two matrices and puts it/them in densityMatrixList. More... | |
int | ddf_load_density_sparse (const char *densityFileName, const IntegralInfo &integralInfo, BasisInfoStruct **basisInfo, int *noOfDensitiesRead, int **rowindList, int **colindList, ergo_real **valuesList, long *nvaluesList) |
Function opens fileName, fills in basisInfo (which has to be allocated and nullified), allocates densityMatrixList and reads density matrix or at most two matrices and puts it/them in densityMatrixList. More... | |
Variables | |
const int | DENSITY_FILE_VERSION_NUMBER = 10002 |
const ergo_real | THRESHOLD_FOR_VECTOR_STORAGE = 1e-12 |
An interface file for writing and reading density matrices to/from a file, including basis set information.
#define _LARGEFILE_SOURCE 1 |
#define MATRIX_STORAGE_TYPE_FULL 1 |
#define MATRIX_STORAGE_TYPE_TRIANGLE 2 |
Referenced by ddf_get_matrix_from_storage(), ddf_get_matrix_from_storage_sparse(), ddf_get_matrix_nvalues_from_storage(), ddf_get_matrix_storage_size(), ddf_get_matrix_storage_size_sparse(), ddf_store_matrix(), ddf_store_matrix_sparse(), ddf_writeShellListAndDensityMatricesToFile(), and ddf_writeShellListAndDensityMatricesToFile_sparse().
#define MATRIX_STORAGE_TYPE_VECTORS 3 |
Referenced by ddf_get_matrix_from_storage(), ddf_get_matrix_from_storage_sparse(), ddf_get_matrix_nvalues_from_storage(), ddf_get_matrix_storage_size(), ddf_get_matrix_storage_size_sparse(), ddf_store_matrix(), ddf_store_matrix_sparse(), ddf_writeShellListAndDensityMatricesToFile(), and ddf_writeShellListAndDensityMatricesToFile_sparse().
|
static |
|
static |
References A, ddf_get_matrix_from_vector_storage_sparse(), ddf_get_triangular_matrix_from_storage_sparse(), do_output(), LOG_AREA_MAIN, LOG_CAT_ERROR, MATRIX_STORAGE_TYPE_FULL, MATRIX_STORAGE_TYPE_TRIANGLE, and MATRIX_STORAGE_TYPE_VECTORS.
Referenced by ddf_read_shells_and_density_matrices_sparse().
|
static |
Referenced by ddf_get_matrix_from_storage().
|
static |
Referenced by ddf_get_matrix_from_storage_sparse().
|
static |
References do_output(), LOG_AREA_MAIN, LOG_CAT_ERROR, MATRIX_STORAGE_TYPE_FULL, MATRIX_STORAGE_TYPE_TRIANGLE, and MATRIX_STORAGE_TYPE_VECTORS.
Referenced by ddf_load_density_getSizes().
|
static |
|
static |
|
static |
References template_blas_fabs(), and THRESHOLD_FOR_VECTOR_STORAGE.
Referenced by ddf_get_matrix_storage_size(), and ddf_store_matrix_as_vectors().
|
static |
Referenced by ddf_get_matrix_from_storage().
|
static |
Referenced by ddf_get_matrix_from_storage_sparse().
int ddf_load_density | ( | const char * | densityFileName, |
int | noOfDensityMatrices, | ||
const IntegralInfo & | integralInfo, | ||
BasisInfoStruct ** | basisInfo, | ||
ergo_real ** | densityMatrix | ||
) |
Function opens fileName, fills in basisInfo (which has to be allocated and nullified), allocates densityMatrixList and reads density matrix or at most two matrices and puts it/them in densityMatrixList.
References ddf_load_density_getSizes(), ddf_read_shells_and_density_matrices(), do_output(), ergo_new, LOG_AREA_MAIN, LOG_CAT_ERROR, and LOG_CAT_INFO.
Referenced by es_get_polarisability(), es_getexc(), load_density_and_project_full(), main(), and ErgoE2Evaluator::transform().
|
static |
References ddf_get_matrix_nvalues_from_storage(), DENSITY_FILE_VERSION_NUMBER, densityFileHeaderStruct::densityFileVersion, do_output(), ergo_free(), ergo_malloc(), densityFileHeaderStruct::fileSizeInBytes, LOG_AREA_MAIN, LOG_CAT_ERROR, densityFileHeaderStruct::matrixSize_1, densityFileHeaderStruct::matrixSize_2, densityFileHeaderStruct::noOfBasisFuncs, densityFileHeaderStruct::noOfDensityMatrices, densityFileHeaderStruct::noOfShells, and densityFileHeaderStruct::typeOfMatrixStorage.
Referenced by ddf_load_density(), and ddf_load_density_sparse().
int ddf_load_density_sparse | ( | const char * | densityFileName, |
const IntegralInfo & | integralInfo, | ||
BasisInfoStruct ** | basisInfo, | ||
int * | noOfDensitiesRead, | ||
int ** | rowindList, | ||
int ** | colindList, | ||
ergo_real ** | valuesList, | ||
long * | nvaluesList | ||
) |
Function opens fileName, fills in basisInfo (which has to be allocated and nullified), allocates densityMatrixList and reads density matrix or at most two matrices and puts it/them in densityMatrixList.
References ddf_load_density_getSizes(), ddf_read_shells_and_density_matrices_sparse(), do_output(), LOG_AREA_MAIN, LOG_CAT_ERROR, and LOG_CAT_INFO.
Referenced by load_density_and_project_sparse().
|
static |
ddf_read_shells_and_density_matrices() reads the basis set information and requested number of density matrices from a specified file.
basisInfo needs to be allocated and zeroed in advance. densityMatrixList must be properly allocated as well.
References ddf_get_matrix_from_storage(), DENSITY_FILE_VERSION_NUMBER, densityFileHeaderStruct::densityFileVersion, do_output(), ergo_free(), ergo_malloc(), densityFileHeaderStruct::fileSizeInBytes, LOG_AREA_MAIN, LOG_CAT_ERROR, densityFileHeaderStruct::matrixSize_1, densityFileHeaderStruct::matrixSize_2, densityFileHeaderStruct::noOfBasisFuncs, densityFileHeaderStruct::noOfDensityMatrices, densityFileHeaderStruct::noOfShells, BasisInfoStruct::noOfShells, BasisInfoStruct::shellList, and densityFileHeaderStruct::typeOfMatrixStorage.
Referenced by ddf_load_density().
|
static |
References ddf_get_matrix_from_storage_sparse(), DENSITY_FILE_VERSION_NUMBER, densityFileHeaderStruct::densityFileVersion, do_output(), ergo_free(), ergo_malloc(), densityFileHeaderStruct::fileSizeInBytes, LOG_AREA_MAIN, LOG_CAT_ERROR, densityFileHeaderStruct::matrixSize_1, densityFileHeaderStruct::matrixSize_2, densityFileHeaderStruct::noOfBasisFuncs, densityFileHeaderStruct::noOfDensityMatrices, densityFileHeaderStruct::noOfShells, and densityFileHeaderStruct::typeOfMatrixStorage.
Referenced by ddf_load_density_sparse().
|
static |
|
static |
References ddf_get_nvalues_symm_matrix(), template_blas_fabs(), and THRESHOLD_FOR_VECTOR_STORAGE.
Referenced by ddf_store_matrix().
|
static |
|
static |
|
static |
stores the upper triangle of a square matrix in the specified memory block.
p | memory block |
n | matrix dimension |
matrix | square matrix |
Referenced by ddf_store_matrix().
|
static |
stores the upper triangle of the matrix given by the matrix_description_struct in the specified memory block.
p | memory block |
n | matrix dimension |
matrix | matrix |
References matrix_description_struct::colind, matrix_description_struct::nvalues, matrix_description_struct::rowind, and matrix_description_struct::values.
Referenced by ddf_store_matrix_sparse().
int ddf_writeShellListAndDensityMatricesToFile | ( | const BasisInfoStruct & | basisInfo, |
int | noOfDensityMatrices, | ||
ergo_real ** | densityMatrixList, | ||
const char * | fileName | ||
) |
References ddf_get_matrix_storage_size(), ddf_store_matrix(), DENSITY_FILE_VERSION_NUMBER, densityFileHeaderStruct::densityFileVersion, do_output(), ergo_free(), ergo_malloc(), densityFileHeaderStruct::fileSizeInBytes, LOG_AREA_MAIN, LOG_CAT_ERROR, LOG_CAT_INFO, MATRIX_STORAGE_TYPE_TRIANGLE, MATRIX_STORAGE_TYPE_VECTORS, densityFileHeaderStruct::matrixSize_1, densityFileHeaderStruct::matrixSize_2, densityFileHeaderStruct::noOfBasisFuncs, BasisInfoStruct::noOfBasisFuncs, densityFileHeaderStruct::noOfDensityMatrices, densityFileHeaderStruct::noOfShells, BasisInfoStruct::noOfShells, densityFileHeaderStruct::padding_int, BasisInfoStruct::shellList, and densityFileHeaderStruct::typeOfMatrixStorage.
Referenced by save_symmetric_matrix().
int ddf_writeShellListAndDensityMatricesToFile_sparse | ( | const BasisInfoStruct & | basisInfo, |
int | noOfDensityMatrices, | ||
matrix_description_struct * | densityMatrixList, | ||
const char * | fileName | ||
) |
Writes basisInfo and sparse matrices in a format that can be later read by ddf_load_density.
Data loss was observed with large files on AFS, we do extra verification to detect it early on...
References ddf_get_matrix_storage_size_sparse(), ddf_store_matrix_sparse(), DENSITY_FILE_VERSION_NUMBER, densityFileHeaderStruct::densityFileVersion, do_output(), ergo_free(), ergo_malloc(), fileno(), densityFileHeaderStruct::fileSizeInBytes, LOG_AREA_MAIN, LOG_CAT_ERROR, LOG_CAT_INFO, MATRIX_STORAGE_TYPE_TRIANGLE, MATRIX_STORAGE_TYPE_VECTORS, densityFileHeaderStruct::matrixSize_1, densityFileHeaderStruct::matrixSize_2, densityFileHeaderStruct::noOfBasisFuncs, BasisInfoStruct::noOfBasisFuncs, densityFileHeaderStruct::noOfDensityMatrices, densityFileHeaderStruct::noOfShells, BasisInfoStruct::noOfShells, densityFileHeaderStruct::padding_int, BasisInfoStruct::shellList, and densityFileHeaderStruct::typeOfMatrixStorage.
Referenced by SCF_unrestricted::write_density_to_file(), and write_matrix_to_file().
const int DENSITY_FILE_VERSION_NUMBER = 10002 |
const ergo_real THRESHOLD_FOR_VECTOR_STORAGE = 1e-12 |
Referenced by ddf_get_nvalues_symm_matrix(), and ddf_store_matrix_as_vectors().