From c1662f64cafb2d548b8c73b495d24750262b3f3e Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Wed, 22 Jan 2025 23:52:52 -0500 Subject: [PATCH 01/13] reaxff/species: post_integrate->end_of_step fix for incorrect molecule IDs (variable: clusterID) output by reaxff/species vector Co-Authored-By: mkanski <20713012+mkanski@users.noreply.github.com> Co-Authored-By: Navraj <88741755+navlalli@users.noreply.github.com> --- src/REAXFF/fix_reaxff_species.cpp | 6 +++--- src/REAXFF/fix_reaxff_species.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 4ef7799c24..834e830808 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -339,7 +339,7 @@ FixReaxFFSpecies::~FixReaxFFSpecies() int FixReaxFFSpecies::setmask() { int mask = 0; - mask |= POST_INTEGRATE; + mask |= END_OF_STEP; return mask; } @@ -356,7 +356,7 @@ void FixReaxFFSpecies::setup(int /*vflag*/) memory->destroy(Name); memory->create(Name, nutypes, "reaxff/species:Name"); - post_integrate(); + end_of_step(); } /* ---------------------------------------------------------------------- */ @@ -411,7 +411,7 @@ void FixReaxFFSpecies::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ -void FixReaxFFSpecies::post_integrate() +void FixReaxFFSpecies::end_of_step() { Output_ReaxFF_Bonds(update->ntimestep, fp); if (comm->me == 0) fflush(fp); diff --git a/src/REAXFF/fix_reaxff_species.h b/src/REAXFF/fix_reaxff_species.h index b9afc5466a..d283c1fff6 100644 --- a/src/REAXFF/fix_reaxff_species.h +++ b/src/REAXFF/fix_reaxff_species.h @@ -39,7 +39,7 @@ class FixReaxFFSpecies : public Fix { void init() override; void init_list(int, class NeighList *) override; void setup(int) override; - void post_integrate() override; + void end_of_step() override; double compute_vector(int) override; protected: From 3a44a03f046caa4ced448503d5472dc3d25d51d2 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 24 Jan 2025 23:29:10 -0500 Subject: [PATCH 02/13] migrate clusterID to fix property/atom --- src/REAXFF/fix_reaxff_species.cpp | 36 +++++++++++++++++-------------- src/REAXFF/fix_reaxff_species.h | 3 ++- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 834e830808..1ba3ae08e7 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -26,6 +26,7 @@ #include "domain.h" #include "error.h" #include "fix_ave_atom.h" +#include "fix_property_atom.h" #include "force.h" #include "group.h" #include "input.h" @@ -141,13 +142,6 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : } x0 = nullptr; - clusterID = nullptr; - - int ntmp = atom->nmax; - memory->create(x0, ntmp, "reaxff/species:x0"); - memory->create(clusterID, ntmp, "reaxff/species:clusterID"); - memset(clusterID, 0, sizeof(double) * ntmp); - vector_atom = clusterID; nmax = 0; setupflag = 0; @@ -304,7 +298,6 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : FixReaxFFSpecies::~FixReaxFFSpecies() { memory->destroy(BOCut); - memory->destroy(clusterID); memory->destroy(x0); memory->destroy(nd); @@ -330,6 +323,7 @@ FixReaxFFSpecies::~FixReaxFFSpecies() try { modify->delete_compute(fmt::format("SPECATOM_{}", id)); modify->delete_fix(fmt::format("SPECBOND_{}", id)); + modify->delete_fix(fmt::format("clusterID_{}", id)); } catch (std::exception &) { } } @@ -339,7 +333,7 @@ FixReaxFFSpecies::~FixReaxFFSpecies() int FixReaxFFSpecies::setmask() { int mask = 0; - mask |= END_OF_STEP; + mask |= POST_INTEGRATE; return mask; } @@ -356,7 +350,7 @@ void FixReaxFFSpecies::setup(int /*vflag*/) memory->destroy(Name); memory->create(Name, nutypes, "reaxff/species:Name"); - end_of_step(); + post_integrate(); } /* ---------------------------------------------------------------------- */ @@ -387,6 +381,20 @@ void FixReaxFFSpecies::init() 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 = dynamic_cast(modify->add_fix(fixcmd)); + + // create a fix to point to fix_property_atom for storing clusterID + fixcmd = fmt::format("clusterID_{} all property/atom d_clusterID ghost yes", id); + f_clusterID = dynamic_cast(modify->add_fix(fixcmd)); + + // per-atom property for clusterID + int flag,cols; + int index1 = atom->find_custom("clusterID",flag,cols); + clusterID = atom->dvector[index1]; + vector_atom = clusterID; + + int ntmp = atom->nmax; + memory->create(x0, ntmp, "reaxff/species:x0"); + setupflag = 1; } @@ -411,7 +419,7 @@ void FixReaxFFSpecies::init_list(int /*id*/, NeighList *ptr) /* ---------------------------------------------------------------------- */ -void FixReaxFFSpecies::end_of_step() +void FixReaxFFSpecies::post_integrate() { Output_ReaxFF_Bonds(update->ntimestep, fp); if (comm->me == 0) fflush(fp); @@ -439,11 +447,7 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) if (atom->nmax > nmax) { nmax = atom->nmax; memory->destroy(x0); - memory->destroy(clusterID); memory->create(x0, nmax, "reaxff/species:x0"); - memory->create(clusterID, nmax, "reaxff/species:clusterID"); - memset(clusterID, 0, sizeof(double) * nmax); - vector_atom = clusterID; } for (int i = 0; i < nmax; i++) { x0[i].x = x0[i].y = x0[i].z = 0.0; } @@ -1177,7 +1181,7 @@ double FixReaxFFSpecies::memory_usage() { double bytes; - bytes = 4 * nmax * sizeof(double); // clusterID + x0 + bytes = 3 * nmax * sizeof(double); // x0 return bytes; } diff --git a/src/REAXFF/fix_reaxff_species.h b/src/REAXFF/fix_reaxff_species.h index d283c1fff6..d378065a82 100644 --- a/src/REAXFF/fix_reaxff_species.h +++ b/src/REAXFF/fix_reaxff_species.h @@ -39,7 +39,7 @@ class FixReaxFFSpecies : public Fix { void init() override; void init_list(int, class NeighList *) override; void setup(int) override; - void end_of_step() override; + void post_integrate() override; double compute_vector(int) override; protected: @@ -88,6 +88,7 @@ class FixReaxFFSpecies : public Fix { class NeighList *list; class FixAveAtom *f_SPECBOND; + class FixPropertyAtom *f_clusterID; class PairReaxFF *reaxff; }; } // namespace LAMMPS_NS From 4bdc02ef3a627c94c37b8db55d442bd8c740eb50 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 24 Jan 2025 23:41:00 -0500 Subject: [PATCH 03/13] bugfix for when not using variable Nlimit for delete option --- src/REAXFF/fix_reaxff_species.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 1ba3ae08e7..138ce1dc19 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -399,7 +399,7 @@ void FixReaxFFSpecies::init() } // check for valid variable name for delete Nlimit keyword - if (delete_Nsteps > 0) { + if (delete_Nsteps > 0 && delete_Nlimit_varid > -1) { delete_Nlimit_varid = input->variable->find(delete_Nlimit_varname.c_str()); if (delete_Nlimit_varid < 0) error->all(FLERR, "Fix reaxff/species: Variable name {} does not exist", From cbd99d29cf1cd9776f15dcc5c5ec15965f4c5a7d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 14:17:20 -0500 Subject: [PATCH 04/13] update pointers in case changed at some point is 'clusterID' name for per-atom property too general? --- src/REAXFF/fix_reaxff_species.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 138ce1dc19..2e605339cb 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -432,6 +432,12 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) { int Nmole, Nspec; + // per-atom property for clusterID + int flag,cols; + int index1 = atom->find_custom("clusterID",flag,cols); + clusterID = atom->dvector[index1]; + vector_atom = clusterID; + // point to fix_ave_atom f_SPECBOND->end_of_step(); From 0a954b0129bf8eda52de769a015ab6d2850c39a4 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 14:44:18 -0500 Subject: [PATCH 05/13] per-atom mass bugfix for delete keyword --- src/REAXFF/fix_reaxff_species.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 2e605339cb..05ce474b73 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -947,6 +947,8 @@ void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec) int ndel, ndelone, count, count_tmp; int *Nameall; int *mask = atom->mask; + double *mass = atom->mass; + double *rmass = atom->rmass; double localmass, totalmass; std::string species_str; @@ -999,7 +1001,8 @@ void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec) Name[itype]++; count++; marklist[nmarklist++] = i; - localmass += atom->mass[atom->type[i]]; + if (rmass) localmass += rmass[i]; + else localmass += atom->mass[atom->type[i]]; } } From ceac416f9a8b59e1f81098dc883252a3c97422bb Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 15:16:26 -0500 Subject: [PATCH 06/13] average charge -> total charge in pos file --- src/REAXFF/fix_reaxff_species.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 05ce474b73..b81feab771 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -836,7 +836,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) int count, count_tmp, m, n, k; int *Nameall; int *mask = atom->mask; - double avq, avq_tmp, avx[3], avx_tmp, box[3], halfbox[3]; + double totq, totq_tmp, avx[3], avx_tmp, box[3], halfbox[3]; double **spec_atom = f_SPECBOND->array_atom; if (multipos) OpenPos(); @@ -863,7 +863,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) for (m = 1; m <= Nmole; m++) { count = 0; - avq = 0.0; + totq = 0.0; for (n = 0; n < 3; n++) avx[n] = 0.0; for (n = 0; n < nutypes; n++) Name[n] = 0; @@ -874,7 +874,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) itype = ele2uele[atom->type[i] - 1]; Name[itype]++; count++; - avq += spec_atom[i][0]; + totq += spec_atom[i][0]; if ((x0[i].x - spec_atom[i][1]) > halfbox[0]) spec_atom[i][1] += box[0]; if ((spec_atom[i][1] - x0[i].x) > halfbox[0]) spec_atom[i][1] -= box[0]; if ((x0[i].y - spec_atom[i][2]) > halfbox[1]) spec_atom[i][2] += box[1]; @@ -885,9 +885,9 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) } } - avq_tmp = 0.0; - MPI_Allreduce(&avq, &avq_tmp, 1, MPI_DOUBLE, MPI_SUM, world); - avq = avq_tmp; + totq_tmp = 0.0; + MPI_Allreduce(&totq, &totq_tmp, 1, MPI_DOUBLE, MPI_SUM, world); + totq = totq_tmp; for (n = 0; n < 3; n++) { avx_tmp = 0.0; @@ -910,7 +910,6 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) } } if (count > 0) { - avq /= count; for (k = 0; k < 3; k++) { avx[k] /= count; if (avx[k] >= domain->boxhi[k]) avx[k] -= box[k]; @@ -919,7 +918,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) avx[k] -= domain->boxlo[k]; avx[k] /= box[k]; } - fprintf(pos, "\t%.8f \t%.8f \t%.8f \t%.8f", avq, avx[0], avx[1], avx[2]); + fprintf(pos, "\t%.8f \t%.8f \t%.8f \t%.8f", totq, avx[0], avx[1], avx[2]); } fprintf(pos, "\n"); } From ccc790265d5b6d538e2680e1c60c9f9cee45c0e8 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 16:21:21 -0500 Subject: [PATCH 07/13] geometric center -> com --- src/REAXFF/fix_reaxff_species.cpp | 33 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index b81feab771..4d635cccf5 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -836,7 +836,8 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) int count, count_tmp, m, n, k; int *Nameall; int *mask = atom->mask; - double totq, totq_tmp, avx[3], avx_tmp, box[3], halfbox[3]; + double *rmass = atom->rmass; + double totq, totq_tmp, com[3], com_tmp, thism, totm, box[3], halfbox[3]; double **spec_atom = f_SPECBOND->array_atom; if (multipos) OpenPos(); @@ -864,7 +865,8 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) count = 0; totq = 0.0; - for (n = 0; n < 3; n++) avx[n] = 0.0; + totm = 0.0; + for (n = 0; n < 3; n++) com[n] = 0.0; for (n = 0; n < nutypes; n++) Name[n] = 0; for (i = 0; i < nlocal; i++) { @@ -881,7 +883,10 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) if ((spec_atom[i][2] - x0[i].y) > halfbox[1]) spec_atom[i][2] -= box[1]; if ((x0[i].z - spec_atom[i][3]) > halfbox[2]) spec_atom[i][3] += box[2]; if ((spec_atom[i][3] - x0[i].z) > halfbox[2]) spec_atom[i][3] -= box[2]; - for (n = 0; n < 3; n++) avx[n] += spec_atom[i][n + 1]; + if (rmass) thism = rmass[i]; + else thism = atom->mass[atom->type[i]]; + for (n = 0; n < 3; n++) com[n] += spec_atom[i][n+1]*thism; + totm += thism; } } @@ -890,14 +895,18 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) totq = totq_tmp; for (n = 0; n < 3; n++) { - avx_tmp = 0.0; - MPI_Reduce(&avx[n], &avx_tmp, 1, MPI_DOUBLE, MPI_SUM, 0, world); - avx[n] = avx_tmp; + com_tmp = 0.0; + MPI_Reduce(&com[n], &com_tmp, 1, MPI_DOUBLE, MPI_SUM, 0, world); + com[n] = com_tmp; } MPI_Reduce(&count, &count_tmp, 1, MPI_INT, MPI_SUM, 0, world); count = count_tmp; + com_tmp = 0.0; + MPI_Reduce(&totm, &com_tmp, 1, MPI_DOUBLE, MPI_SUM, 0, world); + totm = com_tmp; + MPI_Reduce(Name, Nameall, nutypes, MPI_INT, MPI_SUM, 0, world); for (n = 0; n < nutypes; n++) Name[n] = Nameall[n]; @@ -911,14 +920,14 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) } if (count > 0) { for (k = 0; k < 3; k++) { - avx[k] /= count; - if (avx[k] >= domain->boxhi[k]) avx[k] -= box[k]; - if (avx[k] < domain->boxlo[k]) avx[k] += box[k]; + com[k] /= totm; + if (com[k] >= domain->boxhi[k]) com[k] -= box[k]; + if (com[k] < domain->boxlo[k]) com[k] += box[k]; - avx[k] -= domain->boxlo[k]; - avx[k] /= box[k]; + com[k] -= domain->boxlo[k]; + com[k] /= box[k]; } - fprintf(pos, "\t%.8f \t%.8f \t%.8f \t%.8f", totq, avx[0], avx[1], avx[2]); + fprintf(pos, "\t%.8f \t%.8f \t%.8f \t%.8f", totq, com[0], com[1], com[2]); } fprintf(pos, "\n"); } From 8482d150e1073172ea46c9f0a2f4f6c1ae8710a6 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 16:22:12 -0500 Subject: [PATCH 08/13] update label --- src/REAXFF/fix_reaxff_species.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 4d635cccf5..adaa2c8c65 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -855,7 +855,7 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) update->ntimestep, Nmole, Nspec, domain->boxlo[0], domain->boxhi[0], domain->boxlo[1], domain->boxhi[1], domain->boxlo[2], domain->boxhi[2]); - fprintf(pos, "ID\tAtom_Count\tType\tAve_q\t\tCoM_x\t\tCoM_y\t\tCoM_z\n"); + fprintf(pos, "ID\tAtom_Count\tType\tTot_q\t\tCoM_x\t\tCoM_y\t\tCoM_z\n"); } Nameall = nullptr; From baf9a9b2d230a36888f486253a04ffa9e1fb69ed Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 23:14:09 -0500 Subject: [PATCH 09/13] need to update delete_Tcount before returning needs to be every timestep, regarding of Nfreq, etc. settings --- src/REAXFF/fix_reaxff_species.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index adaa2c8c65..f832b52c52 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -940,18 +940,24 @@ void FixReaxFFSpecies::WritePos(int Nmole, int Nspec) void FixReaxFFSpecies::DeleteSpecies(int Nmole, int Nspec) { - int ndeletions; + int i, ndeletions; int headroom = -1; if (delete_Nsteps > 0) { - if (delete_Tcount[delete_Nsteps - 1] == -1) return; + if (delete_Tcount[delete_Nsteps - 1] == -1) { + for (i = delete_Nsteps - 1; i > 0; i--) delete_Tcount[i] = delete_Tcount[i - 1]; + return; + } ndeletions = delete_Tcount[0] - delete_Tcount[delete_Nsteps - 1]; if (delete_Nlimit_varid > -1) delete_Nlimit = input->variable->compute_equal(delete_Nlimit_varid); headroom = MAX(0, delete_Nlimit - ndeletions); - if (headroom == 0) return; + if (headroom == 0) { + for (i = delete_Nsteps - 1; i > 0; i--) delete_Tcount[i] = delete_Tcount[i - 1]; + return; + } } - int i, j, m, n, itype, cid; + int j, m, n, itype, cid; int ndel, ndelone, count, count_tmp; int *Nameall; int *mask = atom->mask; From 464d9d82d65d0bbfc4b9fe3e575fbbd707d9f3d3 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 23:33:04 -0500 Subject: [PATCH 10/13] return correct clusterIDs even on first timestep --- src/REAXFF/fix_reaxff_species.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index f832b52c52..67beb32740 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -82,7 +82,7 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : peratom_freq = 1; compressed = 0; - nvalid = -1; + nvalid = update->ntimestep; ntypes = atom->ntypes; eletype.resize(ntypes); From 991b8c11fffac8e38adce39d052850f7277d8443 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 23:38:15 -0500 Subject: [PATCH 11/13] delete option: reset molecule ID to index from 1 --- src/REAXFF/fix_reaxff_species.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 67beb32740..51c2545409 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -474,7 +474,12 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) if (comm->me == 0) fflush(pos); } - if (delflag) DeleteSpecies(Nmole, Nspec); + if (delflag) { + DeleteSpecies(Nmole, Nspec); + + // reset molecule ID to index from 1 + SortMolecule(Nmole); + } nvalid += nfreq; } From 4c2241054852f1301c32bbd8152ed91d6262fdd1 Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sat, 25 Jan 2025 23:41:35 -0500 Subject: [PATCH 12/13] docs: molIDs range from 1 to # molecules --- doc/src/fix_reaxff_species.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/fix_reaxff_species.rst b/doc/src/fix_reaxff_species.rst index 107695f0f6..068d1de995 100644 --- a/doc/src/fix_reaxff_species.rst +++ b/doc/src/fix_reaxff_species.rst @@ -200,8 +200,8 @@ The 2 values in the global vector are as follows: The per-atom vector stores the molecule ID for each atom as identified by the fix. If an atom is not in a molecule, its ID will be 0. For atoms in the same molecule, the molecule ID for all of them -will be the same and will be equal to the smallest atom ID of -any atom in the molecule. +will be the same, and molecule IDs will range from 1 to the number +of molecules. No parameter of this fix can be used with the *start/stop* keywords of the :doc:`run ` command. From 8e2cb0f4c8bcf6f9489674411034ab26c9a7365c Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Sun, 26 Jan 2025 15:22:00 -0500 Subject: [PATCH 13/13] calculate molids on first timetstep of run but do not delete molecules --- src/REAXFF/fix_reaxff_species.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/REAXFF/fix_reaxff_species.cpp b/src/REAXFF/fix_reaxff_species.cpp index 51c2545409..d96f8214ec 100644 --- a/src/REAXFF/fix_reaxff_species.cpp +++ b/src/REAXFF/fix_reaxff_species.cpp @@ -82,7 +82,7 @@ FixReaxFFSpecies::FixReaxFFSpecies(LAMMPS *lmp, int narg, char **arg) : peratom_freq = 1; compressed = 0; - nvalid = update->ntimestep; + nvalid = -1; ntypes = atom->ntypes; eletype.resize(ntypes); @@ -366,9 +366,6 @@ void FixReaxFFSpecies::init() reaxff->fixspecies_flag = 1; - // reset next output timestep if not yet set or timestep has been reset - if (nvalid != update->ntimestep) nvalid = update->ntimestep + nfreq; - if (!setupflag) { // create a compute to store properties modify->add_compute(fmt::format("SPECATOM_{} all SPEC/ATOM q x y z vx vy vz abo01 abo02 " @@ -441,7 +438,7 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) // point to fix_ave_atom f_SPECBOND->end_of_step(); - if (ntimestep != nvalid) { + if (ntimestep != nvalid && nvalid != -1) { // push back delete_Tcount on every step if (delete_Nsteps > 0) for (int i = delete_Nsteps - 1; i > 0; i--) delete_Tcount[i] = delete_Tcount[i - 1]; @@ -474,14 +471,14 @@ void FixReaxFFSpecies::Output_ReaxFF_Bonds(bigint ntimestep, FILE * /*fp*/) if (comm->me == 0) fflush(pos); } - if (delflag) { + if (delflag && nvalid != -1) { DeleteSpecies(Nmole, Nspec); // reset molecule ID to index from 1 SortMolecule(Nmole); } - nvalid += nfreq; + nvalid = ntimestep + nfreq; } /* ---------------------------------------------------------------------- */