Merge pull request #2467 from jrgissing/bond/react-delete_atoms_bugfix

Bond/react: molecule keyword + bugfixes
This commit is contained in:
Richard Berger
2020-11-30 15:35:14 -05:00
committed by GitHub
15 changed files with 135 additions and 72 deletions

View File

@ -35,8 +35,8 @@ Syntax
* react-ID = user-assigned name for the reaction
* react-group-ID = only atoms in this group are considered for the reaction
* Nevery = attempt reaction every this many steps
* Rmin = bonding pair atoms must be separated by more than Rmin to initiate reaction (distance units)
* Rmax = bonding pair atoms must be separated by less than Rmax to initiate reaction (distance units)
* Rmin = initiator atoms must be separated by more than Rmin to initiate reaction (distance units)
* Rmax = initiator atoms must be separated by less than Rmax to initiate reaction (distance units)
* template-ID(pre-reacted) = ID of a molecule template containing pre-reaction topology
* template-ID(post-reacted) = ID of a molecule template containing post-reaction topology
* map_file = name of file specifying corresponding atom-IDs in the pre- and post-reacted templates
@ -55,6 +55,10 @@ Syntax
*custom_charges* value = *no* or *fragmentID*
no = update all atomic charges (default)
fragmentID = ID of molecule fragment whose charges are updated
*molecule* value = *off* or *inter* or *intra*
off = allow both inter- and intramolecular reactions (default)
inter = search for reactions between molecules with different IDs
intra = search for reactions within the same molecule
Examples
""""""""
@ -172,8 +176,8 @@ timesteps. *Nevery* can be specified with an equal-style
integer.
Three physical conditions must be met for a reaction to occur. First,
a bonding atom pair must be identified within the reaction distance
cutoffs. Second, the topology surrounding the bonding atom pair must
an initiator atom pair must be identified within the reaction distance
cutoffs. Second, the topology surrounding the initiator atom pair must
match the topology of the pre-reaction template. Only atom types and
bond connectivity are used to identify a valid reaction site (not bond
types, etc.). Finally, any reaction constraints listed in the map file
@ -181,10 +185,10 @@ types, etc.). Finally, any reaction constraints listed in the map file
reaction site is eligible to be modified to match the post-reaction
template.
A bonding atom pair will be identified if several conditions are met.
First, a pair of atoms I,J within the specified react-group-ID of type
itype and jtype must be separated by a distance between *Rmin* and
*Rmax*\ . *Rmin* and *Rmax* can be specified with equal-style
An initiator atom pair will be identified if several conditions are
met. First, a pair of atoms I,J within the specified react-group-ID of
type itype and jtype must be separated by a distance between *Rmin*
and *Rmax*\ . *Rmin* and *Rmax* can be specified with equal-style
:doc:`variables <variable>`. For example, these reaction cutoffs can
be a function of the reaction conversion using the following commands:
@ -194,20 +198,20 @@ be a function of the reaction conversion using the following commands:
fix myrxn all bond/react react myrxn1 all 1 0 v_rmax mol1 mol2 map_file.txt
variable rmax equal 3+f_myrxn[1]/100 # arbitrary function of reaction count
The following criteria are used if multiple candidate bonding atom
pairs are identified within the cutoff distance: 1) If the bonding
The following criteria are used if multiple candidate initiator atom
pairs are identified within the cutoff distance: 1) If the initiator
atoms in the pre-reaction template are not 1-2 neighbors (i.e. not
directly bonded) the closest potential partner is chosen. 2)
Otherwise, if the bonding atoms in the pre-reaction template are 1-2
Otherwise, if the initiator atoms in the pre-reaction template are 1-2
neighbors (i.e. directly bonded) the farthest potential partner is
chosen. 3) Then, if both an atom I and atom J have each other as their
bonding partners, these two atoms are identified as the bonding atom
pair of the reaction site. Note that it can be helpful to select
unique atom types for the bonding atoms: if a bonding atom pair is
identified, as described in the previous steps, but does not
initiator partners, these two atoms are identified as the initiator
atom pair of the reaction site. Note that it can be helpful to select
unique atom types for the initiator atoms: if an initiator atom pair
is identified, as described in the previous steps, but does not
correspond to the same pair specified in the pre-reaction template, an
otherwise eligible reaction could be prevented from occurring. Once
this unique bonding atom pair is identified for each reaction, there
this unique initiator atom pair is identified for each reaction, there
could be two or more reactions that involve the same atom on the same
timestep. If this is the case, only one such reaction is permitted to
occur. This reaction is chosen randomly from all potential reactions
@ -217,7 +221,7 @@ with user-specified probabilities.
The pre-reacted molecule template is specified by a molecule command.
This molecule template file contains a sample reaction site and its
surrounding topology. As described below, the bonding atom pairs of
surrounding topology. As described below, the initiator atom pairs of
the pre-reacted template are specified by atom ID in the map file. The
pre-reacted molecule template should contain as few atoms as possible
while still completely describing the topology of all atoms affected
@ -231,18 +235,18 @@ 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. 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.'
pre-reaction template atoms should be linked to an initiator 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::
@ -298,23 +302,23 @@ The optional keywords are 'edgeIDs', 'deleteIDs', 'chiralIDs' and
The body of the map file contains two mandatory sections and four
optional sections. The first mandatory section begins with the keyword
'BondingIDs' and lists the atom IDs of the bonding atom pair in the
pre-reacted molecule template. The second mandatory section begins
with the keyword 'Equivalences' and lists a one-to-one correspondence
between atom IDs of the pre- and post-reacted templates. The first
column is an atom ID of the pre-reacted molecule template, and the
second column is the corresponding atom ID of the post-reacted
molecule template. The first optional section begins with the keyword
'EdgeIDs' and lists the atom IDs of edge atoms in the pre-reacted
molecule template. The second optional section begins with the keyword
'DeleteIDs' and lists the atom IDs of pre-reaction template atoms to
delete. The third optional section begins with the keyword 'ChiralIDs'
lists the atom IDs of chiral atoms whose handedness should be
enforced. The fourth optional section begins with the keyword
'Constraints' and lists additional criteria that must be satisfied in
order for the reaction to occur. Currently, there are five types of
constraints available, as discussed below: 'distance', 'angle',
'dihedral', 'arrhenius', and 'rmsd'.
'InitiatorIDs' and lists the two atom IDs of the initiator atom pair
in the pre-reacted molecule template. The second mandatory section
begins with the keyword 'Equivalences' and lists a one-to-one
correspondence between atom IDs of the pre- and post-reacted
templates. The first column is an atom ID of the pre-reacted molecule
template, and the second column is the corresponding atom ID of the
post-reacted molecule template. The first optional section begins with
the keyword 'EdgeIDs' and lists the atom IDs of edge atoms in the
pre-reacted molecule template. The second optional section begins with
the keyword 'DeleteIDs' and lists the atom IDs of pre-reaction
template atoms to delete. The third optional section begins with the
keyword 'ChiralIDs' lists the atom IDs of chiral atoms whose
handedness should be enforced. The fourth optional section begins with
the keyword 'Constraints' and lists additional criteria that must be
satisfied in order for the reaction to occur. Currently, there are
five types of constraints available, as discussed below: 'distance',
'angle', 'dihedral', 'arrhenius', and 'rmsd'.
A sample map file is given below:
@ -327,7 +331,7 @@ A sample map file is given below:
7 equivalences
2 edgeIDs
BondingIDs
InitiatorIDs
3
5
@ -462,7 +466,7 @@ A few capabilities to note: 1) You may specify as many *react*
arguments as desired. For example, you could break down a complicated
reaction mechanism into several reaction steps, each defined by its
own *react* argument. 2) While typically a bond is formed or removed
between the bonding atom pairs specified in the pre-reacted molecule
between the initiator atoms specified in the pre-reacted molecule
template, this is not required. 3) By reversing the order of the pre-
and post- reacted molecule templates in another *react* argument, you
can allow for the possibility of one or more reverse reactions.
@ -491,12 +495,20 @@ situations, decreasing rather than increasing this parameter will
result in an increase in stability.
The *custom_charges* keyword can be used to specify which atoms'
atomic charges are updated. When the value is set to 'no,' all atomic
atomic charges are updated. When the value is set to 'no', all atomic
charges are updated to those specified by the post-reaction template
(default). Otherwise, the value should be the name of a molecule
fragment defined in the pre-reaction molecule template. In this case,
only the atomic charges of atoms in the molecule fragment are updated.
The *molecule* keyword can be used to force the reaction to be
intermolecular, intramolecular or either. When the value is set to
'off', molecule IDs are not considered when searching for reactions
(default). When the value is set to 'inter', the initiator atoms must
have different molecule IDs in order to be considered for the
reaction. When the value is set to 'intra', only initiator atoms with
the same molecule ID are considered for the reaction.
A few other considerations:
Many reactions result in one or more atoms that are considered
@ -558,7 +570,7 @@ These is 1 quantity for each react argument:
No parameter of this fix can be used with the *start/stop* keywords
of the :doc:`run <run>` command. This fix is not invoked during :doc:`energy minimization <minimize>`.
When fix bond/react is 'unfixed,' all internally-created groups are
When fix bond/react is 'unfixed', all internally-created groups are
deleted. Therefore, fix bond/react can only be unfixed after unfixing
all other fixes that use any group created by fix bond/react.
@ -581,10 +593,14 @@ Default
"""""""
The option defaults are stabilization = no, prob = 1.0, stabilize_steps = 60,
reset_mol_ids = yes, custom_charges = no
reset_mol_ids = yes, custom_charges = no, molecule = off
----------
.. _Gissinger:
**(Gissinger)** Gissinger, Jensen and Wise, Polymer, 128, 211 (2017).
.. _Gissinger2020:
**(Gissinger)** Gissinger, Jensen and Wise, Macromolecules (2020, in press).

