Correctly reproduced examples/in.snap.compute, not yet for quadratic case
This commit is contained in:
@ -93,8 +93,8 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
nperdim = nparams;
|
nperdim = nparams;
|
||||||
ndims_force = 3;
|
ndims_force = 3;
|
||||||
ndims_virial = 6;
|
ndims_virial = 6;
|
||||||
yoffset = nperdim;
|
yoffset = nperdim*atom->ntypes;
|
||||||
zoffset = 2*nperdim;
|
zoffset = 2*yoffset;
|
||||||
natoms = atom->natoms;
|
natoms = atom->natoms;
|
||||||
size_array_rows = 1+ndims_force*natoms+ndims_virial;
|
size_array_rows = 1+ndims_force*natoms+ndims_virial;
|
||||||
size_array_cols = nperdim*atom->ntypes+1;
|
size_array_cols = nperdim*atom->ntypes+1;
|
||||||
@ -169,14 +169,12 @@ void ComputeMLIAP::init()
|
|||||||
|
|
||||||
// allocate memory for global array
|
// allocate memory for global array
|
||||||
|
|
||||||
printf("size_array_rows = %d size_array_cols = %d\n",size_array_rows,size_array_cols);
|
|
||||||
memory->create(mliap,size_array_rows,size_array_cols,
|
memory->create(mliap,size_array_rows,size_array_cols,
|
||||||
"mliap:mliap");
|
"mliap:mliap");
|
||||||
memory->create(mliapall,size_array_rows,size_array_cols,
|
memory->create(mliapall,size_array_rows,size_array_cols,
|
||||||
"mliap:mliapall");
|
"mliap:mliapall");
|
||||||
array = mliapall;
|
array = mliapall;
|
||||||
|
|
||||||
printf("nelements = %d nparams = %d\n",nelements,nparams);
|
|
||||||
memory->create(egradient,nelements*nparams,"ComputeMLIAP:egradient");
|
memory->create(egradient,nelements*nparams,"ComputeMLIAP:egradient");
|
||||||
|
|
||||||
// find compute for reference energy
|
// find compute for reference energy
|
||||||
@ -227,7 +225,6 @@ void ComputeMLIAP::compute_array()
|
|||||||
if (atom->nmax > nmax) {
|
if (atom->nmax > nmax) {
|
||||||
memory->destroy(mliap_peratom);
|
memory->destroy(mliap_peratom);
|
||||||
nmax = atom->nmax;
|
nmax = atom->nmax;
|
||||||
printf("nmax = %d size_peratom = %d\n",nmax,size_peratom);
|
|
||||||
memory->create(mliap_peratom,nmax,size_peratom,
|
memory->create(mliap_peratom,nmax,size_peratom,
|
||||||
"mliap:mliap_peratom");
|
"mliap:mliap_peratom");
|
||||||
}
|
}
|
||||||
@ -256,7 +253,6 @@ void ComputeMLIAP::compute_array()
|
|||||||
memory->grow(gamma,list->inum,gamma_nnz,"ComputeMLIAP:gamma");
|
memory->grow(gamma,list->inum,gamma_nnz,"ComputeMLIAP:gamma");
|
||||||
gamma_max = list->inum;
|
gamma_max = list->inum;
|
||||||
}
|
}
|
||||||
printf("gamma_max %d %d %d %d %d %d %p\n",gamma_max, ndescriptors, gamma_nnz, nelements, nparams, list->inum, list);
|
|
||||||
|
|
||||||
// compute descriptors, if needed
|
// compute descriptors, if needed
|
||||||
|
|
||||||
@ -283,7 +279,7 @@ void ComputeMLIAP::compute_array()
|
|||||||
// accumulate descriptor gradient contributions to global array
|
// accumulate descriptor gradient contributions to global array
|
||||||
|
|
||||||
for (int itype = 0; itype < atom->ntypes; itype++) {
|
for (int itype = 0; itype < atom->ntypes; itype++) {
|
||||||
const int typeoffset_local = ndims_peratom*nperdim*itype;
|
const int typeoffset_local = nperdim*itype;
|
||||||
const int typeoffset_global = nperdim*itype;
|
const int typeoffset_global = nperdim*itype;
|
||||||
for (int icoeff = 0; icoeff < nperdim; icoeff++) {
|
for (int icoeff = 0; icoeff < nperdim; icoeff++) {
|
||||||
int irow = 1;
|
int irow = 1;
|
||||||
@ -360,7 +356,7 @@ void ComputeMLIAP::dbdotr_compute()
|
|||||||
int nall = atom->nlocal + atom->nghost;
|
int nall = atom->nlocal + atom->nghost;
|
||||||
for (int i = 0; i < nall; i++)
|
for (int i = 0; i < nall; i++)
|
||||||
for (int itype = 0; itype < atom->ntypes; itype++) {
|
for (int itype = 0; itype < atom->ntypes; itype++) {
|
||||||
const int typeoffset_local = ndims_peratom*nperdim*itype;
|
const int typeoffset_local = nperdim*itype;
|
||||||
const int typeoffset_global = nperdim*itype;
|
const int typeoffset_global = nperdim*itype;
|
||||||
double *snadi = mliap_peratom[i]+typeoffset_local;
|
double *snadi = mliap_peratom[i]+typeoffset_local;
|
||||||
for (int icoeff = 0; icoeff < nperdim; icoeff++) {
|
for (int icoeff = 0; icoeff < nperdim; icoeff++) {
|
||||||
|
|||||||
@ -228,9 +228,6 @@ void MLIAPDescriptorSNAP::backward(PairMLIAP* pairmliap, NeighList* list, double
|
|||||||
// add to Fi, subtract from Fj
|
// add to Fi, subtract from Fj
|
||||||
|
|
||||||
snaptr->compute_yi(beta[ii]);
|
snaptr->compute_yi(beta[ii]);
|
||||||
//for (int q=0; q<snaptr->idxu_max*2; q++){
|
|
||||||
// fprintf(screen, "%i %f\n",q, snaptr->ylist_r[q]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
for (int jj = 0; jj < ninside; jj++) {
|
for (int jj = 0; jj < ninside; jj++) {
|
||||||
int j = snaptr->inside[jj];
|
int j = snaptr->inside[jj];
|
||||||
@ -294,11 +291,11 @@ void MLIAPDescriptorSNAP::param_backward(int *map, NeighList* list,
|
|||||||
const double ytmp = x[i][1];
|
const double ytmp = x[i][1];
|
||||||
const double ztmp = x[i][2];
|
const double ztmp = x[i][2];
|
||||||
const int itype = type[i];
|
const int itype = type[i];
|
||||||
int ielem = 0;
|
int ielem = itype-1;
|
||||||
if (chemflag)
|
// element map not yet implemented
|
||||||
|
// if (chemflag)
|
||||||
// element map not yet implemented
|
// element map not yet implemented
|
||||||
// ielem = map[itype];
|
// ielem = map[itype];
|
||||||
const int ielem = itype-1;
|
|
||||||
|
|
||||||
jlist = firstneigh[i];
|
jlist = firstneigh[i];
|
||||||
jnum = numneigh[i];
|
jnum = numneigh[i];
|
||||||
@ -322,14 +319,17 @@ void MLIAPDescriptorSNAP::param_backward(int *map, NeighList* list,
|
|||||||
delz = x[j][2] - ztmp;
|
delz = x[j][2] - ztmp;
|
||||||
rsq = delx*delx + dely*dely + delz*delz;
|
rsq = delx*delx + dely*dely + delz*delz;
|
||||||
int jtype = type[j];
|
int jtype = type[j];
|
||||||
|
int jelem = jtype-1;
|
||||||
// element map not yet implemented
|
// element map not yet implemented
|
||||||
// int jelem = map[jtype];
|
// if (chemflag)
|
||||||
const int jelem = jtype-1;
|
// jelem = map[jtype];
|
||||||
|
|
||||||
if (rsq < cutsq[ielem][jelem]) {
|
if (rsq < cutsq[ielem][jelem]) {
|
||||||
snaptr->rij[ninside][0] = delx;
|
snaptr->rij[ninside][0] = delx;
|
||||||
snaptr->rij[ninside][1] = dely;
|
snaptr->rij[ninside][1] = dely;
|
||||||
snaptr->rij[ninside][2] = delz;
|
snaptr->rij[ninside][2] = delz;
|
||||||
snaptr->inside[ninside] = j;
|
snaptr->inside[ninside] = j;
|
||||||
|
// element map not yet implemented
|
||||||
snaptr->wj[ninside] = wjelem[jelem];
|
snaptr->wj[ninside] = wjelem[jelem];
|
||||||
snaptr->rcutij[ninside] = sqrt(cutsq[ielem][jelem]);
|
snaptr->rcutij[ninside] = sqrt(cutsq[ielem][jelem]);
|
||||||
snaptr->element[ninside] = jelem; // element index for chem snap
|
snaptr->element[ninside] = jelem; // element index for chem snap
|
||||||
@ -337,14 +337,13 @@ void MLIAPDescriptorSNAP::param_backward(int *map, NeighList* list,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chemflag)
|
if (chemflag)
|
||||||
snaptr->compute_ui(ninside, ielem);
|
snaptr->compute_ui(ninside, ielem);
|
||||||
else
|
else
|
||||||
snaptr->compute_ui(ninside, 0);
|
snaptr->compute_ui(ninside, 0);
|
||||||
|
|
||||||
|
|
||||||
snaptr->compute_zi();
|
snaptr->compute_zi();
|
||||||
if(chemflag)
|
if (chemflag)
|
||||||
snaptr->compute_bi(ielem);
|
snaptr->compute_bi(ielem);
|
||||||
else
|
else
|
||||||
snaptr->compute_bi(0);
|
snaptr->compute_bi(0);
|
||||||
@ -352,12 +351,12 @@ void MLIAPDescriptorSNAP::param_backward(int *map, NeighList* list,
|
|||||||
for (int jj = 0; jj < ninside; jj++) {
|
for (int jj = 0; jj < ninside; jj++) {
|
||||||
const int j = snaptr->inside[jj];
|
const int j = snaptr->inside[jj];
|
||||||
|
|
||||||
if(chemflag)
|
if(chemflag)
|
||||||
snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj],
|
snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj],
|
||||||
snaptr->rcutij[jj], jj, snaptr->element[jj]);
|
snaptr->rcutij[jj],jj, snaptr->element[jj]);
|
||||||
else
|
else
|
||||||
snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj],
|
snaptr->compute_duidrj(snaptr->rij[jj], snaptr->wj[jj],
|
||||||
snaptr->rcutij[jj], jj, 0);
|
snaptr->rcutij[jj],jj, 0);
|
||||||
|
|
||||||
snaptr->compute_dbidrj();
|
snaptr->compute_dbidrj();
|
||||||
|
|
||||||
@ -541,11 +540,9 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename)
|
|||||||
cut = 2.0*radelem[ielem]*rcutfac;
|
cut = 2.0*radelem[ielem]*rcutfac;
|
||||||
if (cut > cutmax) cutmax = cut;
|
if (cut > cutmax) cutmax = cut;
|
||||||
cutsq[ielem][ielem] = cut*cut;
|
cutsq[ielem][ielem] = cut*cut;
|
||||||
printf("ielem = %d ielem = %d cutsq[i][i] = %g\n",ielem, ielem, cutsq[ielem][ielem]);
|
|
||||||
for(int jelem = ielem+1; jelem < nelements; jelem++) {
|
for(int jelem = ielem+1; jelem < nelements; jelem++) {
|
||||||
cut = (radelem[ielem]+radelem[jelem])*rcutfac;
|
cut = (radelem[ielem]+radelem[jelem])*rcutfac;
|
||||||
cutsq[ielem][jelem] = cutsq[jelem][ielem] = cut*cut;
|
cutsq[ielem][jelem] = cutsq[jelem][ielem] = cut*cut;
|
||||||
printf("ielem = %d jelem = %d cutsq[i][j] = %g\n",ielem, jelem, cutsq[ielem][jelem]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -315,6 +315,7 @@ void Thermo::header()
|
|||||||
|
|
||||||
std::string hdr;
|
std::string hdr;
|
||||||
for (int i = 0; i < nfield; i++) hdr += keyword[i] + std::string(" ");
|
for (int i = 0; i < nfield; i++) hdr += keyword[i] + std::string(" ");
|
||||||
|
hdr += "\n";
|
||||||
if (me == 0) utils::logmesg(lmp,hdr);
|
if (me == 0) utils::logmesg(lmp,hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user