Well, there also is the issue that you have modified the code to work with dynamic groups.
Since you are using nevery=1 it should be OK, though.
The reason for the error message is that you have no atoms in your fix group. This is not anticipated by the existing code and thus will lead to a negative number of molecules and then trying to allocate a negative size array as a consequence, which ultimately causes the error.
The following patch should address this:
diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp
index 352dd33f62..0f5af77453 100644
--- a/src/REAXFF/fix_reaxff_species.cpp
+++ b/src/REAXFF/fix_reaxff_species.cpp
@@ -26,6 +26,7 @@
#include "error.h"
#include "fix_ave_atom.h"
#include "force.h"
+#include "group.h"
#include "memory.h"
#include "modify.h"
#include "neigh_list.h"
@@ -68,6 +69,7 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : Fix(lmp,
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
nrepeat = utils::inumeric(FLERR, arg[4], false, lmp);
global_freq = nfreq = utils::inumeric(FLERR, arg[5], false, lmp);
+ if (nrepeat == 1) dynamic_group_allow = 1;
comm_forward = 4;
@@ -394,9 +396,7 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/)
Nmole = Nspec = 0;
FindMolecule();
-
SortMolecule(Nmole);
-
FindSpecies(Nmole, Nspec);
vector_nmole = Nmole;
@@ -521,16 +521,21 @@ void FixReaxFFSpecies::SortMolecule(int &Nmole)
hi = MAX(hi, nint(clusterID[n]));
}
int flagall;
- MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
- if (flagall && me == 0)
- error->warning(FLERR, "Atom with cluster ID = 0 included in fix reaxff/species group");
MPI_Allreduce(&lo, &idlo, 1, MPI_INT, MPI_MIN, world);
MPI_Allreduce(&hi, &idhi, 1, MPI_INT, MPI_MAX, world);
+ int nlen = idhi - idlo + 1;
+ if (nlen <= 0) { // no atoms in group
+ Nmole = 0;
+ return;
+ }
if (idlo == ntotal)
if (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]);
+
+ MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world);
+ if (flagall && me == 0)
+ error->warning(FLERR, "Atom with cluster ID = 0 included in fix reaxff/species group {}", group->names[igroup]);
- int nlen = idhi - idlo + 1;
memory->create(molmap, nlen, "reaxff/species:molmap");
for (n = 0; n < nlen; n++) molmap[n] = 0;