pair style rann does not support per-atom stress or pair_modify nofdotr
This commit is contained in:
@ -382,6 +382,8 @@ Pair style *rann* is part of the ML-RANN package. It is only enabled if LAMMPS
|
||||
package. Additionally, if any spin fingerprint styles are used LAMMPS must be built with the SPIN
|
||||
package as well.
|
||||
|
||||
Pair style *rann* does not support computing per-atom stress or using :doc:`pair_modify nofdotr <pair_modify>`.
|
||||
|
||||
Defaults
|
||||
""""""""""""
|
||||
|
||||
|
||||
@ -701,15 +701,22 @@ bool PairRANN::check_potential() {
|
||||
|
||||
void PairRANN::compute(int eflag, int vflag)
|
||||
{
|
||||
//perform force/energy computation_
|
||||
//perform force/energy computation_
|
||||
if (dospin) {
|
||||
if (strcmp(update->unit_style,"metal") != 0)
|
||||
error->one(FLERR,"Spin pair styles require metal units");
|
||||
if (!atom->sp_flag)
|
||||
error->one(FLERR,"Spin pair styles requires atom/spin style");
|
||||
}
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = vflag_atom = 0;
|
||||
ev_init(eflag,vflag);
|
||||
|
||||
// only global virial via fdotr is supported by this pair style
|
||||
|
||||
if (vflag_atom)
|
||||
error->all(FLERR,"Pair style rann does not support computing per-atom stress");
|
||||
if (vflag && !vflag_fdotr)
|
||||
error->all(FLERR,"Pair style rann does not support 'pair_modify nofdotr'");
|
||||
|
||||
int ii,i,j;
|
||||
int nn = 0;
|
||||
sims = new Simulation[1];
|
||||
@ -724,13 +731,11 @@ void PairRANN::compute(int eflag, int vflag)
|
||||
sims->s = atom->sp;
|
||||
}
|
||||
int itype,f,jnum,len;
|
||||
if (eflag || vflag) ev_setup(eflag,vflag);
|
||||
else evflag = vflag_fdotr = eflag_global = eflag_atom = 0;
|
||||
if (eflag_global) {eng_vdwl=0;eng_coul=0;}
|
||||
double energy=0;
|
||||
double **force = atom->f;
|
||||
double **fm = atom->fm;
|
||||
double **virial = vatom;
|
||||
|
||||
//loop over atoms
|
||||
for (ii=0;ii<sims->inum;ii++) {
|
||||
i = sims->ilist[ii];
|
||||
@ -800,12 +805,8 @@ void PairRANN::compute(int eflag, int vflag)
|
||||
sx[j]=sy[j]=sz[j]=0;
|
||||
}
|
||||
}
|
||||
if (doscreen) {
|
||||
screen(ii,0,jnum-1);
|
||||
}
|
||||
if (allscreen) {
|
||||
screen_neighbor_list(&jnum);
|
||||
}
|
||||
if (doscreen) screening(ii,0,jnum-1);
|
||||
if (allscreen) screen_neighbor_list(&jnum);
|
||||
//do fingerprints for atom type
|
||||
len = fingerprintperelement[itype];
|
||||
for (j=0;j<len;j++) {
|
||||
@ -825,10 +826,9 @@ void PairRANN::compute(int eflag, int vflag)
|
||||
}
|
||||
//run fingerprints through network
|
||||
if (dospin) {
|
||||
propagateforwardspin(&energy,force,fm,virial,ii,jnum);
|
||||
}
|
||||
else {
|
||||
propagateforward(&energy,force,virial,ii,jnum);
|
||||
propagateforwardspin(&energy,force,fm,ii,jnum);
|
||||
} else {
|
||||
propagateforward(&energy,force,ii,jnum);
|
||||
}
|
||||
}
|
||||
if (vflag_fdotr) virial_fdotr_compute();
|
||||
@ -905,7 +905,7 @@ void PairRANN::screen_neighbor_list(int *jnum) {
|
||||
}
|
||||
|
||||
|
||||
void PairRANN::screen(int ii,int sid,int jnum)
|
||||
void PairRANN::screening(int ii,int sid,int jnum)
|
||||
{
|
||||
//see Baskes, Materials Chemistry and Physics 50 (1997) 152-1.58
|
||||
int i,jj,kk,itype,jtype,ktype;
|
||||
@ -999,7 +999,7 @@ void PairRANN::screen(int ii,int sid,int jnum)
|
||||
|
||||
|
||||
//Called by getproperties. Propagate features and dfeatures through network. Updates force and energy
|
||||
void PairRANN::propagateforward(double * energy,double **force,double ** /*virial*/, int ii,int jnum) {
|
||||
void PairRANN::propagateforward(double *energy,double **force,int ii,int jnum) {
|
||||
int i,j,k,jj,j1,itype,i1;
|
||||
int *ilist;
|
||||
ilist = listfull->ilist;
|
||||
@ -1026,8 +1026,8 @@ void PairRANN::propagateforward(double * energy,double **force,double ** /*viria
|
||||
sum[j] = activation[itype][i]->activation_function(sum[j]);
|
||||
if (i==L-1) {
|
||||
energy[j] = sum[j];
|
||||
if (eflag_atom)eatom[i1]=sum[j];
|
||||
if (eflag_global) {eng_vdwl +=sum[j];}
|
||||
if (eflag_atom) eatom[i1]=sum[j];
|
||||
if (eflag_global) eng_vdwl +=sum[j];
|
||||
}
|
||||
//force propagation
|
||||
for (jj=0;jj<jnum;jj++) {
|
||||
@ -1076,7 +1076,7 @@ void PairRANN::propagateforward(double * energy,double **force,double ** /*viria
|
||||
}
|
||||
|
||||
//Called by getproperties. Propagate features and dfeatures through network. Updates force and energy
|
||||
void PairRANN::propagateforwardspin(double * energy,double **force,double **fm,double ** /*virial*/, int ii,int jnum) {
|
||||
void PairRANN::propagateforwardspin(double * energy,double **force,double **fm,int ii,int jnum) {
|
||||
int i,j,k,jj,j1,itype,i1;
|
||||
int *ilist;
|
||||
ilist = listfull->ilist;
|
||||
@ -1103,8 +1103,8 @@ void PairRANN::propagateforwardspin(double * energy,double **force,double **fm,d
|
||||
sum[j] = activation[itype][i]->activation_function(sum[j]);
|
||||
if (i==L-1) {
|
||||
energy[j] = sum[j];
|
||||
if (eflag_atom)eatom[i1]=sum[j];
|
||||
if (eflag_global) {eng_vdwl +=sum[j];}
|
||||
if (eflag_atom) eatom[i1]=sum[j];
|
||||
if (eflag_global) eng_vdwl +=sum[j];
|
||||
}
|
||||
//force propagation
|
||||
for (jj=0;jj<jnum;jj++) {
|
||||
@ -1173,13 +1173,11 @@ void PairRANN::propagateforwardspin(double * energy,double **force,double **fm,d
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PairRANN::init_list(int /*which*/, NeighList *ptr)
|
||||
{
|
||||
listfull = ptr;
|
||||
}
|
||||
|
||||
|
||||
void PairRANN::init_style()
|
||||
{
|
||||
int irequest_full = neighbor->request(this,instance_me);
|
||||
|
||||
@ -149,9 +149,9 @@ namespace LAMMPS_NS {
|
||||
void read_screening(std::vector<std::string>,std::vector<std::string>,char*,int);
|
||||
void read_mass(const std::vector<std::string> &, const std::vector<std::string> &,const char*,int);
|
||||
bool check_potential();//after finishing reading potential file
|
||||
void propagateforward(double *,double **,double **,int,int);//called by compute to get force and energy
|
||||
void propagateforwardspin(double *,double **,double **,double**,int,int);//called by compute to get force and energy
|
||||
void screen(int,int,int);
|
||||
void propagateforward(double *,double **,int,int);//called by compute to get force and energy
|
||||
void propagateforwardspin(double *,double **,double**,int,int);//called by compute to get force and energy
|
||||
void screening(int,int,int);
|
||||
void cull_neighbor_list(int *,int,int);
|
||||
void screen_neighbor_list(int *);
|
||||
};
|
||||
|
||||
@ -523,36 +523,39 @@ TEST(PairStyle, plain)
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats) std::cerr << "restart_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
restart_lammps(lmp, test_config, true);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
// pair style rann does not support pair_modify nofdotr
|
||||
if (test_config.pair_style != "rann") {
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
restart_lammps(lmp, test_config, true);
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
f = lmp->atom->f;
|
||||
tag = lmp->atom->tag;
|
||||
stats.reset();
|
||||
ASSERT_EQ(nlocal + 1, f_ref.size());
|
||||
for (int i = 0; i < nlocal; ++i) {
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][0], f_ref[tag[i]].x, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][1], f_ref[tag[i]].y, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(f[i][2], f_ref[tag[i]].z, epsilon);
|
||||
}
|
||||
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats) std::cerr << "nofdotr_energy stats:" << stats << std::endl;
|
||||
}
|
||||
if (print_stats) std::cerr << "nofdotr_forces stats:" << stats << std::endl;
|
||||
|
||||
pair = lmp->force->pair;
|
||||
stress = pair->virial;
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(stress[0], test_config.init_stress.xx, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[1], test_config.init_stress.yy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[2], test_config.init_stress.zz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[3], test_config.init_stress.xy, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[4], test_config.init_stress.xz, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(stress[5], test_config.init_stress.yz, epsilon);
|
||||
if (print_stats) std::cerr << "nofdotr_stress stats:" << stats << std::endl;
|
||||
|
||||
stats.reset();
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_vdwl, test_config.init_vdwl, epsilon);
|
||||
EXPECT_FP_LE_WITH_EPS(pair->eng_coul, test_config.init_coul, epsilon);
|
||||
if (print_stats) std::cerr << "nofdotr_energy stats:" << stats << std::endl;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
data_lammps(lmp, test_config);
|
||||
@ -1091,9 +1094,9 @@ TEST(PairStyle, intel)
|
||||
|
||||
// pair styles sw and tersoff and airebo INTEL package variants require newton on,
|
||||
// but that also requires fdotr for /intel
|
||||
if ((test_config.pair_style != "sw") && (test_config.pair_style != "tersoff")
|
||||
&& (test_config.pair_style != "rebo") && (test_config.pair_style != "airebo")
|
||||
&& (test_config.pair_style != "airebo/morse")) {
|
||||
if ((test_config.pair_style != "sw") && (test_config.pair_style != "tersoff") &&
|
||||
(test_config.pair_style != "rebo") && (test_config.pair_style != "airebo") &&
|
||||
(test_config.pair_style != "airebo/morse")) {
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
restart_lammps(lmp, test_config, true, true);
|
||||
|
||||
Reference in New Issue
Block a user