View File

@ -279,7 +279,6 @@ Boltzman
BondAngle
BondBond
bondchk
BondingIDs
bondmax
bondtype
Bonet
@ -1329,6 +1328,7 @@ inhomogeneous
init
initialdelay
initializations
InitiatorIDs
initio
InP
inregion

View File

@ -3,7 +3,7 @@ this is a nominal superimpose file
2 edgeIDs
18 equivalences
BondingIDs
InitiatorIDs
10
1

View File

@ -3,7 +3,7 @@ this is a nominal superimpose file
2 edgeIDs
15 equivalences
BondingIDs
InitiatorIDs
4
12

View File

@ -3,7 +3,7 @@ this is a map file
1 edgeIDs
31 equivalences
BondingIDs
InitiatorIDs
15
1

View File

@ -3,7 +3,7 @@ this is a map file
1 edgeIDs
31 equivalences
BondingIDs
InitiatorIDs
4
25

View File

@ -3,7 +3,7 @@ this is a map file
2 edgeIDs
42 equivalences
BondingIDs
InitiatorIDs
15
32

View File

@ -3,7 +3,7 @@ this is a map file
2 edgeIDs
42 equivalences
BondingIDs
InitiatorIDs
35
24

View File

@ -3,7 +3,7 @@ this is a nominal superimpose file
2 edgeIDs
18 equivalences
BondingIDs
InitiatorIDs
10
1

