Merge pull request #3477 from stanmoore1/kk_bugfixes

Fix several minor issues
This commit is contained in:
Axel Kohlmeyer
2022-10-10 17:27:47 -04:00
committed by GitHub
7 changed files with 195 additions and 168 deletions

View File

@ -54,8 +54,8 @@ FixReaxFFSpeciesKokkos::FixReaxFFSpeciesKokkos(LAMMPS *lmp, int narg, char **arg
void FixReaxFFSpeciesKokkos::init() void FixReaxFFSpeciesKokkos::init()
{ {
Pair* pair_kk = force->pair_match("^reax../kk",0); Pair* pair_kk = force->pair_match("^reax../kk",0);
if (pair_kk == nullptr) error->all(FLERR,"Cannot use fix reaxff/species/kk without " if (pair_kk == nullptr)
"pair_style reaxff/kk"); error->all(FLERR,"Cannot use fix reaxff/species/kk without pair_style reaxff/kk");
FixReaxFFSpecies::init(); FixReaxFFSpecies::init();
} }
@ -135,7 +135,7 @@ void FixReaxFFSpeciesKokkos::FindMolecule()
if (!anychange) break; if (!anychange) break;
MPI_Allreduce(&loop,&looptot,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&loop,&looptot,1,MPI_INT,MPI_SUM,world);
if (looptot >= 400*nprocs) break; if (looptot >= 400*comm->nprocs) break;
} }
} }

View File

