- Moved transposing of Slater_inv to HDF5 conversion tool and removed it from the test program.

- Let Maponi A3 continue, even after the algorithm breaks down.
This commit is contained in:
Francois Coppens 2021-03-18 14:05:58 +01:00
parent 333be9326c
commit 6cd9fb1072
7 changed files with 20 additions and 11 deletions

View File

@ -1,6 +1,6 @@
## Compilers ## Compilers
ARCH = ARCH =
CXX = clang++ CXX = clang++-7
FC = flang-7 FC = flang-7
H5CXX = h5c++ H5CXX = h5c++

View File

@ -103,8 +103,7 @@ void MaponiA3(double *Slater_inv, unsigned int Dim,
cout << endl; cout << endl;
#endif #endif
if (fabs(beta) < 1e-6) { if (fabs(beta) < 1e-6) {
cout << "Break-down occured. Exiting..." << endl; cerr << "Break-down occured." << endl;
exit(1);
} }
// Compute intermediate update to Slater_inv // Compute intermediate update to Slater_inv

View File

@ -113,7 +113,7 @@ void SM2(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
void SM3(double *Slater_inv, unsigned int Dim, unsigned int N_updates, void SM3(double *Slater_inv, unsigned int Dim, unsigned int N_updates,
double *Updates, unsigned int *Updates_index) { double *Updates, unsigned int *Updates_index) {
std::cerr << "Called SM2 with updates " << N_updates << std::endl; std::cerr << "Called SM3 with updates " << N_updates << std::endl;
double C[Dim]; double C[Dim];
double D[Dim]; double D[Dim];

View File

@ -10,8 +10,18 @@
using namespace H5; using namespace H5;
// #define DEBUG // #define DEBUG
const H5std_string FILE_NAME( "datasets.hdf5" ); const H5std_string FILE_NAME( "dataset.hdf5" );
double residual_max(double * A, unsigned int Dim) {
double max= 0.0;
for (unsigned int i = 0; i < Dim; i++) {
for (unsigned int j = 0; j < Dim; j++) {
double delta = (A[i * Dim + j] - (i == j));
if (delta > max) max = delta;
}
}
return max;
}
double residual2(double * A, unsigned int Dim) { double residual2(double * A, unsigned int Dim) {
double res = 0.0; double res = 0.0;
@ -51,7 +61,7 @@ int test_cycle(H5File file, int cycle, std::string version) {
double * slater_inverse = new double[dim*dim]; double * slater_inverse = new double[dim*dim];
read_double(file, group + "/slater_inverse", slater_inverse); read_double(file, group + "/slater_inverse", slater_inverse);
slater_inverse = transpose(slater_inverse, dim); //slater_inverse = transpose(slater_inverse, dim);
unsigned int * col_update_index = new unsigned int[nupdates]; unsigned int * col_update_index = new unsigned int[nupdates];
read_int(file, group + "/col_update_index", col_update_index); read_int(file, group + "/col_update_index", col_update_index);
@ -91,7 +101,6 @@ int test_cycle(H5File file, int cycle, std::string version) {
exit(1); exit(1);
} }
#ifdef DEBUG #ifdef DEBUG
showMatrix(slater_matrix, dim, "NEW Slater"); showMatrix(slater_matrix, dim, "NEW Slater");
#endif #endif
@ -104,8 +113,9 @@ int test_cycle(H5File file, int cycle, std::string version) {
matMul(slater_matrix, slater_inverse, res, dim); matMul(slater_matrix, slater_inverse, res, dim);
bool ok = is_identity(res, dim, 1e-3); bool ok = is_identity(res, dim, 1e-3);
double res_max = residual_max(res, dim);
double res2 = residual2(res, dim); double res2 = residual2(res, dim);
std::cout << "Residual = " << version << " " << cycle << " " << res2 << std::endl; std::cout << "Residual = " << version << " " << cycle << " " << res_max << " " << res2 << std::endl;
#ifdef DEBUG #ifdef DEBUG
showMatrix(res, dim, "Result"); showMatrix(res, dim, "Result");

View File

@ -6,8 +6,8 @@ def rl(rf):
return " ".join(rf.readline().split()) return " ".join(rf.readline().split())
with h5py.File('datasets.hdf5', 'w') as f: with h5py.File('dataset.hdf5', 'w') as f:
with open('datasets.dat', 'r') as rf: with open('dataset.dat', 'r') as rf:
while(1): while(1):
line = rl(rf) line = rl(rf)
if not line or not line.startswith('#START_PACKET'): if not line or not line.startswith('#START_PACKET'):
@ -23,7 +23,7 @@ with h5py.File('datasets.hdf5', 'w') as f:
for i in range(slater_matrix_dim*slater_matrix_dim): for i in range(slater_matrix_dim*slater_matrix_dim):
res = parse('({i:d},{j:d}) {sla:e} {inv:e}', rl(rf)) res = parse('({i:d},{j:d}) {sla:e} {inv:e}', rl(rf))
slater_matrix[res['i']-1, res['j']-1] = res['sla'] slater_matrix[res['i']-1, res['j']-1] = res['sla']
slater_inverse[res['i']-1, res['j']-1] = res['inv'] slater_inverse[res['j']-1, res['i']-1] = res['inv']
# Read updates # Read updates
col_update_index = np.zeros(nupdates, dtype='i') col_update_index = np.zeros(nupdates, dtype='i')