View File

@ -3,7 +3,7 @@ this is a nominal superimpose file
2 edgeIDs
15 equivalences
BondingIDs
InitiatorIDs
4
12

View File

@ -3,7 +3,7 @@ this is a map file
0 edgeIDs
32 equivalences
BondingIDs
InitiatorIDs
4
30

View File

@ -8,7 +8,7 @@ EdgeIDs
17
34
BondingIDs
InitiatorIDs
14
38

View File

@ -7,7 +7,7 @@ EdgeIDs
30
BondingIDs
InitiatorIDs
14
34

View File

@ -85,6 +85,9 @@ enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD};
// keyword values that accept variables as input
enum{NEVERY,RMIN,RMAX,PROB};
// values for molecule_keyword
enum{OFF,INTER,INTRA};
/* ---------------------------------------------------------------------- */
FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
@ -202,6 +205,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
memory->create(limit_duration,nreacts,"bond/react:limit_duration");
memory->create(stabilize_steps_flag,nreacts,"bond/react:stabilize_steps_flag");
memory->create(custom_charges_fragid,nreacts,"bond/react:custom_charges_fragid");
memory->create(molecule_keyword,nreacts,"bond/react:molecule_keyword");
memory->create(constraints,1,MAXCONARGS,"bond/react:constraints");
memory->create(var_flag,NUMVARVALS,nreacts,"bond/react:var_flag");
memory->create(var_id,NUMVARVALS,nreacts,"bond/react:var_id");
@ -222,6 +226,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
max_rxn[i] = INT_MAX;
stabilize_steps_flag[i] = 0;
custom_charges_fragid[i] = -1;
molecule_keyword[i] = OFF;
// set default limit duration to 60 timesteps
limit_duration[i] = 60;
reaction_count[i] = 0;
@ -377,6 +382,14 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
"'custom_charges' keyword does not exist");
}
iarg += 2;
} else if (strcmp(arg[iarg],"molecule") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: "
"'molecule' has too few arguments");
if (strcmp(arg[iarg+1],"off") == 0) molecule_keyword[rxn] = OFF; //default
else if (strcmp(arg[iarg+1],"inter") == 0) molecule_keyword[rxn] = INTER;
else if (strcmp(arg[iarg+1],"intra") == 0) molecule_keyword[rxn] = INTRA;
else error->one(FLERR,"Bond/react: Illegal option for 'molecule' keyword");
iarg += 2;
} else error->all(FLERR,"Illegal fix bond/react command: unknown keyword");
}
}
@ -548,6 +561,7 @@ FixBondReact::~FixBondReact()
memory->destroy(var_id);
memory->destroy(stabilize_steps_flag);
memory->destroy(custom_charges_fragid);
memory->destroy(molecule_keyword);
memory->destroy(iatomtype);
memory->destroy(jatomtype);
@ -750,11 +764,12 @@ void FixBondReact::init()
if (strstr(update->integrate_style,"respa"))
nlevels_respa = ((Respa *) update->integrate)->nlevels;
// check cutoff for iatomtype,jatomtype
for (int i = 0; i < nreacts; i++) {
if (force->pair == nullptr || cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]])
error->all(FLERR,"Bond/react: Fix bond/react cutoff is longer than pairwise cutoff");
}
// check cutoff for iatomtype,jatomtype
for (int i = 0; i < nreacts; i++) {
if (closeneigh[i] == -1) // indicates will search for non-bonded bonding atoms
if (force->pair == nullptr || cutsq[i][1] > force->pair->cutsq[iatomtype[i]][jatomtype[i]])
error->all(FLERR,"Bond/react: Fix bond/react cutoff is longer than pairwise cutoff");
}
// need a half neighbor list, built every Nevery steps
int irequest = neighbor->request(this,instance_me);
@ -1053,6 +1068,11 @@ void FixBondReact::far_partner()
continue;
}
if (molecule_keyword[rxnID] == INTER)
if (atom->molecule[i] == atom->molecule[j]) continue;
else if (molecule_keyword[rxnID] == INTRA)
if (atom->molecule[i] != atom->molecule[j]) continue;
jtype = type[j];
possible = 0;
if (itype == iatomtype[rxnID] && jtype == jatomtype[rxnID]) {
@ -1132,6 +1152,11 @@ void FixBondReact::close_partner()
if (i_limit_tags[i2] != 0) continue;
if (itype != iatomtype[rxnID] || jtype != jatomtype[rxnID]) continue;
if (molecule_keyword[rxnID] == INTER)
if (atom->molecule[i1] == atom->molecule[i2]) continue;
else if (molecule_keyword[rxnID] == INTRA)
if (atom->molecule[i1] != atom->molecule[i2]) continue;
delx = x[i1][0] - x[i2][0];
dely = x[i1][1] - x[i2][1];
delz = x[i1][2] - x[i2][2];
@ -1203,7 +1228,7 @@ void FixBondReact::superimpose_algorithm()
memory->create(glove,max_natoms,2,"bond/react:glove");
memory->create(restore_pt,MAXGUESS,4,"bond/react:restore_pt");
memory->create(pioneers,max_natoms,"bond/react:pioneers");
memory->create(restore,max_natoms,MAXGUESS,"bond/react:restore");
memory->create(restore,max_natoms,MAXGUESS*4,"bond/react:restore");
memory->create(local_mega_glove,max_natoms+1,allncreate,"bond/react:local_mega_glove");
memory->create(ghostly_mega_glove,max_natoms+1,allncreate,"bond/react:ghostly_mega_glove");
@ -1304,7 +1329,9 @@ void FixBondReact::superimpose_algorithm()
// let's go ahead and catch the simplest of hangs
//if (hang_catch > onemol->natoms*4)
if (hang_catch > atom->nlocal*30) {
error->one(FLERR,"Bond/react: Excessive iteration of superimpose algorithm");
error->one(FLERR,"Bond/react: Excessive iteration of superimpose algorithm. "
"Please check that all pre-reaction template atoms are linked to an initiator atom, "
"via at least one path that does not involve edge atoms.");
}
}
}
@ -1718,6 +1745,17 @@ void FixBondReact::ring_check()
// ring_check can be made more efficient by re-introducing 'frozen' atoms
// 'frozen' atoms have been assigned and also are no longer pioneers
// double check the number of neighbors match for all non-edge atoms
// otherwise, atoms at 'end' of symmetric ring can behave like edge atoms
for (int i = 0; i < onemol->natoms; i++) {
if (edge[i][rxnID] == 0) {
if (onemol_nxspecial[i][0] != nxspecial[atom->map(glove[i][1])][0]) {
status = GUESSFAIL;
return;
}
}
}
for (int i = 0; i < onemol->natoms; i++) {
for (int j = 0; j < onemol_nxspecial[i][0]; j++) {
int ring_fail = 1;
@ -3131,6 +3169,12 @@ void FixBondReact::update_everything()
int Tdelta_imprp;
MPI_Allreduce(&delta_imprp,&Tdelta_imprp,1,MPI_INT,MPI_SUM,world);
atom->nimpropers += Tdelta_imprp;
if (ndel && (atom->map_style != Atom::MAP_NONE)) {
atom->nghost = 0;
atom->map_init();
atom->map_set();
}
}
/* ----------------------------------------------------------------------
@ -3184,7 +3228,9 @@ void FixBondReact::read(int myrxn)
int equivflag = 0, bondflag = 0;
while (strlen(keyword)) {
if (strcmp(keyword,"BondingIDs") == 0) {
if (strcmp(keyword,"InitiatorIDs") == 0 || strcmp(keyword,"BondingIDs") == 0) {
if (strcmp(keyword,"BondingIDs") == 0)
if (me == 0) error->warning(FLERR,"Bond/react: The BondingIDs section title has been deprecated. Please use InitiatorIDs instead.");
bondflag = 1;
readline(line);
sscanf(line,"%d",&ibonding[myrxn]);
@ -3213,7 +3259,7 @@ void FixBondReact::read(int myrxn)
// error check
if (bondflag == 0 || equivflag == 0)
error->all(FLERR,"Bond/react: Map file missing BondingIDs or Equivalences section\n");
error->all(FLERR,"Bond/react: Map file missing InitiatorIDs or Equivalences section\n");
}
void FixBondReact::EdgeIDs(char *line, int myrxn)

View File

@ -65,6 +65,7 @@ class FixBondReact : public Fix {
int custom_exclude_flag;
int *stabilize_steps_flag;
int *custom_charges_fragid;
int *molecule_keyword;
int nconstraints;
int narrhenius;
double **constraints;