@@ -45,6 +45,7 @@ PairNNP::PairNNP(LAMMPS *lmp)
4545 cutoff = 0 .;
4646 numb_models = 0 ;
4747 out_freq = 0 ;
48+ scale = NULL ;
4849
4950 // set comm size needed by this Pair
5051 comm_reverse = 1 ;
@@ -61,12 +62,13 @@ PairNNP::print_summary(const string pre) const
6162 nnp_inter.print_summary (pre );
6263 cout << pre << " >>> Info of lammps module:" << endl;
6364 cout << pre << " use deepmd-kit at: " << STR_DEEPMD_ROOT << endl;
65+ cout << pre << " source: " << STR_GIT_SUMM << endl;
6466 cout << pre << " source branch: " << STR_GIT_BRANCH << endl;
6567 cout << pre << " source commit: " << STR_GIT_HASH << endl;
6668 cout << pre << " source commit at: " << STR_GIT_DATE << endl;
6769 cout << pre << " build float prec: " << STR_FLOAT_PREC << endl;
6870 cout << pre << " build with tf inc: " << STR_TensorFlow_INCLUDE_DIRS << endl;
69- cout << pre << " build with tf lib: " << STR_TensorFlow_LIBRARY_PATH << endl;
71+ cout << pre << " build with tf lib: " << STR_TensorFlow_LIBRARY << endl;
7072 }
7173}
7274
@@ -76,6 +78,7 @@ PairNNP::~PairNNP()
7678 if (allocated) {
7779 memory->destroy (setflag);
7880 memory->destroy (cutsq);
81+ memory->destroy (scale);
7982 }
8083}
8184
@@ -342,19 +345,19 @@ void PairNNP::compute(int eflag, int vflag)
342345 // get force
343346 for (int ii = 0 ; ii < nall; ++ii){
344347 for (int dd = 0 ; dd < 3 ; ++dd){
345- f[ii][dd] += dforce[3 *ii+dd];
348+ f[ii][dd] += scale[ 1 ][ 1 ] * dforce[3 *ii+dd];
346349 }
347350 }
348351
349352 // accumulate energy and virial
350- if (eflag) eng_vdwl += dener;
353+ if (eflag) eng_vdwl += scale[ 1 ][ 1 ] * dener;
351354 if (vflag) {
352- virial[0 ] += 1.0 * dvirial[0 ];
353- virial[1 ] += 1.0 * dvirial[4 ];
354- virial[2 ] += 1.0 * dvirial[8 ];
355- virial[3 ] += 1.0 * dvirial[3 ];
356- virial[4 ] += 1.0 * dvirial[6 ];
357- virial[5 ] += 1.0 * dvirial[7 ];
355+ virial[0 ] += 1.0 * dvirial[0 ] * scale[ 1 ][ 1 ] ;
356+ virial[1 ] += 1.0 * dvirial[4 ] * scale[ 1 ][ 1 ] ;
357+ virial[2 ] += 1.0 * dvirial[8 ] * scale[ 1 ][ 1 ] ;
358+ virial[3 ] += 1.0 * dvirial[3 ] * scale[ 1 ][ 1 ] ;
359+ virial[4 ] += 1.0 * dvirial[6 ] * scale[ 1 ][ 1 ] ;
360+ virial[5 ] += 1.0 * dvirial[7 ] * scale[ 1 ][ 1 ] ;
358361 }
359362}
360363
@@ -372,6 +375,7 @@ void PairNNP::allocate()
372375 setflag[i][i] = 1 ;
373376
374377 memory->create (cutsq,n+1 ,n+1 ," pair:cutsq" );
378+ memory->create (scale,n+1 ,n+1 ," pair:scale" );
375379}
376380
377381void PairNNP::settings (int narg, char **arg)
@@ -425,6 +429,28 @@ void PairNNP::coeff(int narg, char **arg)
425429 if (!allocated) {
426430 allocate ();
427431 }
432+
433+ int n = atom->ntypes ;
434+ int ilo,ihi,jlo,jhi;
435+ ilo = 0 ;
436+ jlo = 0 ;
437+ ihi = n;
438+ jhi = n;
439+ if (narg == 2 ) {
440+ force->bounds (FLERR,arg[0 ],atom->ntypes ,ilo,ihi);
441+ force->bounds (FLERR,arg[1 ],atom->ntypes ,jlo,jhi);
442+ if (ilo != 0 || jlo != 0 || ihi != n || jhi != n) {
443+ error->all (FLERR," deepmd requires that the scale should be set to all atom types, i.e. pair_coeff * *." );
444+ }
445+ }
446+ for (int i = ilo; i <= ihi; i++) {
447+ for (int j = MAX (jlo,i); j <= jhi; j++) {
448+ if (i == j) {
449+ setflag[i][i] = 1 ;
450+ }
451+ scale[i][j] = 1.0 ;
452+ }
453+ }
428454}
429455
430456
@@ -439,6 +465,9 @@ void PairNNP::init_style()
439465
440466double PairNNP::init_one (int i, int j)
441467{
468+ if (setflag[i][j] == 0 ) scale[i][j] = 1.0 ;
469+ scale[j][i] = scale[i][j];
470+
442471 return cutoff;
443472}
444473
@@ -480,7 +509,13 @@ void PairNNP::unpack_reverse_comm(int n, int *list, double *buf)
480509
481510void *PairNNP::extract (const char *str, int &dim)
482511{
483- dim = 0 ;
484- if (strcmp (str," cut_coul" ) == 0 ) return (void *) &cutoff;
512+ if (strcmp (str," cut_coul" ) == 0 ) {
513+ dim = 0 ;
514+ return (void *) &cutoff;
515+ }
516+ if (strcmp (str," scale" ) == 0 ) {
517+ dim = 2 ;
518+ return (void *) scale;
519+ }
485520 return NULL ;
486521}
0 commit comments