forked from lijiext/lammps
Implemented lists instead of multidim arrays
This commit is contained in:
parent
960a975e2a
commit
0559e155f2
|
@ -247,13 +247,12 @@ void ComputeSNAAtom::compute_peratom()
|
|||
snaptr->compute_ui(ninside);
|
||||
snaptr->compute_zi();
|
||||
snaptr->compute_bi();
|
||||
snaptr->copy_bi2bvec();
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++)
|
||||
sna[i][icoeff] = snaptr->bvec[icoeff];
|
||||
sna[i][icoeff] = snaptr->blist[icoeff];
|
||||
if (quadraticflag) {
|
||||
int ncount = ncoeff;
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||
double bi = snaptr->bvec[icoeff];
|
||||
double bi = snaptr->blist[icoeff];
|
||||
|
||||
// diagonal element of quadratic matrix
|
||||
|
||||
|
@ -262,7 +261,7 @@ void ComputeSNAAtom::compute_peratom()
|
|||
// upper-triangular elements of quadratic matrix
|
||||
|
||||
for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++)
|
||||
sna[i][ncount++] = bi*snaptr->bvec[jcoeff];
|
||||
sna[i][ncount++] = bi*snaptr->blist[jcoeff];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -266,7 +266,6 @@ void ComputeSNADAtom::compute_peratom()
|
|||
snaptr->compute_zi();
|
||||
if (quadraticflag) {
|
||||
snaptr->compute_bi();
|
||||
snaptr->copy_bi2bvec();
|
||||
}
|
||||
|
||||
for (int jj = 0; jj < ninside; jj++) {
|
||||
|
@ -275,7 +274,6 @@ void ComputeSNADAtom::compute_peratom()
|
|||
snaptr->wj[jj],
|
||||
snaptr->rcutij[jj]);
|
||||
snaptr->compute_dbidrj();
|
||||
snaptr->copy_dbi2dbvec();
|
||||
|
||||
// Accumulate -dBi/dRi, -dBi/dRj
|
||||
|
||||
|
@ -283,12 +281,12 @@ void ComputeSNADAtom::compute_peratom()
|
|||
double *snadj = snad[j]+typeoffset;
|
||||
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||
snadi[icoeff] += snaptr->dbvec[icoeff][0];
|
||||
snadi[icoeff+yoffset] += snaptr->dbvec[icoeff][1];
|
||||
snadi[icoeff+zoffset] += snaptr->dbvec[icoeff][2];
|
||||
snadj[icoeff] -= snaptr->dbvec[icoeff][0];
|
||||
snadj[icoeff+yoffset] -= snaptr->dbvec[icoeff][1];
|
||||
snadj[icoeff+zoffset] -= snaptr->dbvec[icoeff][2];
|
||||
snadi[icoeff] += snaptr->dblist[icoeff][0];
|
||||
snadi[icoeff+yoffset] += snaptr->dblist[icoeff][1];
|
||||
snadi[icoeff+zoffset] += snaptr->dblist[icoeff][2];
|
||||
snadj[icoeff] -= snaptr->dblist[icoeff][0];
|
||||
snadj[icoeff+yoffset] -= snaptr->dblist[icoeff][1];
|
||||
snadj[icoeff+zoffset] -= snaptr->dblist[icoeff][2];
|
||||
}
|
||||
|
||||
if (quadraticflag) {
|
||||
|
@ -297,10 +295,10 @@ void ComputeSNADAtom::compute_peratom()
|
|||
snadj += quadraticoffset;
|
||||
int ncount = 0;
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||
double bi = snaptr->bvec[icoeff];
|
||||
double bix = snaptr->dbvec[icoeff][0];
|
||||
double biy = snaptr->dbvec[icoeff][1];
|
||||
double biz = snaptr->dbvec[icoeff][2];
|
||||
double bi = snaptr->blist[icoeff];
|
||||
double bix = snaptr->dblist[icoeff][0];
|
||||
double biy = snaptr->dblist[icoeff][1];
|
||||
double biz = snaptr->dblist[icoeff][2];
|
||||
|
||||
// diagonal elements of quadratic matrix
|
||||
|
||||
|
@ -319,12 +317,12 @@ void ComputeSNADAtom::compute_peratom()
|
|||
// upper-triangular elements of quadratic matrix
|
||||
|
||||
for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) {
|
||||
double dbxtmp = bi*snaptr->dbvec[jcoeff][0]
|
||||
+ bix*snaptr->bvec[jcoeff];
|
||||
double dbytmp = bi*snaptr->dbvec[jcoeff][1]
|
||||
+ biy*snaptr->bvec[jcoeff];
|
||||
double dbztmp = bi*snaptr->dbvec[jcoeff][2]
|
||||
+ biz*snaptr->bvec[jcoeff];
|
||||
double dbxtmp = bi*snaptr->dblist[jcoeff][0]
|
||||
+ bix*snaptr->blist[jcoeff];
|
||||
double dbytmp = bi*snaptr->dblist[jcoeff][1]
|
||||
+ biy*snaptr->blist[jcoeff];
|
||||
double dbztmp = bi*snaptr->dblist[jcoeff][2]
|
||||
+ biz*snaptr->blist[jcoeff];
|
||||
|
||||
snadi[ncount] += dbxtmp;
|
||||
snadi[ncount+yoffset] += dbytmp;
|
||||
|
|
|
@ -260,7 +260,6 @@ void ComputeSNAVAtom::compute_peratom()
|
|||
snaptr->compute_zi();
|
||||
if (quadraticflag) {
|
||||
snaptr->compute_bi();
|
||||
snaptr->copy_bi2bvec();
|
||||
}
|
||||
|
||||
for (int jj = 0; jj < ninside; jj++) {
|
||||
|
@ -270,7 +269,6 @@ void ComputeSNAVAtom::compute_peratom()
|
|||
snaptr->wj[jj],
|
||||
snaptr->rcutij[jj]);
|
||||
snaptr->compute_dbidrj();
|
||||
snaptr->copy_dbi2dbvec();
|
||||
|
||||
// Accumulate -dBi/dRi*Ri, -dBi/dRj*Rj
|
||||
|
||||
|
@ -278,18 +276,18 @@ void ComputeSNAVAtom::compute_peratom()
|
|||
double *snavj = snav[j]+typeoffset;
|
||||
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||
snavi[icoeff] += snaptr->dbvec[icoeff][0]*xtmp;
|
||||
snavi[icoeff+nperdim] += snaptr->dbvec[icoeff][1]*ytmp;
|
||||
snavi[icoeff+2*nperdim] += snaptr->dbvec[icoeff][2]*ztmp;
|
||||
snavi[icoeff+3*nperdim] += snaptr->dbvec[icoeff][1]*ztmp;
|
||||
snavi[icoeff+4*nperdim] += snaptr->dbvec[icoeff][0]*ztmp;
|
||||
snavi[icoeff+5*nperdim] += snaptr->dbvec[icoeff][0]*ytmp;
|
||||
snavj[icoeff] -= snaptr->dbvec[icoeff][0]*x[j][0];
|
||||
snavj[icoeff+nperdim] -= snaptr->dbvec[icoeff][1]*x[j][1];
|
||||
snavj[icoeff+2*nperdim] -= snaptr->dbvec[icoeff][2]*x[j][2];
|
||||
snavj[icoeff+3*nperdim] -= snaptr->dbvec[icoeff][1]*x[j][2];
|
||||
snavj[icoeff+4*nperdim] -= snaptr->dbvec[icoeff][0]*x[j][2];
|
||||
snavj[icoeff+5*nperdim] -= snaptr->dbvec[icoeff][0]*x[j][1];
|
||||
snavi[icoeff] += snaptr->dblist[icoeff][0]*xtmp;
|
||||
snavi[icoeff+nperdim] += snaptr->dblist[icoeff][1]*ytmp;
|
||||
snavi[icoeff+2*nperdim] += snaptr->dblist[icoeff][2]*ztmp;
|
||||
snavi[icoeff+3*nperdim] += snaptr->dblist[icoeff][1]*ztmp;
|
||||
snavi[icoeff+4*nperdim] += snaptr->dblist[icoeff][0]*ztmp;
|
||||
snavi[icoeff+5*nperdim] += snaptr->dblist[icoeff][0]*ytmp;
|
||||
snavj[icoeff] -= snaptr->dblist[icoeff][0]*x[j][0];
|
||||
snavj[icoeff+nperdim] -= snaptr->dblist[icoeff][1]*x[j][1];
|
||||
snavj[icoeff+2*nperdim] -= snaptr->dblist[icoeff][2]*x[j][2];
|
||||
snavj[icoeff+3*nperdim] -= snaptr->dblist[icoeff][1]*x[j][2];
|
||||
snavj[icoeff+4*nperdim] -= snaptr->dblist[icoeff][0]*x[j][2];
|
||||
snavj[icoeff+5*nperdim] -= snaptr->dblist[icoeff][0]*x[j][1];
|
||||
}
|
||||
|
||||
if (quadraticflag) {
|
||||
|
@ -298,10 +296,10 @@ void ComputeSNAVAtom::compute_peratom()
|
|||
snavj += quadraticoffset;
|
||||
int ncount = 0;
|
||||
for (int icoeff = 0; icoeff < ncoeff; icoeff++) {
|
||||
double bi = snaptr->bvec[icoeff];
|
||||
double bix = snaptr->dbvec[icoeff][0];
|
||||
double biy = snaptr->dbvec[icoeff][1];
|
||||
double biz = snaptr->dbvec[icoeff][2];
|
||||
double bi = snaptr->blist[icoeff];
|
||||
double bix = snaptr->dblist[icoeff][0];
|
||||
double biy = snaptr->dblist[icoeff][1];
|
||||
double biz = snaptr->dblist[icoeff][2];
|
||||
|
||||
// diagonal element of quadratic matrix
|
||||
|
||||
|
@ -325,12 +323,12 @@ void ComputeSNAVAtom::compute_peratom()
|
|||
// upper-triangular elements of quadratic matrix
|
||||
|
||||
for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) {
|
||||
double dbxtmp = bi*snaptr->dbvec[jcoeff][0]
|
||||
+ bix*snaptr->bvec[jcoeff];
|
||||
double dbytmp = bi*snaptr->dbvec[jcoeff][1]
|
||||
+ biy*snaptr->bvec[jcoeff];
|
||||
double dbztmp = bi*snaptr->dbvec[jcoeff][2]
|
||||
+ biz*snaptr->bvec[jcoeff];
|
||||
double dbxtmp = bi*snaptr->dblist[jcoeff][0]
|
||||
+ bix*snaptr->blist[jcoeff];
|
||||
double dbytmp = bi*snaptr->dblist[jcoeff][1]
|
||||
+ biy*snaptr->blist[jcoeff];
|
||||
double dbztmp = bi*snaptr->dblist[jcoeff][2]
|
||||
+ biz*snaptr->blist[jcoeff];
|
||||
snavi[ncount] += dbxtmp*xtmp;
|
||||
snavi[ncount+nperdim] += dbytmp*ytmp;
|
||||
snavi[ncount+2*nperdim] += dbztmp*ztmp;
|
||||
|
|
|
@ -166,17 +166,14 @@ void PairSNAP::compute(int eflag, int vflag)
|
|||
}
|
||||
}
|
||||
|
||||
// compute Ui, Zi, and Bi for atom I
|
||||
// compute Ui, Yi for atom I
|
||||
|
||||
snaptr->compute_ui(ninside);
|
||||
snaptr->compute_zi();
|
||||
|
||||
// for neighbors of I within cutoff:
|
||||
// compute Fij = dEi/dRj = -dEi/dRi
|
||||
// add to Fi, subtract from Fj
|
||||
|
||||
// compute beta_i*Z_i = Y_i
|
||||
|
||||
snaptr->compute_yi(beta[ii]);
|
||||
|
||||
for (int jj = 0; jj < ninside; jj++) {
|
||||
|
@ -310,10 +307,9 @@ void PairSNAP::compute_bispectrum()
|
|||
snaptr->compute_ui(ninside);
|
||||
snaptr->compute_zi();
|
||||
snaptr->compute_bi();
|
||||
snaptr->copy_bi2bvec();
|
||||
|
||||
for (int k = 0; k < ncoeff; k++)
|
||||
bispectrum[ii][k] = snaptr->bvec[k];
|
||||
bispectrum[ii][k] = snaptr->blist[k];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1160
src/SNAP/sna.cpp
1160
src/SNAP/sna.cpp
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,6 @@ namespace LAMMPS_NS {
|
|||
|
||||
struct SNA_ZINDICES {
|
||||
int j1, j2, j, ma1min, ma2max, mb1min, mb2max, na, nb, jju;
|
||||
double betaj;
|
||||
};
|
||||
|
||||
struct SNA_BINDICES {
|
||||
|
@ -51,19 +50,20 @@ public:
|
|||
void compute_ui(int);
|
||||
void compute_zi();
|
||||
void compute_yi(const double*);
|
||||
void compute_yterm(int, int, int, const double*);
|
||||
void compute_bi();
|
||||
void copy_bi2bvec();
|
||||
|
||||
// functions for derivatives
|
||||
|
||||
void compute_duidrj(double*, double, double);
|
||||
void compute_dbidrj();
|
||||
void compute_deidrj(double*);
|
||||
void copy_dbi2dbvec();
|
||||
double compute_sfac(double, double);
|
||||
double compute_dsfac(double, double);
|
||||
|
||||
double* bvec, ** dbvec;
|
||||
double* blist;
|
||||
double** dblist;
|
||||
double** rij;
|
||||
int* inside;
|
||||
double* wj;
|
||||
|
@ -73,31 +73,17 @@ public:
|
|||
void grow_rij(int);
|
||||
|
||||
int twojmax, diagonalstyle;
|
||||
double*** uarraytot_r, *** uarraytot_i;
|
||||
double***** zarray_r, ***** zarray_i;
|
||||
double*** yarray_r, *** yarray_i;
|
||||
double*** uarray_r, *** uarray_i;
|
||||
|
||||
private:
|
||||
double rmin0, rfac0;
|
||||
|
||||
// use indexlist instead of loops, constructor generates these
|
||||
// data for bispectrum coefficients
|
||||
|
||||
SNA_ZINDICES* idxz;
|
||||
SNA_BINDICES* idxb;
|
||||
int idxcg_max, idxu_max, idxz_max, idxb_max;
|
||||
|
||||
// data for bispectrum coefficients
|
||||
|
||||
double***** cgarray;
|
||||
double** rootpqarray;
|
||||
double*** barray;
|
||||
|
||||
// derivatives of data
|
||||
|
||||
double**** duarray_r, **** duarray_i;
|
||||
double**** dbarray;
|
||||
|
||||
double* cglist;
|
||||
int*** idxcg_block;
|
||||
|
||||
|
@ -121,9 +107,6 @@ private:
|
|||
void destroy_twojmax_arrays();
|
||||
void init_clebsch_gordan();
|
||||
void init_rootpqarray();
|
||||
void jtostr(char*, int);
|
||||
void mtostr(char*, int, int);
|
||||
void print_clebsch_gordan(FILE*);
|
||||
void zero_uarraytot();
|
||||
void addself_uarraytot(double);
|
||||
void add_uarraytot(double, double, double);
|
||||
|
|
Loading…
Reference in New Issue