Skip to content

Commit 173e796

Browse files
authored
Merge pull request lammps#4674 from jrgissing/bond/react-docs+bugfixes
Bond/react: docs+bugfixes
2 parents a6fb236 + 84b04d8 commit 173e796

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

doc/src/fix_bond_react.rst

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,15 @@ currently connected to the rest of a long polymer chain. These are
289289
referred to as edge atoms, and are also specified in the map file. All
290290
pre-reaction template atoms should be linked to an initiator atom, via
291291
at least one path that does not involve edge atoms. When the
292-
pre-reaction template contains edge atoms, not all atoms, bonds,
293-
charges, etc. specified in the reaction templates will be updated.
294-
Specifically, topology that involves only atoms that are "too near" to
295-
template edges will not be updated. The definition of "too near the
296-
edge" depends on which interactions are defined in the simulation. If
297-
the simulation has defined dihedrals, atoms within two bonds of edge
298-
atoms are considered "too near the edge." If the simulation defines
299-
angles, but not dihedrals, atoms within one bond of edge atoms are
300-
considered "too near the edge." If just bonds are defined, only edge
301-
atoms are considered "too near the edge."
292+
pre-reaction template contains edge atoms, not all atoms, bonds, etc.
293+
specified in the reaction templates will be updated. Specifically, topology
294+
that involves only atoms that are "too near" to template edges will not be
295+
updated. The definition of "too near the edge" depends on which
296+
interactions are defined in the simulation. If the simulation has defined
297+
dihedrals, atoms within two bonds of edge atoms are considered "too near
298+
the edge." If the simulation defines angles, but not dihedrals, atoms
299+
within one bond of edge atoms are considered "too near the edge." If just
300+
bonds are defined, only edge atoms are considered "too near the edge."
302301

303302
.. note::
304303

@@ -578,16 +577,17 @@ only one value, e.g. bond force. This value is returned by the
578577
fragment in the pre-reaction template. The fragment must contain
579578
exactly two atoms, corresponding to the atoms involved in the bond
580579
whose value should be calculated. An example of a constraint that uses
581-
the force experienced by a bond is provided below. The 'rxnsum' and
582-
'rxnave' functions operate over the atoms in a given reaction site,
583-
and have one mandatory argument and one optional argument. The
584-
mandatory argument is the identifier for an atom-style variable. The
585-
second, optional argument is the name of a molecule fragment in the
586-
pre-reaction template, and can be used to operate over a subset of
587-
atoms in the reaction site. The 'rxnsum' function sums the atom-style
588-
variable over the reaction site, while the 'rxnave' returns the
589-
average value. For example, a constraint on the total potential energy
590-
of atoms involved in the reaction can be imposed as follows:
580+
the force experienced by a bond is provided below. When using 'rxnbond',
581+
at least one atom in the fragment must be an initiator atom. The
582+
'rxnsum' and 'rxnave' functions operate over the atoms in a given
583+
reaction site, and have one mandatory argument and one optional
584+
argument. The mandatory argument is the identifier for an atom-style
585+
variable. The second, optional argument is the name of a molecule
586+
fragment in the pre-reaction template, and can be used to operate over a
587+
subset of atoms in the reaction site. The 'rxnsum' function sums the
588+
atom-style variable over the reaction site, while the 'rxnave' returns
589+
the average value. For example, a constraint on the total potential
590+
energy of atoms involved in the reaction can be imposed as follows:
591591

592592
.. code-block:: LAMMPS
593593
@@ -620,7 +620,7 @@ Arrhenius constraint that depends on the bond force of a specific bond:
620620
621621
# in Constraints section of map file
622622
623-
custom "exp(-(v_E_a-rxnbond(c_bondforce,bond1frag)*v_l0)/(2/3*rxnave(v_ke))) < random(0,1,12345)"
623+
custom "exp(-(v_E_a-rxnbond(c_bondforce,bond1frag)*v_l0)/(2/3*rxnave(v_ke))) > random(0,1,12345)"
624624
625625
By using an inequality and the 'random(x,y,z)' function, the left-hand
626626
side can be interpreted as the probability of the reaction occurring,

src/REACTION/fix_bond_react.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,10 +2446,12 @@ double FixBondReact::rxnfunction(const std::string& rxnfunc, const std::string&
24462446
for (int i = 0; i < onemol->natoms; i++) {
24472447
if (onemol->fragmentmask[ifrag][i]) {
24482448
aset.insert(glove[i][1]);
2449-
nsum++;
2449+
if (ibonding[i] == 1 || jbonding[i] == 1) nsum++;
24502450
}
24512451
}
2452-
if (nsum != 2) error->one(FLERR,"Bond/react: Molecule fragment of reaction special function 'rxnbond' "
2452+
if (nsum == 0) error->one(FLERR, "Bond/react: When using reaction special function 'rxnbond', "
2453+
"at least one atom in molecule fragment must be an initiator atom");
2454+
if (aset.size() != 2) error->one(FLERR,"Bond/react: Molecule fragment of reaction special function 'rxnbond' "
24532455
"must contain exactly two atoms");
24542456

24552457
if (cperbond->invoked_local != lmp->update->ntimestep)
@@ -4204,11 +4206,16 @@ void FixBondReact::Equivalences(char *line, int myrxn)
42044206
reverse_equiv[tmp1-1][1][myrxn] = tmp2;
42054207
}
42064208
// sanity check for one-to-one mapping for equivalences
4207-
for (int i = 0; i < twomol->natoms; i++)
4208-
for (int j = i+1; j < twomol->natoms; j++)
4209+
for (int i = 0; i < twomol->natoms; i++) {
4210+
if (create_atoms[i][myrxn] == 1) continue;
4211+
for (int j = i+1; j < twomol->natoms; j++) {
4212+
if (create_atoms[i][myrxn] == 1) continue;
42094213
if (equivalences[i][0][myrxn] == equivalences[j][0][myrxn] ||
4210-
equivalences[i][1][myrxn] == equivalences[j][1][myrxn])
4214+
equivalences[i][1][myrxn] == equivalences[j][1][myrxn]) {
42114215
error->one(FLERR,"Fix bond/react: Repeated atoms IDs in Equivalences section");
4216+
}
4217+
}
4218+
}
42124219
}
42134220

42144221
void FixBondReact::DeleteAtoms(char *line, int myrxn)

0 commit comments

Comments
 (0)