enable and apply clang-format, remove redundant code, improve error message for EAM potential pair styles

This commit is contained in:
Axel Kohlmeyer
2023-03-25 06:48:59 -04:00
parent 7edb42f190
commit 22a1cf935e
16 changed files with 385 additions and 424 deletions

View File

@ -138,8 +138,7 @@ void PairEAMAlloyGPU::compute(int eflag, int vflag)
eam_alloy_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else
eam_alloy_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0)
neighbor->build_topology();
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
}
/* ----------------------------------------------------------------------
@ -282,12 +281,8 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes) error->all(FLERR, "Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0], "*") != 0 || strcmp(arg[1], "*") != 0)
error->all(FLERR, "Incorrect args for pair coefficients");
if (narg != 3 + atom->ntypes)
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM setfl file

View File

@ -138,8 +138,7 @@ void PairEAMFSGPU::compute(int eflag, int vflag)
eam_fs_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else
eam_fs_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0)
neighbor->build_topology();
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
}
/* ----------------------------------------------------------------------
@ -282,12 +281,8 @@ void PairEAMFSGPU::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes) error->all(FLERR, "Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0], "*") != 0 || strcmp(arg[1], "*") != 0)
error->all(FLERR, "Incorrect args for pair coefficients");
if (narg != 3 + atom->ntypes)
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM Finnis-Sinclair file

View File

@ -136,8 +136,7 @@ void PairEAMGPU::compute(int eflag, int vflag)
eam_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else
eam_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0)
neighbor->build_topology();
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
}
/* ----------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -48,12 +47,7 @@ void PairEAMAlloyIntel::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM setfl file
@ -79,16 +73,17 @@ void PairEAMAlloyIntel::coeff(int narg, char **arg)
}
for (j = 0; j < setfl->nelements; j++)
if (strcmp(arg[i], setfl->elements[j]) == 0) break;
if (j < setfl->nelements) map[i-2] = j;
else error->all(FLERR,"No matching element in EAM potential file");
if (j < setfl->nelements)
map[i - 2] = j;
else
error->all(FLERR, "No matching element in EAM potential file");
}
// clear setflag since coeff() called once with I,J = * *
int n = atom->ntypes;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
setflag[i][j] = 0;
for (j = i; j <= n; j++) setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
// set mass of atom type if i = j
@ -123,8 +118,7 @@ void PairEAMAlloyIntel::read_file(char *filename)
// transparently convert units for supported conversions
int unit_convert = reader.get_unit_convert();
double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
unit_convert);
double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert);
try {
reader.skip_line();
reader.skip_line();
@ -164,8 +158,7 @@ void PairEAMAlloyIntel::read_file(char *filename)
reader.next_dvector(&file->frho[i][1], file->nrho);
reader.next_dvector(&file->rhor[i][1], file->nr);
if (unit_convert) {
for (int j = 1; j < file->nrho; ++j)
file->frho[i][j] *= conversion_factor;
for (int j = 1; j < file->nrho; ++j) file->frho[i][j] *= conversion_factor;
}
}
@ -173,8 +166,7 @@ void PairEAMAlloyIntel::read_file(char *filename)
for (int j = 0; j <= i; j++) {
reader.next_dvector(&file->z2r[i][j][1], file->nr);
if (unit_convert) {
for (int k = 1; k < file->nr; ++k)
file->z2r[i][j][k] *= conversion_factor;
for (int k = 1; k < file->nr; ++k) file->z2r[i][j][k] *= conversion_factor;
}
}
}
@ -220,9 +212,7 @@ void PairEAMAlloyIntel::read_file(char *filename)
// broadcast file->z2r
for (int i = 0; i < file->nelements; i++) {
for (int j = 0; j <= i; j++) {
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
}
for (int j = 0; j <= i; j++) { MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); }
}
}
@ -269,8 +259,10 @@ void PairEAMAlloyIntel::file2array()
// then map it to last frho array of zeroes
for (i = 1; i <= ntypes; i++)
if (map[i] >= 0) type2frho[i] = map[i];
else type2frho[i] = nfrho-1;
if (map[i] >= 0)
type2frho[i] = map[i];
else
type2frho[i] = nfrho - 1;
// ------------------------------------------------------------------
// setup rhor arrays
@ -293,8 +285,7 @@ void PairEAMAlloyIntel::file2array()
// OK if map = -1 (non-EAM atom in pair hybrid) b/c type2rhor not used
for (i = 1; i <= ntypes; i++)
for (j = 1; j <= ntypes; j++)
type2rhor[i][j] = map[i];
for (j = 1; j <= ntypes; j++) type2rhor[i][j] = map[i];
// ------------------------------------------------------------------
// setup z2r arrays

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -48,12 +47,7 @@ void PairEAMFSIntel::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM Finnis-Sinclair file
@ -79,16 +73,17 @@ void PairEAMFSIntel::coeff(int narg, char **arg)
}
for (j = 0; j < fs->nelements; j++)
if (strcmp(arg[i], fs->elements[j]) == 0) break;
if (j < fs->nelements) map[i-2] = j;
else error->all(FLERR,"No matching element in EAM potential file");
if (j < fs->nelements)
map[i - 2] = j;
else
error->all(FLERR, "No matching element in EAM potential file");
}
// clear setflag since coeff() called once with I,J = * *
int n = atom->ntypes;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
setflag[i][j] = 0;
for (j = i; j <= n; j++) setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
// set mass of atom type if i = j
@ -123,8 +118,7 @@ void PairEAMFSIntel::read_file(char *filename)
// transparently convert units for supported conversions
int unit_convert = reader.get_unit_convert();
double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
unit_convert);
double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert);
try {
reader.skip_line();
reader.skip_line();
@ -163,8 +157,7 @@ void PairEAMFSIntel::read_file(char *filename)
reader.next_dvector(&file->frho[i][1], file->nrho);
if (unit_convert) {
for (int j = 1; j <= file->nrho; ++j)
file->frho[i][j] *= conversion_factor;
for (int j = 1; j <= file->nrho; ++j) file->frho[i][j] *= conversion_factor;
}
for (int j = 0; j < file->nelements; j++) {
@ -176,8 +169,7 @@ void PairEAMFSIntel::read_file(char *filename)
for (int j = 0; j <= i; j++) {
reader.next_dvector(&file->z2r[i][j][1], file->nr);
if (unit_convert) {
for (int k = 1; k <= file->nr; ++k)
file->z2r[i][j][k] *= conversion_factor;
for (int k = 1; k <= file->nr; ++k) file->z2r[i][j][k] *= conversion_factor;
}
}
}
@ -226,9 +218,7 @@ void PairEAMFSIntel::read_file(char *filename)
// broadcast file->z2r
for (int i = 0; i < file->nelements; i++) {
for (int j = 0; j <= i; j++) {
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
}
for (int j = 0; j <= i; j++) { MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); }
}
}
@ -275,8 +265,10 @@ void PairEAMFSIntel::file2array()
// then map it to last frho array of zeroes
for (i = 1; i <= ntypes; i++)
if (map[i] >= 0) type2frho[i] = map[i];
else type2frho[i] = nfrho-1;
if (map[i] >= 0)
type2frho[i] = map[i];
else
type2frho[i] = nfrho - 1;
// ------------------------------------------------------------------
// setup rhor arrays
@ -303,8 +295,7 @@ void PairEAMFSIntel::file2array()
// OK if map = -1 (non-EAM atom in pair hybrid) b/c type2rhor not used
for (i = 1; i <= ntypes; i++)
for (j = 1; j <= ntypes; j++)
type2rhor[i][j] = map[i] * fs->nelements + map[j];
for (j = 1; j <= ntypes; j++) type2rhor[i][j] = map[i] * fs->nelements + map[j];
// ------------------------------------------------------------------
// setup z2r arrays

View File

@ -919,12 +919,7 @@ void PairEAMAlloyKokkos<DeviceType>::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM setfl file

View File

@ -920,12 +920,7 @@ void PairEAMFSKokkos<DeviceType>::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM Finnis-Sinclair file

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -48,7 +47,7 @@ void PairEAMAlloy::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM setfl file
@ -74,16 +73,17 @@ void PairEAMAlloy::coeff(int narg, char **arg)
}
for (j = 0; j < setfl->nelements; j++)
if (strcmp(arg[i], setfl->elements[j]) == 0) break;
if (j < setfl->nelements) map[i-2] = j;
else error->all(FLERR,"No matching element in EAM potential file");
if (j < setfl->nelements)
map[i - 2] = j;
else
error->all(FLERR, "No matching element in EAM potential file");
}
// clear setflag since coeff() called once with I,J = * *
int n = atom->ntypes;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
setflag[i][j] = 0;
for (j = i; j <= n; j++) setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
// set mass of atom type if i = j
@ -118,8 +118,7 @@ void PairEAMAlloy::read_file(char *filename)
// transparently convert units for supported conversions
int unit_convert = reader.get_unit_convert();
double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
unit_convert);
double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert);
try {
reader.skip_line();
reader.skip_line();
@ -159,8 +158,7 @@ void PairEAMAlloy::read_file(char *filename)
reader.next_dvector(&file->frho[i][1], file->nrho);
reader.next_dvector(&file->rhor[i][1], file->nr);
if (unit_convert) {
for (int j = 1; j < file->nrho; ++j)
file->frho[i][j] *= conversion_factor;
for (int j = 1; j < file->nrho; ++j) file->frho[i][j] *= conversion_factor;
}
}
@ -168,8 +166,7 @@ void PairEAMAlloy::read_file(char *filename)
for (int j = 0; j <= i; j++) {
reader.next_dvector(&file->z2r[i][j][1], file->nr);
if (unit_convert) {
for (int k = 1; k < file->nr; ++k)
file->z2r[i][j][k] *= conversion_factor;
for (int k = 1; k < file->nr; ++k) file->z2r[i][j][k] *= conversion_factor;
}
}
}
@ -215,9 +212,7 @@ void PairEAMAlloy::read_file(char *filename)
// broadcast file->z2r
for (int i = 0; i < file->nelements; i++) {
for (int j = 0; j <= i; j++) {
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
}
for (int j = 0; j <= i; j++) { MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); }
}
}
@ -264,8 +259,10 @@ void PairEAMAlloy::file2array()
// then map it to last frho array of zeroes
for (i = 1; i <= ntypes; i++)
if (map[i] >= 0) type2frho[i] = map[i];
else type2frho[i] = nfrho-1;
if (map[i] >= 0)
type2frho[i] = map[i];
else
type2frho[i] = nfrho - 1;
// ------------------------------------------------------------------
// setup rhor arrays
@ -288,8 +285,7 @@ void PairEAMAlloy::file2array()
// OK if map = -1 (non-EAM atom in pair hybrid) b/c type2rhor not used
for (i = 1; i <= ntypes; i++)
for (j = 1; j <= ntypes; j++)
type2rhor[i][j] = map[i];
for (j = 1; j <= ntypes; j++) type2rhor[i][j] = map[i];
// ------------------------------------------------------------------
// setup z2r arrays

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -49,7 +48,7 @@ void PairEAMFS::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes)
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM Finnis-Sinclair file
@ -75,16 +74,17 @@ void PairEAMFS::coeff(int narg, char **arg)
}
for (j = 0; j < fs->nelements; j++)
if (strcmp(arg[i], fs->elements[j]) == 0) break;
if (j < fs->nelements) map[i-2] = j;
else error->all(FLERR,"No matching element in EAM potential file");
if (j < fs->nelements)
map[i - 2] = j;
else
error->all(FLERR, "No matching element in EAM potential file");
}
// clear setflag since coeff() called once with I,J = * *
int n = atom->ntypes;
for (i = 1; i <= n; i++)
for (j = i; j <= n; j++)
setflag[i][j] = 0;
for (j = i; j <= n; j++) setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
// set mass of atom type if i = j
@ -114,14 +114,12 @@ void PairEAMFS::read_file(char *filename)
// read potential file
if (comm->me == 0) {
PotentialFileReader reader(lmp, filename, he_flag ? "eam/he" : "eam/fs",
unit_convert_flag);
PotentialFileReader reader(lmp, filename, he_flag ? "eam/he" : "eam/fs", unit_convert_flag);
// transparently convert units for supported conversions
int unit_convert = reader.get_unit_convert();
double conversion_factor = utils::get_conversion_factor(utils::ENERGY,
unit_convert);
double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert);
try {
reader.skip_line();
reader.skip_line();
@ -138,8 +136,10 @@ void PairEAMFS::read_file(char *filename)
for (int i = 0; i < file->nelements; i++)
file->elements[i] = utils::strdup(values.next_string());
if (he_flag) values = reader.next_values(6);
else values = reader.next_values(5);
if (he_flag)
values = reader.next_values(6);
else
values = reader.next_values(5);
file->nrho = values.next_int();
file->drho = values.next_double();
file->nr = values.next_int();
@ -162,8 +162,7 @@ void PairEAMFS::read_file(char *filename)
reader.next_dvector(&file->frho[i][1], file->nrho);
if (unit_convert) {
for (int j = 1; j <= file->nrho; ++j)
file->frho[i][j] *= conversion_factor;
for (int j = 1; j <= file->nrho; ++j) file->frho[i][j] *= conversion_factor;
}
for (int j = 0; j < file->nelements; j++) {
@ -175,8 +174,7 @@ void PairEAMFS::read_file(char *filename)
for (int j = 0; j <= i; j++) {
reader.next_dvector(&file->z2r[i][j][1], file->nr);
if (unit_convert) {
for (int k = 1; k <= file->nr; ++k)
file->z2r[i][j][k] *= conversion_factor;
for (int k = 1; k <= file->nr; ++k) file->z2r[i][j][k] *= conversion_factor;
}
}
}
@ -226,9 +224,7 @@ void PairEAMFS::read_file(char *filename)
// broadcast file->z2r
for (int i = 0; i < file->nelements; i++) {
for (int j = 0; j <= i; j++) {
MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world);
}
for (int j = 0; j <= i; j++) { MPI_Bcast(&file->z2r[i][j][1], file->nr, MPI_DOUBLE, 0, world); }
}
}
@ -247,8 +243,10 @@ void PairEAMFS::file2array()
nr = fs->nr;
drho = fs->drho;
dr = fs->dr;
if (he_flag) rhomin = rhomax - (nrho-1) * drho;
else rhomax = (nrho-1) * drho;
if (he_flag)
rhomin = rhomax - (nrho - 1) * drho;
else
rhomax = (nrho - 1) * drho;
// ------------------------------------------------------------------
// setup frho arrays
@ -276,8 +274,10 @@ void PairEAMFS::file2array()
// then map it to last frho array of zeroes
for (i = 1; i <= ntypes; i++)
if (map[i] >= 0) type2frho[i] = map[i];
else type2frho[i] = nfrho-1;
if (map[i] >= 0)
type2frho[i] = map[i];
else
type2frho[i] = nfrho - 1;
// ------------------------------------------------------------------
// setup rhor arrays
@ -304,8 +304,7 @@ void PairEAMFS::file2array()
// OK if map = -1 (non-EAM atom in pair hybrid) b/c type2rhor not used
for (i = 1; i <= ntypes; i++)
for (j = 1; j <= ntypes; j++)
type2rhor[i][j] = map[i] * fs->nelements + map[j];
for (j = 1; j <= ntypes; j++) type2rhor[i][j] = map[i] * fs->nelements + map[j];
// ------------------------------------------------------------------
// setup z2r arrays

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -76,7 +75,8 @@ void PairEAMHE::compute(int eflag, int vflag)
if (newton_pair) {
for (i = 0; i < nall; i++) rho[i] = 0.0;
} else for (i = 0; i < nlocal; i++) rho[i] = 0.0;
} else
for (i = 0; i < nlocal; i++) rho[i] = 0.0;
// rho = density at each atom
// loop over neighbors of my atoms
@ -228,12 +228,10 @@ void PairEAMHE::compute(int eflag, int vflag)
}
if (eflag) evdwl = scale[itype][jtype] * phi;
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz);
}
}
}
if (vflag_fdotr) virial_fdotr_compute();
}

View File

@ -45,7 +45,8 @@ void PairEAMAlloyOMP::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes) error->all(FLERR, "Incorrect args for pair coefficients");
if (narg != 3 + atom->ntypes)
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM setfl file

View File

@ -45,7 +45,8 @@ void PairEAMFSOMP::coeff(int narg, char **arg)
if (!allocated) allocate();
if (narg != 3 + atom->ntypes) error->all(FLERR, "Incorrect args for pair coefficients");
if (narg != 3 + atom->ntypes)
error->all(FLERR, "Number of element to type mappings does not match number of atom types");
// read EAM Finnis-Sinclair file

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -31,5 +30,4 @@ using namespace LAMMPS_NS;
inherit everything else from PairEAMAlloy
------------------------------------------------------------------------- */
PairEAMAlloyOpt::PairEAMAlloyOpt(LAMMPS *lmp) :
PairEAM(lmp), PairEAMAlloy(lmp), PairEAMOpt(lmp) {}
PairEAMAlloyOpt::PairEAMAlloyOpt(LAMMPS *lmp) : PairEAM(lmp), PairEAMAlloy(lmp), PairEAMOpt(lmp) {}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -31,5 +30,4 @@ using namespace LAMMPS_NS;
inherit everything else from PairEAMFS
------------------------------------------------------------------------- */
PairEAMFSOpt::PairEAMFSOpt(LAMMPS *lmp) :
PairEAM(lmp), PairEAMFS(lmp), PairEAMOpt(lmp) {}
PairEAMFSOpt::PairEAMFSOpt(LAMMPS *lmp) : PairEAM(lmp), PairEAMFS(lmp), PairEAMOpt(lmp) {}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -21,15 +20,16 @@
------------------------------------------------------------------------- */
#include "pair_eam_opt.h"
#include <cmath>
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "neigh_list.h"
#include "memory.h"
#include "neigh_list.h"
#include "update.h"
#include <cmath>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
@ -44,24 +44,31 @@ void PairEAMOpt::compute(int eflag, int vflag)
if (evflag) {
if (eflag) {
if (force->newton_pair) return eval<1,1,1>();
else return eval<1,1,0>();
if (force->newton_pair)
return eval<1, 1, 1>();
else
return eval<1, 1, 0>();
} else {
if (force->newton_pair) return eval<1,0,1>();
else return eval<1,0,0>();
if (force->newton_pair)
return eval<1, 0, 1>();
else
return eval<1, 0, 0>();
}
} else {
if (force->newton_pair) return eval<0,0,1>();
else return eval<0,0,0>();
if (force->newton_pair)
return eval<0, 0, 1>();
else
return eval<0, 0, 0>();
}
}
/* ---------------------------------------------------------------------- */
template < int EVFLAG, int EFLAG, int NEWTON_PAIR >
void PairEAMOpt::eval()
template <int EVFLAG, int EFLAG, int NEWTON_PAIR> void PairEAMOpt::eval()
{
typedef struct { double x,y,z; } vec3_t;
typedef struct {
double x, y, z;
} vec3_t;
typedef struct {
double rhor0i, rhor1i, rhor2i, rhor3i;
@ -114,7 +121,8 @@ void PairEAMOpt::eval()
auto *_noalias fast_alpha =
(fast_alpha_t *) malloc((size_t) ntypes2 * (nr + 1) * sizeof(fast_alpha_t));
for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
for (i = 0; i < ntypes; i++)
for (j = 0; j < ntypes; j++) {
auto *_noalias tab = &fast_alpha[i * ntypes * nr + j * nr];
if (type2rhor[i + 1][j + 1] >= 0) {
for (int m = 1; m <= nr; m++) {
@ -137,7 +145,8 @@ void PairEAMOpt::eval()
auto *_noalias fast_gamma =
(fast_gamma_t *) malloc((size_t) ntypes2 * (nr + 1) * sizeof(fast_gamma_t));
for (i = 0; i < ntypes; i++) for (j = 0; j < ntypes; j++) {
for (i = 0; i < ntypes; i++)
for (j = 0; j < ntypes; j++) {
auto *_noalias tab = &fast_gamma[i * ntypes * nr + j * nr];
if (type2rhor[i + 1][j + 1] >= 0) {
for (int m = 1; m <= nr; m++) {
@ -173,7 +182,8 @@ void PairEAMOpt::eval()
if (NEWTON_PAIR) {
int m = nlocal + atom->nghost;
for (i = 0; i < m; i++) rho[i] = 0.0;
} else for (i = 0; i < nlocal; i++) rho[i] = 0.0;
} else
for (i = 0; i < nlocal; i++) rho[i] = 0.0;
// rho = density at each atom
// loop over neighbors of my atoms
@ -214,9 +224,7 @@ void PairEAMOpt::eval()
} else {
fast_alpha_t &a = tabeighti[jtype * nr + nr1];
tmprho += a.rhor3j + a.rhor2j + a.rhor1j + a.rhor0j;
if (NEWTON_PAIR || j < nlocal) {
rho[j] += a.rhor3i+a.rhor2i+a.rhor1i+a.rhor0i;
}
if (NEWTON_PAIR || j < nlocal) { rho[j] += a.rhor3i + a.rhor2i + a.rhor1i + a.rhor0i; }
}
}
}
@ -339,8 +347,7 @@ void PairEAMOpt::eval()
if (EFLAG) evdwl = scale_i[jtype] * phi;
if (EVFLAG) ev_tally(i,j,nlocal,NEWTON_PAIR,
evdwl,0.0,fpair,delx,dely,delz);
if (EVFLAG) ev_tally(i, j, nlocal, NEWTON_PAIR, evdwl, 0.0, fpair, delx, dely, delz);
}
}
@ -349,8 +356,10 @@ void PairEAMOpt::eval()
ff[i].z += tmpfz;
}
free(fast_alpha); fast_alpha = nullptr;
free(fast_gamma); fast_gamma = nullptr;
free(fast_alpha);
fast_alpha = nullptr;
free(fast_gamma);
fast_gamma = nullptr;
if (vflag_fdotr) virial_fdotr_compute();
}