@ -63,6 +63,7 @@ void NPairCopyKokkos<DeviceType>::copy_to_kokkos(NeighList *list)
list_kk->d_ilist = listcopy_kk->d_ilist; list_kk->d_ilist = listcopy_kk->d_ilist;
list_kk->d_numneigh = listcopy_kk->d_numneigh; list_kk->d_numneigh = listcopy_kk->d_numneigh;
list_kk->d_neighbors = listcopy_kk->d_neighbors; list_kk->d_neighbors = listcopy_kk->d_neighbors;
list_kk->maxneighs = listcopy_kk->maxneighs;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -123,6 +123,7 @@ void PairMEAMKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagPairMEAMOffsets>(0,inum_half),*this,n); Kokkos::parallel_reduce(Kokkos::RangePolicy<DeviceType, TagPairMEAMOffsets>(0,inum_half),*this,n);
meam_inst_kk->meam_dens_setup(atom->nmax, nall, n); meam_inst_kk->meam_dens_setup(atom->nmax, nall, n);
update_meam_views();
x = atomKK->k_x.view<DeviceType>(); x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
@ -324,35 +325,35 @@ KOKKOS_INLINE_FUNCTION
void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMPackForwardComm, const int &i) const { void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMPackForwardComm, const int &i) const {
int j = d_sendlist(iswap, i); int j = d_sendlist(iswap, i);
int m = i*38; int m = i*38;
v_buf[m++] = meam_inst_kk->d_rho0[j]; v_buf[m++] = d_rho0[j];
v_buf[m++] = meam_inst_kk->d_rho1[j]; v_buf[m++] = d_rho1[j];
v_buf[m++] = meam_inst_kk->d_rho2[j]; v_buf[m++] = d_rho2[j];
v_buf[m++] = meam_inst_kk->d_rho3[j]; v_buf[m++] = d_rho3[j];
v_buf[m++] = meam_inst_kk->d_frhop[j]; v_buf[m++] = d_frhop[j];
v_buf[m++] = meam_inst_kk->d_gamma[j]; v_buf[m++] = d_gamma[j];
v_buf[m++] = meam_inst_kk->d_dgamma1[j]; v_buf[m++] = d_dgamma1[j];
v_buf[m++] = meam_inst_kk->d_dgamma2[j]; v_buf[m++] = d_dgamma2[j];
v_buf[m++] = meam_inst_kk->d_dgamma3[j]; v_buf[m++] = d_dgamma3[j];
v_buf[m++] = meam_inst_kk->d_arho2b[j]; v_buf[m++] = d_arho2b[j];
v_buf[m++] = meam_inst_kk->d_arho1(j,0); v_buf[m++] = d_arho1(j,0);
v_buf[m++] = meam_inst_kk->d_arho1(j,1); v_buf[m++] = d_arho1(j,1);
v_buf[m++] = meam_inst_kk->d_arho1(j,2); v_buf[m++] = d_arho1(j,2);
v_buf[m++] = meam_inst_kk->d_arho2(j,0); v_buf[m++] = d_arho2(j,0);
v_buf[m++] = meam_inst_kk->d_arho2(j,1); v_buf[m++] = d_arho2(j,1);
v_buf[m++] = meam_inst_kk->d_arho2(j,2); v_buf[m++] = d_arho2(j,2);
v_buf[m++] = meam_inst_kk->d_arho2(j,3); v_buf[m++] = d_arho2(j,3);
v_buf[m++] = meam_inst_kk->d_arho2(j,4); v_buf[m++] = d_arho2(j,4);
v_buf[m++] = meam_inst_kk->d_arho2(j,5); v_buf[m++] = d_arho2(j,5);
for (int k = 0; k < 10; k++) v_buf[m++] = meam_inst_kk->d_arho3(j,k); for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3(j,k);
v_buf[m++] = meam_inst_kk->d_arho3b(j,0); v_buf[m++] = d_arho3b(j,0);
v_buf[m++] = meam_inst_kk->d_arho3b(j,1); v_buf[m++] = d_arho3b(j,1);
v_buf[m++] = meam_inst_kk->d_arho3b(j,2); v_buf[m++] = d_arho3b(j,2);
v_buf[m++] = meam_inst_kk->d_t_ave(j,0); v_buf[m++] = d_t_ave(j,0);
v_buf[m++] = meam_inst_kk->d_t_ave(j,1); v_buf[m++] = d_t_ave(j,1);
v_buf[m++] = meam_inst_kk->d_t_ave(j,2); v_buf[m++] = d_t_ave(j,2);
v_buf[m++] = meam_inst_kk->d_tsq_ave(j,0); v_buf[m++] = d_tsq_ave(j,0);
v_buf[m++] = meam_inst_kk->d_tsq_ave(j,1); v_buf[m++] = d_tsq_ave(j,1);
v_buf[m++] = meam_inst_kk->d_tsq_ave(j,2); v_buf[m++] = d_tsq_ave(j,2);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -372,35 +373,35 @@ KOKKOS_INLINE_FUNCTION
void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMUnpackForwardComm, const int &i) const{ void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMUnpackForwardComm, const int &i) const{
int m = i*38; int m = i*38;
meam_inst_kk->d_rho0[i+first] = v_buf[m++]; d_rho0[i+first] = v_buf[m++];
meam_inst_kk->d_rho1[i+first] = v_buf[m++]; d_rho1[i+first] = v_buf[m++];
meam_inst_kk->d_rho2[i+first] = v_buf[m++]; d_rho2[i+first] = v_buf[m++];
meam_inst_kk->d_rho3[i+first] = v_buf[m++]; d_rho3[i+first] = v_buf[m++];
meam_inst_kk->d_frhop[i+first] = v_buf[m++]; d_frhop[i+first] = v_buf[m++];
meam_inst_kk->d_gamma[i+first] = v_buf[m++]; d_gamma[i+first] = v_buf[m++];
meam_inst_kk->d_dgamma1[i+first] = v_buf[m++]; d_dgamma1[i+first] = v_buf[m++];
meam_inst_kk->d_dgamma2[i+first] = v_buf[m++]; d_dgamma2[i+first] = v_buf[m++];
meam_inst_kk->d_dgamma3[i+first] = v_buf[m++]; d_dgamma3[i+first] = v_buf[m++];
meam_inst_kk->d_arho2b[i+first] = v_buf[m++]; d_arho2b[i+first] = v_buf[m++];
meam_inst_kk->d_arho1(i+first,0) = v_buf[m++]; d_arho1(i+first,0) = v_buf[m++];
meam_inst_kk->d_arho1(i+first,1) = v_buf[m++]; d_arho1(i+first,1) = v_buf[m++];
meam_inst_kk->d_arho1(i+first,2) = v_buf[m++]; d_arho1(i+first,2) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,0) = v_buf[m++]; d_arho2(i+first,0) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,1) = v_buf[m++]; d_arho2(i+first,1) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,2) = v_buf[m++]; d_arho2(i+first,2) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,3) = v_buf[m++]; d_arho2(i+first,3) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,4) = v_buf[m++]; d_arho2(i+first,4) = v_buf[m++];
meam_inst_kk->d_arho2(i+first,5) = v_buf[m++]; d_arho2(i+first,5) = v_buf[m++];
for (int k = 0; k < 10; k++) meam_inst_kk->d_arho3(i+first,k) = v_buf[m++]; for (int k = 0; k < 10; k++) d_arho3(i+first,k) = v_buf[m++];
meam_inst_kk->d_arho3b(i+first,0) = v_buf[m++]; d_arho3b(i+first,0) = v_buf[m++];
meam_inst_kk->d_arho3b(i+first,1) = v_buf[m++]; d_arho3b(i+first,1) = v_buf[m++];
meam_inst_kk->d_arho3b(i+first,2) = v_buf[m++]; d_arho3b(i+first,2) = v_buf[m++];
meam_inst_kk->d_t_ave(i+first,0) = v_buf[m++]; d_t_ave(i+first,0) = v_buf[m++];
meam_inst_kk->d_t_ave(i+first,1) = v_buf[m++]; d_t_ave(i+first,1) = v_buf[m++];
meam_inst_kk->d_t_ave(i+first,2) = v_buf[m++]; d_t_ave(i+first,2) = v_buf[m++];
meam_inst_kk->d_tsq_ave(i+first,0) = v_buf[m++]; d_tsq_ave(i+first,0) = v_buf[m++];
meam_inst_kk->d_tsq_ave(i+first,1) = v_buf[m++]; d_tsq_ave(i+first,1) = v_buf[m++];
meam_inst_kk->d_tsq_ave(i+first,2) = v_buf[m++]; d_tsq_ave(i+first,2) = v_buf[m++];
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -555,27 +556,27 @@ KOKKOS_INLINE_FUNCTION
void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMPackReverseComm, const int &i) const { void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMPackReverseComm, const int &i) const {
int m = i*30; int m = i*30;
v_buf[m++] = meam_inst_kk->d_rho0[i+first]; v_buf[m++] = d_rho0[i+first];
v_buf[m++] = meam_inst_kk->d_arho2b[i+first]; v_buf[m++] = d_arho2b[i+first];
v_buf[m++] = meam_inst_kk->d_arho1(i+first,0); v_buf[m++] = d_arho1(i+first,0);
v_buf[m++] = meam_inst_kk->d_arho1(i+first,1); v_buf[m++] = d_arho1(i+first,1);
v_buf[m++] = meam_inst_kk->d_arho1(i+first,2); v_buf[m++] = d_arho1(i+first,2);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,0); v_buf[m++] = d_arho2(i+first,0);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,1); v_buf[m++] = d_arho2(i+first,1);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,2); v_buf[m++] = d_arho2(i+first,2);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,3); v_buf[m++] = d_arho2(i+first,3);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,4); v_buf[m++] = d_arho2(i+first,4);
v_buf[m++] = meam_inst_kk->d_arho2(i+first,5); v_buf[m++] = d_arho2(i+first,5);
for (int k = 0; k < 10; k++) v_buf[m++] = meam_inst_kk->d_arho3(i+first,k); for (int k = 0; k < 10; k++) v_buf[m++] = d_arho3(i+first,k);
v_buf[m++] = meam_inst_kk->d_arho3b(i+first,0); v_buf[m++] = d_arho3b(i+first,0);
v_buf[m++] = meam_inst_kk->d_arho3b(i+first,1); v_buf[m++] = d_arho3b(i+first,1);
v_buf[m++] = meam_inst_kk->d_arho3b(i+first,2); v_buf[m++] = d_arho3b(i+first,2);
v_buf[m++] = meam_inst_kk->d_t_ave(i+first,0); v_buf[m++] = d_t_ave(i+first,0);
v_buf[m++] = meam_inst_kk->d_t_ave(i+first,1); v_buf[m++] = d_t_ave(i+first,1);
v_buf[m++] = meam_inst_kk->d_t_ave(i+first,2); v_buf[m++] = d_t_ave(i+first,2);
v_buf[m++] = meam_inst_kk->d_tsq_ave(i+first,0); v_buf[m++] = d_tsq_ave(i+first,0);
v_buf[m++] = meam_inst_kk->d_tsq_ave(i+first,1); v_buf[m++] = d_tsq_ave(i+first,1);
v_buf[m++] = meam_inst_kk->d_tsq_ave(i+first,2); v_buf[m++] = d_tsq_ave(i+first,2);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -640,27 +641,27 @@ void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMUnpackReverseComm, const
int j = d_sendlist(iswap, i); int j = d_sendlist(iswap, i);
int m = i*30; int m = i*30;
meam_inst_kk->d_rho0[j] += v_buf[m++]; d_rho0[j] += v_buf[m++];
meam_inst_kk->d_arho2b[j] += v_buf[m++]; d_arho2b[j] += v_buf[m++];
meam_inst_kk->d_arho1(j,0) += v_buf[m++]; d_arho1(j,0) += v_buf[m++];
meam_inst_kk->d_arho1(j,1) += v_buf[m++]; d_arho1(j,1) += v_buf[m++];
meam_inst_kk->d_arho1(j,2) += v_buf[m++]; d_arho1(j,2) += v_buf[m++];
meam_inst_kk->d_arho2(j,0) += v_buf[m++]; d_arho2(j,0) += v_buf[m++];
meam_inst_kk->d_arho2(j,1) += v_buf[m++]; d_arho2(j,1) += v_buf[m++];
meam_inst_kk->d_arho2(j,2) += v_buf[m++]; d_arho2(j,2) += v_buf[m++];
meam_inst_kk->d_arho2(j,3) += v_buf[m++]; d_arho2(j,3) += v_buf[m++];
meam_inst_kk->d_arho2(j,4) += v_buf[m++]; d_arho2(j,4) += v_buf[m++];
meam_inst_kk->d_arho2(j,5) += v_buf[m++]; d_arho2(j,5) += v_buf[m++];
for (int k = 0; k < 10; k++) meam_inst_kk->d_arho3(j,k) += v_buf[m++]; for (int k = 0; k < 10; k++) d_arho3(j,k) += v_buf[m++];
meam_inst_kk->d_arho3b(j,0) += v_buf[m++]; d_arho3b(j,0) += v_buf[m++];
meam_inst_kk->d_arho3b(j,1) += v_buf[m++]; d_arho3b(j,1) += v_buf[m++];
meam_inst_kk->d_arho3b(j,2) += v_buf[m++]; d_arho3b(j,2) += v_buf[m++];
meam_inst_kk->d_t_ave(j,0) += v_buf[m++]; d_t_ave(j,0) += v_buf[m++];
meam_inst_kk->d_t_ave(j,1) += v_buf[m++]; d_t_ave(j,1) += v_buf[m++];
meam_inst_kk->d_t_ave(j,2) += v_buf[m++]; d_t_ave(j,2) += v_buf[m++];
meam_inst_kk->d_tsq_ave(j,0) += v_buf[m++]; d_tsq_ave(j,0) += v_buf[m++];
meam_inst_kk->d_tsq_ave(j,1) += v_buf[m++]; d_tsq_ave(j,1) += v_buf[m++];
meam_inst_kk->d_tsq_ave(j,2) += v_buf[m++]; d_tsq_ave(j,2) += v_buf[m++];
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -744,6 +745,29 @@ void PairMEAMKokkos<DeviceType>::operator()(TagPairMEAMOffsets, const int ii, in
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
template<class DeviceType>
void PairMEAMKokkos<DeviceType>::update_meam_views()
{
d_rho0 = meam_inst_kk->d_rho0;
d_rho1 = meam_inst_kk->d_rho1;
d_rho2 = meam_inst_kk->d_rho2;
d_rho3 = meam_inst_kk->d_rho3;
d_frhop = meam_inst_kk->d_frhop;
d_gamma = meam_inst_kk->d_gamma;
d_dgamma1 = meam_inst_kk->d_dgamma1;
d_dgamma2 = meam_inst_kk->d_dgamma2;
d_dgamma3 = meam_inst_kk->d_dgamma3;
d_arho1 = meam_inst_kk->d_arho1;
d_arho2 = meam_inst_kk->d_arho2;
d_arho3 = meam_inst_kk->d_arho3;
d_arho2b = meam_inst_kk->d_arho2b;
d_arho3b = meam_inst_kk->d_arho3b;
d_t_ave = meam_inst_kk->d_t_ave;
d_tsq_ave = meam_inst_kk->d_tsq_ave;
}
/* ---------------------------------------------------------------------- */
namespace LAMMPS_NS { namespace LAMMPS_NS {
template class PairMEAMKokkos<LMPDeviceType>; template class PairMEAMKokkos<LMPDeviceType>;
#ifdef KOKKOS_ENABLE_CUDA #ifdef KOKKOS_ENABLE_CUDA

View File

@ -114,6 +114,12 @@ class PairMEAMKokkos : public PairMEAM, public KokkosBase {
int iswap,first; int iswap,first;
int neighflag,nlocal,nall,eflag,vflag; int neighflag,nlocal,nall,eflag,vflag;
typename ArrayTypes<DeviceType>::t_ffloat_1d d_rho, d_rho0, d_rho1, d_rho2, d_rho3, d_frhop;
typename ArrayTypes<DeviceType>::t_ffloat_1d d_gamma, d_dgamma1, d_dgamma2, d_dgamma3, d_arho2b;
typename ArrayTypes<DeviceType>::t_ffloat_2d d_arho1, d_arho2, d_arho3, d_arho3b, d_t_ave, d_tsq_ave;
void update_meam_views();
friend void pair_virial_fdotr_compute<PairMEAMKokkos>(PairMEAMKokkos*); friend void pair_virial_fdotr_compute<PairMEAMKokkos>(PairMEAMKokkos*);
}; };

View File

@ -44,9 +44,13 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), Name(nullptr), MolName(nullptr), NMol(nullptr), nd(nullptr),
MolType(nullptr), molmap(nullptr), mark(nullptr), Mol2Spec(nullptr), clusterID(nullptr),
x0(nullptr), BOCut(nullptr), fp(nullptr), pos(nullptr), fdel(nullptr), ele(nullptr),
eletype(nullptr), filepos(nullptr), filedel(nullptr)
{ {
if (narg < 7) error->all(FLERR, "Illegal fix reaxff/species command"); if (narg < 7) utils::missing_cmd_args(FLERR, "fix reaxff/species", error);
force_reneighbor = 1; force_reneighbor = 1;
next_reneighbor = -1; next_reneighbor = -1;
@ -62,8 +66,6 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
compressed = 0; compressed = 0;
nvalid = -1; nvalid = -1;
MPI_Comm_rank(world, &me);
MPI_Comm_size(world, &nprocs);
ntypes = atom->ntypes; ntypes = atom->ntypes;
nevery = utils::inumeric(FLERR, arg[3], false, lmp); nevery = utils::inumeric(FLERR, arg[3], false, lmp);
@ -73,10 +75,11 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
comm_forward = 4; comm_forward = 4;
if (nevery <= 0 || nrepeat <= 0 || nfreq <= 0) if (nevery <= 0) error->all(FLERR, "Invalid fix reaxff/species nevery value {}", nevery);
error->all(FLERR, "Illegal fix reaxff/species command"); if (nrepeat <= 0) error->all(FLERR, "Invalid fix reaxff/species nrepeat value {}", nrepeat);
if (nfreq % nevery || nrepeat * nevery > nfreq) if (nfreq <= 0) error->all(FLERR, "Invalid fix reaxff/species nfreq value {}", nfreq);
error->all(FLERR, "Illegal fix reaxff/species command"); if ((nfreq % nevery) || (nrepeat * nevery > nfreq))
error->all(FLERR, "Incompatible fix reaxff/species nevery/nrepeat/nfreq settings");
// Neighbor lists must stay unchanged during averaging of bonds, // Neighbor lists must stay unchanged during averaging of bonds,
// but may be updated when no averaging is performed. // but may be updated when no averaging is performed.
@ -99,13 +102,13 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
rene_flag = 1; rene_flag = 1;
} }
if (me == 0 && rene_flag) if (comm->me == 0 && rene_flag)
error->warning(FLERR, error->warning(FLERR,
"Resetting reneighboring criteria to 'delay {} every {} check no' " "Resetting reneighboring criteria to 'delay {} every {} check no' "
"due to fix reaxff/species", "due to fix reaxff/species averaging of bond data",
neighbor->delay, neighbor->every); neighbor->delay, neighbor->every);
if (me == 0) { if (comm->me == 0) {
if (platform::has_compress_extension(arg[6])) { if (platform::has_compress_extension(arg[6])) {
fp = platform::compressed_write(arg[6]); fp = platform::compressed_write(arg[6]);
compressed = 1; compressed = 1;
@ -125,16 +128,6 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
memory->create(clusterID, ntmp, "reaxff/species:clusterID"); memory->create(clusterID, ntmp, "reaxff/species:clusterID");
vector_atom = clusterID; vector_atom = clusterID;
BOCut = nullptr;
Name = nullptr;
MolName = nullptr;
MolType = nullptr;
NMol = nullptr;
Mol2Spec = nullptr;
nd = nullptr;
molmap = nullptr;
mark = nullptr;
nmax = 0; nmax = 0;
setupflag = 0; setupflag = 0;
@ -159,16 +152,16 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
int iarg = 7; int iarg = 7;
while (iarg < narg) { while (iarg < narg) {
// set BO cutoff // set BO cutoff
if (strcmp(arg[iarg], "cutoff") == 0) { if (strcmp(arg[iarg], "cutoff") == 0) {
if (iarg + 4 > narg) error->all(FLERR, "Illegal fix reaxff/species command"); if (iarg + 4 > narg) utils::missing_cmd_args(FLERR, "fix reaxff/species cutoff", error);
itype = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); itype = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
jtype = utils::inumeric(FLERR, arg[iarg + 2], false, lmp); jtype = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
bo_cut = utils::numeric(FLERR, arg[iarg + 3], false, lmp); bo_cut = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
if (itype > ntypes || jtype > ntypes) error->all(FLERR, "Illegal fix reaxff/species command"); if ((itype <= 0) || (jtype <= 0) || (itype > ntypes) || (jtype > ntypes))
if (itype <= 0 || jtype <= 0) error->all(FLERR, "Illegal fix reaxff/species command"); error->all(FLERR, "Fix reaxff/species cutoff atom type(s) out of range");
if (bo_cut > 1.0 || bo_cut < 0.0) error->all(FLERR, "Illegal fix reaxff/species command"); if ((bo_cut > 1.0) || (bo_cut < 0.0))
error->all(FLERR, "Fix reaxff/species invalid cutoff value: {}", bo_cut);
BOCut[itype][jtype] = bo_cut; BOCut[itype][jtype] = bo_cut;
BOCut[jtype][itype] = bo_cut; BOCut[jtype][itype] = bo_cut;
@ -176,7 +169,8 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
// modify element type names // modify element type names
} else if (strcmp(arg[iarg], "element") == 0) { } else if (strcmp(arg[iarg], "element") == 0) {
if (iarg + ntypes + 1 > narg) error->all(FLERR, "Illegal fix reaxff/species command"); if (iarg + ntypes + 1 > narg)
utils::missing_cmd_args(FLERR, "fix reaxff/species element", error);
eletype = (char **) malloc(ntypes * sizeof(char *)); eletype = (char **) malloc(ntypes * sizeof(char *));
int len; int len;
@ -193,63 +187,66 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
delflag = 1; delflag = 1;
delete[] filedel; delete[] filedel;
filedel = utils::strdup(arg[iarg + 1]); filedel = utils::strdup(arg[iarg + 1]);
if (me == 0) { if (comm->me == 0) {
fdel = fopen(filedel, "w"); fdel = fopen(filedel, "w");
if (!fdel) if (!fdel)
error->one(FLERR, "Cannot open fix reaxff/species delete file {}: {}", filedel, error->one(FLERR, "Cannot open fix reaxff/species delete file {}: {}", filedel,
utils::getsyserror()); utils::getsyserror());
} }
del_opened = 1; del_opened = 1;
if (strcmp(arg[iarg + 2], "masslimit") == 0) { if (strcmp(arg[iarg + 2], "masslimit") == 0) {
if (iarg + 5 > narg) error->all(FLERR, "Illegal fix reaxff/species command"); if (iarg + 5 > narg) utils::missing_cmd_args(FLERR, "fix reaxff/species masslimit", error);
masslimitflag = 1; masslimitflag = 1;
massmin = atof(arg[iarg + 3]); massmin = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
massmax = atof(arg[iarg + 4]); massmax = utils::numeric(FLERR, arg[iarg + 4], false, lmp);
iarg += 5; iarg += 5;
} else if (strcmp(arg[iarg + 2], "specieslist") == 0) { } else if (strcmp(arg[iarg + 2], "specieslist") == 0) {
specieslistflag = 1; specieslistflag = 1;
ndelspec = atoi(arg[iarg + 3]); ndelspec = utils::inumeric(FLERR, arg[iarg + 3], false, lmp);
if (iarg + ndelspec + 4 > narg) error->all(FLERR, "Illegal fix reaxff/species command"); if (iarg + ndelspec + 4 > narg)
utils::missing_cmd_args(FLERR, "fix reaxff/species delete specieslist", error);
del_species.resize(ndelspec); del_species.resize(ndelspec);
for (int i = 0; i < ndelspec; i++) del_species[i] = arg[iarg + 4 + i]; for (int i = 0; i < ndelspec; i++) del_species[i] = arg[iarg + 4 + i];
if (me == 0) { if (comm->me == 0) {
fprintf(fdel, "Timestep"); fprintf(fdel, "Timestep");
for (i = 0; i < ndelspec; i++) fprintf(fdel, "\t%s", del_species[i].c_str()); for (i = 0; i < ndelspec; i++) fprintf(fdel, "\t%s", del_species[i].c_str());
fprintf(fdel, "\n"); fprintf(fdel, "\n");
fflush(fdel); fflush(fdel);
} }
iarg += ndelspec + 4; iarg += ndelspec + 4;
} else } else
error->all(FLERR, "Illegal fix reaxff/species command"); error->all(FLERR, "Unknown fix reaxff/species delete option: {}", arg[iarg]);
// position of molecules // position of molecules
} else if (strcmp(arg[iarg], "position") == 0) { } else if (strcmp(arg[iarg], "position") == 0) {
if (iarg + 3 > narg) error->all(FLERR, "Illegal fix reaxff/species command"); if (iarg + 3 > narg) utils::missing_cmd_args(FLERR, "fix reaxff/species position", error);
posflag = 1; posflag = 1;
posfreq = utils::inumeric(FLERR, arg[iarg + 1], false, lmp); posfreq = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
if (posfreq < nfreq || (posfreq % nfreq != 0)) if (posfreq < nfreq || (posfreq % nfreq != 0))
error->all(FLERR, "Illegal fix reaxff/species command"); error->all(FLERR, "Incompatible fix reaxff/species postion frequency {}", posfreq);
filepos = new char[255]; filepos = new char[255];
strcpy(filepos, arg[iarg + 2]); strcpy(filepos, arg[iarg + 2]);
if (strchr(filepos, '*')) { if (strchr(filepos, '*')) {
multipos = 1; multipos = 1;
} else { } else {
if (me == 0) { if (comm->me == 0) {
pos = fopen(filepos, "w"); pos = fopen(filepos, "w");
if (pos == nullptr) error->one(FLERR, "Cannot open fix reaxff/species position file"); if (pos == nullptr)
error->one(FLERR, "Cannot open fix reaxff/species position file: {}",
utils::getsyserror());
} }
singlepos_opened = 1; singlepos_opened = 1;
multipos = 0; multipos = 0;
} }
iarg += 3; iarg += 3;
} else } else
error->all(FLERR, "Illegal fix reaxff/species command"); error->all(FLERR, "Unknown fix reaxff/species keyword: {}", arg[iarg]);
} }
if (!eleflag) { if (!eleflag) {
@ -261,7 +258,7 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
} }
if (delflag && specieslistflag && masslimitflag) if (delflag && specieslistflag && masslimitflag)
error->all(FLERR, "Illegal fix reaxff/species command"); error->all(FLERR, "Incompatible combination fix reaxff/species command options");
vector_nmole = 0; vector_nmole = 0;
vector_nspec = 0; vector_nspec = 0;
@ -286,7 +283,7 @@ FixReaxFFSpecies::~FixReaxFFSpecies()
delete[] filepos; delete[] filepos;
delete[] filedel; delete[] filedel;
if (me == 0) { if (comm->me == 0) {
if (compressed) if (compressed)
platform::pclose(fp); platform::pclose(fp);
else else
@ -365,7 +362,7 @@ void FixReaxFFSpecies::init_list(int /*id*/, NeighList *ptr)
void FixReaxFFSpecies::post_integrate() void FixReaxFFSpecies::post_integrate()
{ {
Output_ReaxFF_Bonds(update->ntimestep, fp); Output_ReaxFF_Bonds(update->ntimestep, fp);
if (me == 0) fflush(fp); if (comm->me == 0) fflush(fp);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -402,11 +399,11 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/)
vector_nmole = Nmole; vector_nmole = Nmole;
vector_nspec = Nspec; vector_nspec = Nspec;
if (me == 0 && ntimestep >= 0) WriteFormulas(Nmole, Nspec); if (comm->me == 0 && ntimestep >= 0) WriteFormulas(Nmole, Nspec);
if (posflag && ((ntimestep) % posfreq == 0)) { if (posflag && ((ntimestep) % posfreq == 0)) {
WritePos(Nmole, Nspec); WritePos(Nmole, Nspec);
if (me == 0) fflush(pos); if (comm->me == 0) fflush(pos);
} }
if (delflag) DeleteSpecies(Nmole, Nspec); if (delflag) DeleteSpecies(Nmole, Nspec);
@ -498,7 +495,7 @@ void FixReaxFFSpecies::FindMolecule()
if (!anychange) break; if (!anychange) break;
MPI_Allreduce(&loop, &looptot, 1, MPI_INT, MPI_SUM, world); MPI_Allreduce(&loop, &looptot, 1, MPI_INT, MPI_SUM, world);
if (looptot >= 400 * nprocs) break; if (looptot >= 400 * comm->nprocs) break;
} }
} }
@ -529,12 +526,12 @@ void FixReaxFFSpecies::SortMolecule(int &Nmole)
return; return;
} }
if (idlo == ntotal) if (idlo == ntotal)
if (me == 0) if (comm->me == 0)
error->warning(FLERR, "Atom with cluster ID = maxmol included in fix reaxff/species group {}", error->warning(FLERR, "Atom with cluster ID = maxmol included in fix reaxff/species group {}",
group->names[igroup]); group->names[igroup]);
MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world); MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
if (flagall && me == 0) if (flagall && comm->me == 0)
error->warning(FLERR, "Atom with cluster ID = 0 included in fix reaxff/species group {}", error->warning(FLERR, "Atom with cluster ID = 0 included in fix reaxff/species group {}",
group->names[igroup]); group->names[igroup]);
@ -711,7 +708,7 @@ void FixReaxFFSpecies::WriteFormulas(int Nmole, int Nspec)
void FixReaxFFSpecies::OpenPos() void FixReaxFFSpecies::OpenPos()
{ {
if (me == 0) { if (comm->me == 0) {
auto filecurrent = utils::star_subst(filepos, update->ntimestep, padflag); auto filecurrent = utils::star_subst(filepos, update->ntimestep, padflag);
pos = fopen(filecurrent.c_str(), "w"); pos = fopen(filecurrent.c_str(), "w");
if (pos == nullptr) if (pos == nullptr)
@ -741,7 +738,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec)
for (int j = 0; j < 3; j++) halfbox[j] = box[j] / 2; for (int j = 0; j < 3; j++) halfbox[j] = box[j] / 2;
if (me == 0) { if (comm->me == 0) {
fmt::print(pos, fmt::print(pos,
"Timestep {} NMole {} NSpec {} xlo {:f} " "Timestep {} NMole {} NSpec {} xlo {:f} "
"xhi {:f} ylo {:f} yhi {:f} zlo {:f} zhi {:f}\n", "xhi {:f} ylo {:f} yhi {:f} zlo {:f} zhi {:f}\n",
@ -795,7 +792,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec)
MPI_Reduce(Name, Nameall, ntypes, MPI_INT, MPI_SUM, 0, world); MPI_Reduce(Name, Nameall, ntypes, MPI_INT, MPI_SUM, 0, world);
for (n = 0; n < ntypes; n++) Name[n] = Nameall[n]; for (n = 0; n < ntypes; n++) Name[n] = Nameall[n];
if (me == 0) { if (comm->me == 0) {
fprintf(pos, "%d\t%d\t", m, count); fprintf(pos, "%d\t%d\t", m, count);
for (n = 0; n < ntypes; n++) { for (n = 0; n < ntypes; n++) {
if (Name[n] != 0) { if (Name[n] != 0) {
@ -821,7 +818,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec)
fprintf(pos, "\n"); fprintf(pos, "\n");
} }
} }
if (me == 0 && !multipos) fprintf(pos, "#\n"); if (comm->me == 0 && !multipos) fprintf(pos, "#\n");
memory->destroy(Nameall); memory->destroy(Nameall);
} }
@ -934,12 +931,12 @@ void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec)
atom->natoms -= ndel; atom->natoms -= ndel;
if (me == 0) if (comm->me == 0)
MPI_Reduce(MPI_IN_PLACE, deletecount, ndelcomm, MPI_DOUBLE, MPI_SUM, 0, world); MPI_Reduce(MPI_IN_PLACE, deletecount, ndelcomm, MPI_DOUBLE, MPI_SUM, 0, world);
else else
MPI_Reduce(deletecount, deletecount, ndelcomm, MPI_DOUBLE, MPI_SUM, 0, world); MPI_Reduce(deletecount, deletecount, ndelcomm, MPI_DOUBLE, MPI_SUM, 0, world);
if (me == 0) { if (comm->me == 0) {
if (masslimitflag) { if (masslimitflag) {
int printflag = 0; int printflag = 0;
for (int m = 0; m < Nspec; m++) { for (int m = 0; m < Nspec; m++) {

View File

@ -44,7 +44,7 @@ class FixReaxFFSpecies : public Fix {
double compute_vector(int) override; double compute_vector(int) override;
protected: protected:
int me, nprocs, nmax, nlocal, ntypes, ntotal; int nmax, nlocal, ntypes, ntotal;
int nrepeat, nfreq, posfreq, compressed, ndelspec; int nrepeat, nfreq, posfreq, compressed, ndelspec;
int Nmoltype, vector_nmole, vector_nspec; int Nmoltype, vector_nmole, vector_nspec;
int *Name, *MolName, *NMol, *nd, *MolType, *molmap, *mark; int *Name, *MolName, *NMol, *nd, *MolType, *molmap, *mark;

View File

@ -1726,11 +1726,10 @@ void Input::pair_coeff()
{ {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"Pair_coeff command before simulation box is defined"); error->all(FLERR,"Pair_coeff command before simulation box is defined");
if (force->pair == nullptr) if (force->pair == nullptr) error->all(FLERR,"Pair_coeff command without a pair style");
error->all(FLERR,"Pair_coeff command before pair_style is defined"); if (narg < 2) utils::missing_cmd_args(FLERR,"pair_coeff", error);
if ((narg < 2) || (force->pair->one_coeff && ((strcmp(arg[0],"*") != 0) if (force->pair->one_coeff && ((strcmp(arg[0],"*") != 0) || (strcmp(arg[1],"*") != 0)))
|| (strcmp(arg[1],"*") != 0)))) error->all(FLERR,"Pair_coeff must start with * * for this pair style");
error->all(FLERR,"Incorrect args for pair coefficients");
char *newarg0 = utils::expand_type(FLERR, arg[0], Atom::ATOM, lmp); char *newarg0 = utils::expand_type(FLERR, arg[0], Atom::ATOM, lmp);
if (newarg0) arg[0] = newarg0; if (newarg0) arg[0] = newarg0;
@ -1740,9 +1739,9 @@ void Input::pair_coeff()
// if arg[1] < arg[0], and neither contain a wildcard, reorder // if arg[1] < arg[0], and neither contain a wildcard, reorder
int itype,jtype; int itype,jtype;
if (strchr(arg[0],'*') == nullptr && strchr(arg[1],'*') == nullptr) { if (utils::strmatch(arg[0],"^\\d+$") && utils::strmatch(arg[1],"^\\d+$")) {
itype = utils::numeric(FLERR,arg[0],false,lmp); itype = utils::inumeric(FLERR,arg[0],false,lmp);
jtype = utils::numeric(FLERR,arg[1],false,lmp); jtype = utils::inumeric(FLERR,arg[1],false,lmp);
if (jtype < itype) { if (jtype < itype) {
char *str = arg[0]; char *str = arg[0];
arg[0] = arg[1]; arg[0] = arg[1];