diff --git a/doc/src/Errors_warnings.rst b/doc/src/Errors_warnings.rst index ad5323c6ad..4a944eeb18 100644 --- a/doc/src/Errors_warnings.rst +++ b/doc/src/Errors_warnings.rst @@ -195,6 +195,12 @@ Doc page with :doc:`ERROR messages ` *Fix SRD walls overlap but fix srd overlap not set* You likely want to set this in your input script. +* Fix bond/create is used multiple times or with fix bond/break - may not work as expected* + When using fix bond/create multiple times or in combination with + fix bond/break, the individual fix instances do not share information + about changes they made at the same time step and thus it may result + in unexpected behavior. + *Fix bond/swap will ignore defined angles* See the doc page for fix bond/swap for more info on this restriction. diff --git a/doc/txt/Errors_warnings.txt b/doc/txt/Errors_warnings.txt index 06474e1bb3..cb22b7ad0c 100644 --- a/doc/txt/Errors_warnings.txt +++ b/doc/txt/Errors_warnings.txt @@ -239,6 +239,13 @@ will be truncated to attempt to prevent the bond from blowing up. :dd You likely want to set this in your input script. :dd +{ Fix bond/create is used multiple times or with fix bond/break - may not work as expected} :dt + +When using fix bond/create multiple times or in combination with +fix bond/break, the individual fix instances do not share information +about changes they made at the same time step and thus it may result +in unexpected behavior. :dd + {Fix bond/swap will ignore defined angles} :dt See the doc page for fix bond/swap for more info on this diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index 2ff0e4126f..520abb9d32 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -33,7 +33,8 @@ using namespace FixConst; FixBondBreak::FixBondBreak(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - partner(NULL), finalpartner(NULL), distsq(NULL), probability(NULL), broken(NULL), copy(NULL), random(NULL) + partner(NULL), finalpartner(NULL), distsq(NULL), probability(NULL), + broken(NULL), copy(NULL), random(NULL) { if (narg < 6) error->all(FLERR,"Illegal fix bond/break command"); diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index 3f63a22d60..a7f955ad0b 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -18,6 +18,7 @@ #include "respa.h" #include "atom.h" #include "force.h" +#include "modify.h" #include "pair.h" #include "comm.h" #include "neighbor.h" @@ -216,6 +217,19 @@ void FixBondCreate::init() if (force->pair == NULL || cutsq > force->pair->cutsq[iatomtype][jatomtype]) error->all(FLERR,"Fix bond/create cutoff is longer than pairwise cutoff"); + // warn if more than one fix bond/create or also a fix bond/break + // because this fix stores per-atom state in bondcount + // if other fixes create/break bonds, this fix will not know about it + + int count = 0; + for (int i = 0; i < modify->nfix; i++) { + if (strcmp(modify->fix[i]->style,"bond/create") == 0) count++; + if (strcmp(modify->fix[i]->style,"bond/break") == 0) count++; + } + if (count > 1 && me == 0) + error->warning(FLERR,"Fix bond/create is used multiple times " + " or with fix bond/break - may not work as expected"); + // enable angle/dihedral/improper creation if atype/dtype/itype // option was used and a force field has been specified diff --git a/src/MC/fix_bond_create.h b/src/MC/fix_bond_create.h index 403b1ae340..1e4b9a11c1 100644 --- a/src/MC/fix_bond_create.h +++ b/src/MC/fix_bond_create.h @@ -170,4 +170,11 @@ See the read_data command for info on setting the "extra special per atom" header value to allow for additional special values to be stored. +W: Fix bond/create is used multiple times or with fix bond/break - may not work as expected + +When using fix bond/create multiple times or in combination with +fix bond/break, the individual fix instances do not share information +about changes they made at the same time step and thus it may result +in unexpected behavior. + */