ergo
density_description_file.cc File Reference

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
 

Detailed Description

An interface file for writing and reading density matrices to/from a file, including basis set information.

Author
: Elias Rudberg responsible

Macro Definition Documentation

◆ _LARGEFILE_SOURCE

#define _LARGEFILE_SOURCE   1

◆ MATRIX_STORAGE_TYPE_FULL

#define MATRIX_STORAGE_TYPE_FULL   1

◆ MATRIX_STORAGE_TYPE_TRIANGLE

#define MATRIX_STORAGE_TYPE_TRIANGLE   2

◆ MATRIX_STORAGE_TYPE_VECTORS

#define MATRIX_STORAGE_TYPE_VECTORS   3

Function Documentation

◆ ddf_get_matrix_from_storage()

static int ddf_get_matrix_from_storage ( const char *  p,
size_t  sizeInBytes,
int  n,
ergo_real resultMatrix,
int  storageType 
)
static

◆ ddf_get_matrix_from_storage_sparse()

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 
)
static

◆ ddf_get_matrix_from_vector_storage()

static int ddf_get_matrix_from_vector_storage ( const char *  p,
size_t  sizeInBytes,
int  n,
ergo_real resultMatrix 
)
static

◆ ddf_get_matrix_from_vector_storage_sparse()

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

◆ ddf_get_matrix_nvalues_from_storage()

static int ddf_get_matrix_nvalues_from_storage ( const char *  p,
size_t  sizeInBytes,
int  n,
long *  result_nvalues,
int  storageType 
)
static

◆ ddf_get_matrix_storage_size()

static size_t ddf_get_matrix_storage_size ( int  storageType,
int  n,
const ergo_real matrix 
)
static

◆ ddf_get_matrix_storage_size_sparse()

◆ ddf_get_nvalues_symm_matrix()

static int ddf_get_nvalues_symm_matrix ( int  n,
const ergo_real matrix 
)
static

◆ ddf_get_triangular_matrix_from_storage()

static void ddf_get_triangular_matrix_from_storage ( const char *  p,
long  n,
ergo_real resultMatrix 
)
static

◆ ddf_get_triangular_matrix_from_storage_sparse()

static void ddf_get_triangular_matrix_from_storage_sparse ( const char *  p,
int  n,
int *  rowind,
int *  colind,
ergo_real values 
)
static

◆ ddf_load_density()

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().

◆ ddf_load_density_getSizes()

◆ 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().

◆ ddf_read_shells_and_density_matrices()

static int ddf_read_shells_and_density_matrices ( BasisInfoStruct basisInfo,
int  noOfDensityMatrices,
ergo_real **  densityMatrixList,
const char *  fileName 
)
static

◆ ddf_read_shells_and_density_matrices_sparse()

◆ ddf_store_matrix()

static int ddf_store_matrix ( char *  p,
size_t  sizeInBytes,
int  n,
const ergo_real matrix,
int  storageType 
)
static

◆ ddf_store_matrix_as_vectors()

static int ddf_store_matrix_as_vectors ( char *  p,
int  n,
const ergo_real matrix,
size_t  sizeInBytes 
)
static

◆ ddf_store_matrix_as_vectors_sparse()

static int ddf_store_matrix_as_vectors_sparse ( char *  p,
int  n,
matrix_description_struct matrix,
size_t  sizeInBytes 
)
static

◆ ddf_store_matrix_sparse()

◆ ddf_store_triangular_matrix()

static void ddf_store_triangular_matrix ( char *  p,
int  n,
const ergo_real matrix 
)
static

stores the upper triangle of a square matrix in the specified memory block.


Parameters
pmemory block
nmatrix dimension
matrixsquare matrix

Referenced by ddf_store_matrix().

◆ ddf_store_triangular_matrix_sparse()

static void ddf_store_triangular_matrix_sparse ( char *  p,
long  n,
matrix_description_struct matrix 
)
static

stores the upper triangle of the matrix given by the matrix_description_struct in the specified memory block.

Parameters
pmemory block
nmatrix dimension
matrixmatrix

References matrix_description_struct::colind, matrix_description_struct::nvalues, matrix_description_struct::rowind, and matrix_description_struct::values.

Referenced by ddf_store_matrix_sparse().

◆ ddf_writeShellListAndDensityMatricesToFile()

◆ ddf_writeShellListAndDensityMatricesToFile_sparse()

Variable Documentation

◆ DENSITY_FILE_VERSION_NUMBER

◆ THRESHOLD_FOR_VECTOR_STORAGE

const ergo_real THRESHOLD_FOR_VECTOR_STORAGE = 1e-12