diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index 8e18f67c28..619f82f4a8 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -69,7 +69,7 @@ void FitPOD::command(int narg, char **arg) // get POD coefficients from an input file - if (coeff_file != "") podptr->podArrayCopy(desc.c, podptr->pod.coeff, podptr->pod.nd); + if (coeff_file != "") podArrayCopy(desc.c, podptr->pod.coeff, podptr->pod.nd); // compute POD coefficients using least-squares method @@ -507,13 +507,13 @@ void FitPOD::get_data(datastruct &data, std::vector species) } int len = data.num_atom.size(); - data.num_atom_min = podptr->podArrayMin(&data.num_atom[0], len); - data.num_atom_max = podptr->podArrayMax(&data.num_atom[0], len); + data.num_atom_min = podArrayMin(&data.num_atom[0], len); + data.num_atom_max = podArrayMax(&data.num_atom[0], len); data.num_atom_cumsum.resize(len+1); - podptr->podCumsum(&data.num_atom_cumsum[0], &data.num_atom[0], len+1); + podCumsum(&data.num_atom_cumsum[0], &data.num_atom[0], len+1); data.num_config_cumsum.resize(nfiles+1); - podptr->podCumsum(&data.num_config_cumsum[0], &data.num_config[0], nfiles+1); + podCumsum(&data.num_config_cumsum[0], &data.num_config[0], nfiles+1); // convert all structures to triclinic system @@ -529,11 +529,11 @@ void FitPOD::get_data(datastruct &data, std::vector species) double *a2 = &lattice[3]; double *a3 = &lattice[6]; - podptr->matrix33_inverse(Qmat, a1, a2, a3); - podptr->triclinic_lattice_conversion(a1, a2, a3, a1, a2, a3); - podptr->matrix33_multiplication(Qmat, lattice, Qmat, DIM); - podptr->matrix33_multiplication(x, Qmat, x, natom); - podptr->matrix33_multiplication(f, Qmat, f, natom); + matrix33_inverse(Qmat, a1, a2, a3); + triclinic_lattice_conversion(a1, a2, a3, a1, a2, a3); + matrix33_multiplication(Qmat, lattice, Qmat, DIM); + matrix33_multiplication(x, Qmat, x, natom); + matrix33_multiplication(f, Qmat, f, natom); } if (comm->me == 0) { @@ -640,12 +640,12 @@ void FitPOD::select_data(datastruct &newdata, datastruct data) newdata.num_atom_each_file[file] = num_atom_sum; } int len = newdata.num_atom.size(); - newdata.num_atom_min = podptr->podArrayMin(&newdata.num_atom[0], len); - newdata.num_atom_max = podptr->podArrayMax(&newdata.num_atom[0], len); + newdata.num_atom_min = podArrayMin(&newdata.num_atom[0], len); + newdata.num_atom_max = podArrayMax(&newdata.num_atom[0], len); newdata.num_atom_cumsum.resize(len+1); - podptr->podCumsum(&newdata.num_atom_cumsum[0], &newdata.num_atom[0], len+1); + podCumsum(&newdata.num_atom_cumsum[0], &newdata.num_atom[0], len+1); newdata.num_atom_sum = newdata.num_atom_cumsum[len]; - podptr->podCumsum(&newdata.num_config_cumsum[0], &newdata.num_config[0], nfiles+1); + podCumsum(&newdata.num_config_cumsum[0], &newdata.num_config[0], nfiles+1); newdata.num_config_sum = newdata.num_atom.size(); int n = data.num_config_sum; @@ -867,7 +867,7 @@ int FitPOD::podfullneighborlist(double *y, int *alist, int *neighlist, int *numn nn = podneighborlist(neighlist, numneigh, y, rcutsq, nx, N, dim); - podptr->podCumsum(numneighsum, numneigh, nx+1); + podCumsum(numneighsum, numneigh, nx+1); return nn; } @@ -879,9 +879,9 @@ void FitPOD::allocate_memory(datastruct data) memory->create(desc.A, nd*nd, "fitpod:desc_A"); memory->create(desc.b, nd, "fitpod:desc_b"); memory->create(desc.c, nd, "fitpod:desc_c"); - podptr->podArraySetValue(desc.A, 0.0, nd*nd); - podptr->podArraySetValue(desc.b, 0.0, nd); - podptr->podArraySetValue(desc.c, 0.0, nd); + podArraySetValue(desc.A, 0.0, nd*nd); + podArraySetValue(desc.b, 0.0, nd); + podArraySetValue(desc.c, 0.0, nd); int dim = 3; int natom_max = data.num_atom_max; @@ -1192,7 +1192,7 @@ void FitPOD::least_squares_matrix(datastruct data, int ci) // least-square matrix for all descriptors: A = A + (we*we)*(gd^T * gd) - podptr->podKron(desc.A, desc.gd, desc.gd, we2, nd, nd); + podKron(desc.A, desc.gd, desc.gd, we2, nd, nd); // least-square matrix for all descriptors derivatives: A = A + (wf*wf) * (gdd^T * gdd) @@ -1340,7 +1340,7 @@ double FitPOD::energyforce_calculation(double *force, double *coeff, datastruct podptr->podNeighPairs(rij, nb.y, idxi, ai, aj, ti, tj, nb.pairnum_cumsum, atomtype, nb.pairlist, nb.alist, natom); double *effectivecoeff = &tmpmem[3*Nij]; // 3*Nij - podptr->podArraySetValue(effectivecoeff, 0.0, nd1234); + podArraySetValue(effectivecoeff, 0.0, nd1234); double energy = podptr->energyforce_calculation(force, coeff, effectivecoeff, desc.gd, rij, &tmpmem[3*Nij+nd1234], nb.pairnum_cumsum, atomtype, idxi, ai, aj, ti, tj, natom, Nij); @@ -1496,8 +1496,8 @@ void FitPOD::error_analysis(datastruct data, double *coeff) outarray[2 + m*ci] = energy; outarray[3 + m*ci] = DFTenergy; outarray[4 + m*ci] = fabs(DFTenergy-energy)/natom; - outarray[5 + m*ci] = podptr->podArrayNorm(force.data(), nforce); - outarray[6 + m*ci] = podptr->podArrayNorm(DFTforce, nforce); + outarray[5 + m*ci] = podArrayNorm(force.data(), nforce); + outarray[6 + m*ci] = podArrayNorm(DFTforce, nforce); double diff, sum = 0.0, ssr = 0.0; for (int j=0; jme == 0) utils::logmesg(lmp, "**************** End of Energy/Force Calculation ****************\n"); } + +void FitPOD::print_matrix(const char *desc, int m, int n, double **a, int /*lda*/ ) +{ + int i, j; + printf( "\n %s\n", desc ); + + for( i = 0; i < m; i++ ) + { + for( j = 0; j < n; j++ ) printf( " %6.12f", a[j][i] ); + printf( "\n" ); + } +} + +void FitPOD::print_matrix(const char *desc, int m, int n, double *a, int lda ) +{ + int i, j; + printf( "\n %s\n", desc ); + + for( i = 0; i < m; i++ ) + { + for( j = 0; j < n; j++ ) printf( " %6.12f", a[i+j*lda] ); + printf( "\n" ); + } +} + +void FitPOD::print_matrix(const char *desc, int m, int n, int *a, int lda) +{ + int i, j; + printf( "\n %s\n", desc ); + + for( i = 0; i < m; i++ ) + { + for( j = 0; j < n; j++ ) printf( " %d", a[i+j*lda] ); + printf( "\n" ); + } +} + +void FitPOD::podArrayFill(int* output, int start, int length) +{ + for (int j = 0; j < length; ++j) + output[j] = start + j; +} + +double FitPOD::podArraySum(double *a, int n) +{ + double e = a[0]; + for (int i=1; ib) + b = a[i]; + return b; +} + +int FitPOD::podArrayMin(int *a, int n) +{ + int b = a[0]; + for (int i=1; ib) + b = a[i]; + return b; +} + +void FitPOD::podKron(double *C, double *A, double *B, double alpha, int M1, int M2) +{ + int M = M1*M2; + for (int idx=0; idxb) - b = a[i]; - return b; -} - -int MLPOD::podArrayMin(int *a, int n) -{ - int b = a[0]; - for (int i=1; ib) - b = a[i]; - return b; -} - -void MLPOD::podKron(double *C, double *A, double *B, double alpha, int M1, int M2) -{ - int M = M1*M2; - for (int idx=0; idx