From ed02c25cfc6ced2c8a2b50341c3875d0e9eaa969 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Thu, 22 Aug 2019 22:36:48 -0600 Subject: [PATCH 01/11] bond/react: bug in 'max_rxn' option fix one-line bug in 'max_rxn' option of bond/react --- src/USER-MISC/fix_bond_react.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index 05dc54c57e..852362018f 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -1209,7 +1209,7 @@ void FixBondReact::superimpose_algorithm() rxn_by_proc[j] = -1; // corresponds to ghostly int itemp = 0; for (int j = 0; j < nprocs; j++) - for (int k = 0; k < local_rxn_count[j]; k++) + for (int k = 0; k < local_rxncounts[j]; k++) rxn_by_proc[itemp++] = j; std::random_shuffle(&rxn_by_proc[0],&rxn_by_proc[delta_rxn]); for (int j = 0; j < nprocs; j++) From c981dd7cf4999ff9e1f01ed76c8c0375e8f93545 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sat, 31 Aug 2019 22:51:06 -0600 Subject: [PATCH 02/11] another one-liner: incorrect string assigment does not affect any current features --- src/USER-MISC/fix_bond_react.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index 852362018f..9c4d819f5d 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -207,7 +207,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : iarg++; - rxn_name[rxn] = arg[iarg++]; + strcpy(rxn_name[rxn],arg[iarg++]); int igroup = group->find(arg[iarg++]); if (igroup == -1) error->all(FLERR,"Could not find fix group ID"); From 86c21264b951b64713125f77767f1d74c19b87de Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sun, 1 Sep 2019 23:09:01 -0600 Subject: [PATCH 03/11] correct string assignment, take 2 --- src/USER-MISC/fix_bond_react.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index 9c4d819f5d..b38a3468c2 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -207,7 +207,9 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : iarg++; - strcpy(rxn_name[rxn],arg[iarg++]); + int n = strlen(arg[iarg]) + 1; + if (n > MAXLINE) error->all(FLERR,"Reaction name (react-ID) is too long (limit: 256 characters)"); + strncpy(rxn_name[rxn],arg[iarg++],n); int igroup = group->find(arg[iarg++]); if (igroup == -1) error->all(FLERR,"Could not find fix group ID"); From 50af20d194ee86de6f873ab48493d81c72d79389 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sun, 1 Sep 2019 23:31:31 -0600 Subject: [PATCH 04/11] bond/react: remember reaction counts allow restart files to restore cumutative reaction counts --- doc/src/fix_bond_react.txt | 9 ++++--- src/USER-MISC/fix_bond_react.cpp | 42 ++++++++++++++++++++++++++++++++ src/USER-MISC/fix_bond_react.h | 9 +++++++ 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/doc/src/fix_bond_react.txt b/doc/src/fix_bond_react.txt index 3f428e2103..5aff35787d 100644 --- a/doc/src/fix_bond_react.txt +++ b/doc/src/fix_bond_react.txt @@ -392,10 +392,11 @@ local command. [Restart, fix_modify, output, run start/stop, minimize info:] -No information about this fix is written to "binary restart -files"_restart.html, aside from internally-created per-atom -properties. None of the "fix_modify"_fix_modify.html options are -relevant to this fix. +Cumulative reaction counts for each reaction are written to "binary +restart files"_restart.html. These values are associated with the +reaction name (react-ID). Additionally, internally-created per-atom +properties are stored to allow for smooth restarts. None of the +"fix_modify"_fix_modify.html options are relevant to this fix. This fix computes one statistic for each {react} argument that it stores in a global vector, of length 'number of react arguments', that diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index b38a3468c2..07f009360a 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -87,6 +87,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : MPI_Comm_size(world,&nprocs); newton_bond = force->newton_bond; + restart_global = 1; attempted_rxn = 0; force_reneighbor = 1; next_reneighbor = -1; @@ -388,6 +389,10 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : id_fix3 = NULL; statted_id = NULL; custom_exclude_flag = 0; + + // used to store restart info + set = new Set[nreacts]; + memset(set,0,nreacts*sizeof(Set)); } /* ---------------------------------------------------------------------- */ @@ -471,6 +476,7 @@ FixBondReact::~FixBondReact() delete [] statted_id; delete [] guess_branch; delete [] pioneer_count; + delete [] set; if (group) { char **newarg; @@ -3100,6 +3106,42 @@ void FixBondReact::unpack_reverse_comm(int n, int *list, double *buf) } } +/* ---------------------------------------------------------------------- + write Set data to restart file +------------------------------------------------------------------------- */ + +void FixBondReact::write_restart(FILE *fp) +{ + set[0].nreacts = nreacts; + for (int i = 0; i < nreacts; i++) { + set[i].reaction_count_total = reaction_count_total[i]; + int n = strlen(rxn_name[i]) + 1; + strncpy(set[i].rxn_name,rxn_name[i],n); + } + + if (me == 0) { + int size = nreacts*sizeof(Set); + fwrite(&size,sizeof(int),1,fp); + fwrite(set,sizeof(Set),nreacts,fp); + } +} + +/* ---------------------------------------------------------------------- + use selected state info from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixBondReact::restart(char *buf) +{ + Set *set_restart = (Set *) buf; + for (int i = 0; i < set_restart[0].nreacts; i++) { + for (int j = 0; j < nreacts; j++) { + if (strcmp(set_restart[i].rxn_name,rxn_name[j]) == 0) { + reaction_count_total[j] = set_restart[i].reaction_count_total; + } + } + } +} + /* ---------------------------------------------------------------------- memory usage of local atom-based arrays ------------------------------------------------------------------------- */ diff --git a/src/USER-MISC/fix_bond_react.h b/src/USER-MISC/fix_bond_react.h index 1ac8d624a9..2be20cf8ec 100644 --- a/src/USER-MISC/fix_bond_react.h +++ b/src/USER-MISC/fix_bond_react.h @@ -170,6 +170,15 @@ class FixBondReact : public Fix { void unlimit_bond(); void limit_bond(int); void dedup_mega_gloves(int); //dedup global mega_glove + virtual void write_restart(FILE *); + virtual void restart(char *buf); + + struct Set { + int nreacts; + char rxn_name[256]; + int reaction_count_total; + }; + Set *set; // DEBUG From 49b5825e8da3fc7caea9fe9cc28a655664e101dc Mon Sep 17 00:00:00 2001 From: jrgissing Date: Thu, 5 Sep 2019 23:50:57 -0600 Subject: [PATCH 05/11] bond/react docs tweak: address a common mistake no atom of a small molecule should be specified as an edge atom --- doc/src/fix_bond_react.txt | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/doc/src/fix_bond_react.txt b/doc/src/fix_bond_react.txt index 5aff35787d..3fe3d8547e 100644 --- a/doc/src/fix_bond_react.txt +++ b/doc/src/fix_bond_react.txt @@ -186,19 +186,22 @@ reacting atoms. Some atoms in the pre-reacted template that are not reacting may have missing topology with respect to the simulation. For example, the -pre-reacted template may contain an atom that would connect to the -rest of a long polymer chain. These are referred to as edge atoms, and -are also specified in the map file. When the pre-reaction template -contains edge atoms, not all atoms, bonds, charges, etc. specified in -the reaction templates will be updated. Specifically, topology that -involves only atoms that are 'too near' to template edges will not be -updated. The definition of 'too near the edge' depends on which -interactions are defined in the simulation. If the simulation has -defined dihedrals, atoms within two bonds of edge atoms are considered -'too near the edge.' If the simulation defines angles, but not -dihedrals, atoms within one bond of edge atoms are considered 'too -near the edge.' If just bonds are defined, only edge atoms are -considered 'too near the edge.' +pre-reacted template may contain an atom that, in the simulation, is +currently connected to the rest of a long polymer chain. These are +referred to as edge atoms, and are also specified in the map file. +When the pre-reaction template contains edge atoms, not all atoms, +bonds, charges, etc. specified in the reaction templates will be +updated. Specifically, topology that involves only atoms that are 'too +near' to template edges will not be updated. The definition of 'too +near the edge' depends on which interactions are defined in the +simulation. If the simulation has defined dihedrals, atoms within two +bonds of edge atoms are considered 'too near the edge.' If the +simulation defines angles, but not dihedrals, atoms within one bond of +edge atoms are considered 'too near the edge.' If just bonds are +defined, only edge atoms are considered 'too near the edge.' + +NOTE: Small molecules, i.e. ones that have all their atoms contained +within the reaction templates, never have edge atoms. Note that some care must be taken when a building a molecule template for a given simulation. All atom types in the pre-reacted template From 0235b1a286209bd11fc9087357cfd88fc6269223 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Fri, 6 Sep 2019 00:18:24 -0600 Subject: [PATCH 06/11] bond/react: move MAXLINE to header --- src/USER-MISC/fix_bond_react.cpp | 1 - src/USER-MISC/fix_bond_react.h | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/USER-MISC/fix_bond_react.cpp b/src/USER-MISC/fix_bond_react.cpp index 07f009360a..6b61a7b84d 100644 --- a/src/USER-MISC/fix_bond_react.cpp +++ b/src/USER-MISC/fix_bond_react.cpp @@ -56,7 +56,6 @@ static const char cite_fix_bond_react[] = #define BIG 1.0e20 #define DELTA 16 -#define MAXLINE 256 #define MAXGUESS 20 // max # of guesses allowed by superimpose algorithm #define MAXCONARGS 5 // max # of arguments for any type of constraint diff --git a/src/USER-MISC/fix_bond_react.h b/src/USER-MISC/fix_bond_react.h index 2be20cf8ec..169409c3aa 100644 --- a/src/USER-MISC/fix_bond_react.h +++ b/src/USER-MISC/fix_bond_react.h @@ -26,6 +26,8 @@ FixStyle(bond/react,FixBondReact) #include "fix.h" +#define MAXLINE 256 + namespace LAMMPS_NS { class FixBondReact : public Fix { @@ -175,7 +177,7 @@ class FixBondReact : public Fix { struct Set { int nreacts; - char rxn_name[256]; + char rxn_name[MAXLINE]; int reaction_count_total; }; Set *set; From 2e0fcac74418d2c23093814dbb411bf5baf01c9a Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sun, 8 Sep 2019 21:11:24 -0600 Subject: [PATCH 07/11] bond/react: define MAXLINE take 2 --- src/USER-MISC/fix_bond_react.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/USER-MISC/fix_bond_react.h b/src/USER-MISC/fix_bond_react.h index 169409c3aa..e5452cb226 100644 --- a/src/USER-MISC/fix_bond_react.h +++ b/src/USER-MISC/fix_bond_react.h @@ -26,12 +26,13 @@ FixStyle(bond/react,FixBondReact) #include "fix.h" -#define MAXLINE 256 - namespace LAMMPS_NS { class FixBondReact : public Fix { public: + + enum {MAXLINE=256}; + FixBondReact(class LAMMPS *, int, char **); ~FixBondReact(); int setmask(); From 450f437d9f2f5f99ddaf56926d78cee9a1702489 Mon Sep 17 00:00:00 2001 From: jrgissing Date: Sun, 8 Sep 2019 22:59:59 -0600 Subject: [PATCH 08/11] bond/react:another edge atom clarification --- doc/src/fix_bond_react.txt | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/doc/src/fix_bond_react.txt b/doc/src/fix_bond_react.txt index 3fe3d8547e..ff5c14c1bd 100644 --- a/doc/src/fix_bond_react.txt +++ b/doc/src/fix_bond_react.txt @@ -188,17 +188,19 @@ Some atoms in the pre-reacted template that are not reacting may have missing topology with respect to the simulation. For example, the pre-reacted template may contain an atom that, in the simulation, is currently connected to the rest of a long polymer chain. These are -referred to as edge atoms, and are also specified in the map file. -When the pre-reaction template contains edge atoms, not all atoms, -bonds, charges, etc. specified in the reaction templates will be -updated. Specifically, topology that involves only atoms that are 'too -near' to template edges will not be updated. The definition of 'too -near the edge' depends on which interactions are defined in the -simulation. If the simulation has defined dihedrals, atoms within two -bonds of edge atoms are considered 'too near the edge.' If the -simulation defines angles, but not dihedrals, atoms within one bond of -edge atoms are considered 'too near the edge.' If just bonds are -defined, only edge atoms are considered 'too near the edge.' +referred to as edge atoms, and are also specified in the map file. All +pre-reaction template atoms should be linked to a bonding atom, via at +least one path that does not involve edge atoms. When the pre-reaction +template contains edge atoms, not all atoms, bonds, charges, etc. +specified in the reaction templates will be updated. Specifically, +topology that involves only atoms that are 'too near' to template +edges will not be updated. The definition of 'too near the edge' +depends on which interactions are defined in the simulation. If the +simulation has defined dihedrals, atoms within two bonds of edge atoms +are considered 'too near the edge.' If the simulation defines angles, +but not dihedrals, atoms within one bond of edge atoms are considered +'too near the edge.' If just bonds are defined, only edge atoms are +considered 'too near the edge.' NOTE: Small molecules, i.e. ones that have all their atoms contained within the reaction templates, never have edge atoms. From 95f59f5bf198e65aed91e93a0dbcd1f852354a9a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 19 Sep 2019 13:58:30 -0400 Subject: [PATCH 09/11] cosmetic changes --- doc/src/fix_bond_react.txt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/src/fix_bond_react.txt b/doc/src/fix_bond_react.txt index ff5c14c1bd..4f4506944f 100644 --- a/doc/src/fix_bond_react.txt +++ b/doc/src/fix_bond_react.txt @@ -412,8 +412,8 @@ These is 1 quantity for each react argument: (1) cumulative # of reactions occurred :ul -No parameter of this fix can be used with the {start/stop} keywords of -the "run"_run.html command. This fix is not invoked during "energy +No parameter of this fix can be used with the {start/stop} keywords +of the "run"_run.html command. This fix is not invoked during "energy minimization"_minimize.html. When fix bond/react is 'unfixed,' all internally-created groups are @@ -423,18 +423,20 @@ all other fixes that use any group created by fix bond/react. [Restrictions:] This fix is part of the USER-MISC package. It is only enabled if -LAMMPS was built with that package. See the "Build -package"_Build_package.html doc page for more info. +LAMMPS was built with that package. See the +"Build package"_Build_package.html doc page for more info. [Related commands:] -"fix bond/create"_fix_bond_create.html, "fix -bond/break"_fix_bond_break.html, "fix bond/swap"_fix_bond_swap.html, +"fix bond/create"_fix_bond_create.html, +"fix bond/break"_fix_bond_break.html, +"fix bond/swap"_fix_bond_swap.html, "dump local"_dump.html, "special_bonds"_special_bonds.html [Default:] -The option defaults are stabilization = no, prob = 1.0, stabilize_steps = 60, update_edges = none +The option defaults are stabilization = no, prob = 1.0, stabilize_steps = 60, +update_edges = none :line From 077647b4e2a58be582ac8c9da3cb75f688a71c05 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 19 Sep 2019 14:54:48 -0400 Subject: [PATCH 10/11] whitespace cleanup --- doc/src/fix_controller.txt | 1 - doc/src/fix_rigid_meso.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/src/fix_controller.txt b/doc/src/fix_controller.txt index 7458f1bcfa..45eb646b8e 100644 --- a/doc/src/fix_controller.txt +++ b/doc/src/fix_controller.txt @@ -31,7 +31,6 @@ cvar = name of control variable :l [Examples:] - fix 1 all controller 100 1.0 0.5 0.0 0.0 c_thermo_temp 1.5 tcontrol fix 1 all controller 100 0.2 0.5 0 100.0 v_pxxwall 1.01325 xwall fix 1 all controller 10000 0.2 0.5 0 2000 v_avpe -3.785 tcontrol :pre diff --git a/doc/src/fix_rigid_meso.txt b/doc/src/fix_rigid_meso.txt index 0819fdb2fb..a9c68b2c04 100644 --- a/doc/src/fix_rigid_meso.txt +++ b/doc/src/fix_rigid_meso.txt @@ -44,7 +44,7 @@ fix 1 rods rigid/meso molecule fix 1 spheres rigid/meso single force 1 off off on fix 1 particles rigid/meso molecule force 1*5 off off off force 6*10 off off on fix 2 spheres rigid/meso group 3 sphere1 sphere2 sphere3 torque * off off off :pre - + [Description:] Treat one or more sets of mesoscopic SPH/SDPD particles as independent From b7d9337da4e3e9370584eb7f360e7490c9a6786a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 19 Sep 2019 15:13:53 -0400 Subject: [PATCH 11/11] remove a tab --- doc/src/pair_granular.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/pair_granular.txt b/doc/src/pair_granular.txt index f16cd9fe0b..d46bea2343 100644 --- a/doc/src/pair_granular.txt +++ b/doc/src/pair_granular.txt @@ -790,4 +790,4 @@ alternative contact force models during inelastic collisions. Powder Technology, 233, 30-46. :link(WaltonPC) -[(Otis R. Walton)] Walton, O.R., Personal Communication +[(Otis R. Walton)] Walton, O.R., Personal Communication