From 2aa326c8273c144d0bb0f8aaee27ac432db3dc7d Mon Sep 17 00:00:00 2001 From: Jacob Gissinger Date: Fri, 12 Feb 2021 10:56:48 -0500 Subject: [PATCH 1/3] bond/react: same-type initiators fix previously, if/when a reaction happens could depend on the order of listed initiator atoms, if they have the same type, in some cases --- src/USER-REACTION/fix_bond_react.cpp | 17 +++++++++++------ src/USER-REACTION/fix_bond_react.h | 0 2 files changed, 11 insertions(+), 6 deletions(-) mode change 100644 => 100755 src/USER-REACTION/fix_bond_react.cpp mode change 100644 => 100755 src/USER-REACTION/fix_bond_react.h diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp old mode 100644 new mode 100755 index 3098a1bd67..c4ffbea4fc --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -1031,23 +1031,28 @@ void FixBondReact::post_integrate() if (finalpartner[i] == 0) continue; j = atom->map(finalpartner[i]); - // if (j < 0 || tag[i] < tag[j]) { - if (tag[i] < tag[j]) { //atom->map(std::min(tag[i],tag[j])) <= nlocal && - if (nattempt[rxnID] == maxattempt) { + if (tag[i] < tag[j]) { + if (nattempt[rxnID] > maxattempt-2) { maxattempt += DELTA; - // third column of 'attempt': bond/react integer ID + // third dim of 'attempt': bond/react integer ID memory->grow(attempt,maxattempt,2,nreacts,"bond/react:attempt"); } // to ensure types remain in same order - // unnecessary now taken from reaction map file if (iatomtype[rxnID] == type[i]) { attempt[nattempt[rxnID]][0][rxnID] = tag[i]; attempt[nattempt[rxnID]][1][rxnID] = finalpartner[i]; + nattempt[rxnID]++; + // add another attempt if initiator atoms are same type + if (iatomtype[rxnID] == jatomtype[rxnID]) { + attempt[nattempt[rxnID]][0][rxnID] = finalpartner[i]; + attempt[nattempt[rxnID]][1][rxnID] = tag[i]; + nattempt[rxnID]++; + } } else { attempt[nattempt[rxnID]][0][rxnID] = finalpartner[i]; attempt[nattempt[rxnID]][1][rxnID] = tag[i]; + nattempt[rxnID]++; } - nattempt[rxnID]++; } } } diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h old mode 100644 new mode 100755 From a60853cca6c85e0dc6f5626c1d8d47f9b41c5a9d Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sat, 13 Feb 2021 14:39:28 -0500 Subject: [PATCH 2/3] memory leak introduced in recent 'create atoms' feature --- src/USER-REACTION/fix_bond_react.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp index c4ffbea4fc..1ec29efacd 100755 --- a/src/USER-REACTION/fix_bond_react.cpp +++ b/src/USER-REACTION/fix_bond_react.cpp @@ -2710,7 +2710,7 @@ update molecule IDs, charges, types, special lists and all topology void FixBondReact::update_everything() { - int nlocal; // must be defined after create_atoms + int nlocal = atom->nlocal; // must be redefined after create atoms int *type = atom->type; int **nspecial = atom->nspecial; tagint **special = atom->special; @@ -2722,6 +2722,9 @@ void FixBondReact::update_everything() // used when deleting atoms int ndel,ndelone; int *mark; + int nmark = nlocal; + memory->create(mark,nmark,"bond/react:mark"); + for (int i = 0; i < nmark; i++) mark[i] = 0; tagint *tag = atom->tag; AtomVec *avec = atom->avec; @@ -2783,8 +2786,11 @@ void FixBondReact::update_everything() // mark to-delete atoms nlocal = atom->nlocal; - mark = new int[nlocal]; - for (int i = 0; i < nlocal; i++) mark[i] = 0; + if (nlocal > nmark) { + memory->grow(mark,nlocal,"bond/react:mark"); + for (int i = nmark; i < nlocal; i++) mark[i] = 0; + nmark = nlocal; + } for (int i = 0; i < update_num_mega; i++) { rxnID = update_mega_glove[0][i]; onemol = atom->molecules[unreacted_mol[rxnID]]; @@ -3233,7 +3239,7 @@ void FixBondReact::update_everything() } } } - delete [] mark; + memory->destroy(mark); MPI_Allreduce(&ndelone,&ndel,1,MPI_INT,MPI_SUM,world); From 91f74cf9569f796dad61ec0e5eadb70c492ffac0 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sat, 13 Feb 2021 20:48:31 +0000 Subject: [PATCH 3/3] permissions! --- src/USER-REACTION/fix_bond_react.cpp | 0 src/USER-REACTION/fix_bond_react.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/USER-REACTION/fix_bond_react.cpp mode change 100755 => 100644 src/USER-REACTION/fix_bond_react.h diff --git a/src/USER-REACTION/fix_bond_react.cpp b/src/USER-REACTION/fix_bond_react.cpp old mode 100755 new mode 100644 diff --git a/src/USER-REACTION/fix_bond_react.h b/src/USER-REACTION/fix_bond_react.h old mode 100755 new mode 100644