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); eam_alloy_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else else
eam_alloy_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom); eam_alloy_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
neighbor->build_topology();
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -282,12 +281,8 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg)
if (!allocated) allocate(); 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");
// ensure I,J args are * *
if (strcmp(arg[0], "*") != 0 || strcmp(arg[1], "*") != 0)
error->all(FLERR, "Incorrect args for pair coefficients");
// read EAM setfl file // 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); eam_fs_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else else
eam_fs_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom); eam_fs_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
neighbor->build_topology();
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -282,12 +281,8 @@ void PairEAMFSGPU::coeff(int narg, char **arg)
if (!allocated) allocate(); 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");
// ensure I,J args are * *
if (strcmp(arg[0], "*") != 0 || strcmp(arg[1], "*") != 0)
error->all(FLERR, "Incorrect args for pair coefficients");
// read EAM Finnis-Sinclair file // 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); eam_gpu_compute_force(nullptr, eflag, vflag, eflag_atom, vflag_atom);
else else
eam_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom); eam_gpu_compute_force(ilist, eflag, vflag, eflag_atom, vflag_atom);
if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) if (atom->molecular != Atom::ATOMIC && neighbor->ago == 0) neighbor->build_topology();
neighbor->build_topology();
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

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

View File

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

View File

@ -919,12 +919,7 @@ void PairEAMAlloyKokkos<DeviceType>::coeff(int narg, char **arg)
if (!allocated) allocate(); if (!allocated) allocate();
if (narg != 3 + atom->ntypes) 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");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
// read EAM setfl file // read EAM setfl file

View File

@ -920,12 +920,7 @@ void PairEAMFSKokkos<DeviceType>::coeff(int narg, char **arg)
if (!allocated) allocate(); if (!allocated) allocate();
if (narg != 3 + atom->ntypes) 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");
// ensure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
// read EAM Finnis-Sinclair file // read EAM Finnis-Sinclair file

View File

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

View File

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

View File

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

View File

@ -45,7 +45,8 @@ void PairEAMAlloyOMP::coeff(int narg, char **arg)
if (!allocated) allocate(); 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 // read EAM setfl file

View File

@ -45,7 +45,8 @@ void PairEAMFSOMP::coeff(int narg, char **arg)
if (!allocated) allocate(); 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 // read EAM Finnis-Sinclair file

View File

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

View File

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

View File

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