have internal fix/compute ids include the fix id for fix reaxff/species

this allows using the fix multiple times
also remove code and warning that checks for multiple fix instances
This commit is contained in:
Axel Kohlmeyer
2021-12-23 08:20:28 -05:00
parent 3748a14582
commit b2adb4df47

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -247,8 +246,8 @@ FixReaxFFSpecies::~FixReaxFFSpecies()
if (posflag && multipos_opened) fclose(pos);
}
modify->delete_compute("SPECATOM");
modify->delete_fix("SPECBOND");
modify->delete_compute(fmt::format("SPECATOM_{}",id));
modify->delete_fix(fmt::format("SPECBOND_{}",id));
}
/* ---------------------------------------------------------------------- */
@ -288,22 +287,16 @@ void FixReaxFFSpecies::init()
if (nvalid != update->ntimestep)
nvalid = update->ntimestep+nfreq;
// check if this fix has been called twice
int count = 0;
for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"reaxff/species") == 0) count++;
if (count > 1 && comm->me == 0)
error->warning(FLERR,"More than one fix reaxff/species");
if (!setupflag) {
// create a compute to store properties
modify->add_compute("SPECATOM all SPEC/ATOM q x y z vx vy vz abo01 abo02 abo03 abo04 "
"abo05 abo06 abo07 abo08 abo09 abo10 abo11 abo12 abo13 abo14 "
"abo15 abo16 abo17 abo18 abo19 abo20 abo21 abo22 abo23 abo24");
modify->add_compute(fmt::format("SPECATOM_{} all SPEC/ATOM q x y z vx vy vz abo01 abo02 "
"abo03 abo04 abo05 abo06 abo07 abo08 abo09 abo10 abo11 "
"abo12 abo13 abo14 abo15 abo16 abo17 abo18 abo19 abo20 "
"abo21 abo22 abo23 abo24",id));
// create a fix to point to fix_ave_atom for averaging stored properties
auto fixcmd = fmt::format("SPECBOND all ave/atom {} {} {}",nevery,nrepeat,nfreq);
for (int i = 1; i < 32; ++i) fixcmd += " c_SPECATOM[" + std::to_string(i) + "]";
auto fixcmd = fmt::format("SPECBOND_{} all ave/atom {} {} {}",id,nevery,nrepeat,nfreq);
for (int i = 1; i < 32; ++i) fixcmd += fmt::format(" c_SPECATOM_{}[{}]",id,i);
f_SPECBOND = (FixAveAtom *) modify->add_fix(fixcmd);
setupflag = 1;
}