[lammps-users] fix bond/swap for checking bond type

Dear all,

I am simulating a cross-linked system with swappable bonds. There are two types of linkages in the system: A-B-C and A-B-D-D-D. The group ID for swappable atoms defined in the fix bond/swap command is all B beads and the molecule IDs are set so that the swap occurs between different chains.

I would like to check for bond types associated with the swaps so that swap only occurs between B beads with different connectivities (A-B-C and A-B-D) and the same type swaps (A-B-C and A-B-C, A-B-D and A-B-D) are avoided. I included for loop in fix_bond_swap.cpp within FixBondSwap::post_integrate() function to check for the bond types associated with i and j as described below. I look at the neighbors of these beads and check if the bond types associated are type 2 and 6 (ie, B-C and B-D) and store them. The if condition then checks for the equality to continue to the next iteration.

Line 282 (fix_bond_swap.cpp):
// look at all bond partners of atoms i and j
// use num_bond for this, not special list, so also find bondtypes
// inext,jnext = bonded atoms
// inext,jnext must be on-processor (inext,jnext < nlocal)
// inext,jnext must be same dist from chain end (mol[inext] = mol[jnext])
// since swaps may occur between two ends of a single chain, insure
// the 4 atoms are unique (no duplicates): inext != jnext, inext != j
// all 4 old and new bonds must have length < cutoff

for (ibond = 0; ibond < num_bond[i]; ibond++) {
inext = atom->map(bond_atom[i][ibond]);
if (inext >= nlocal || inext < 0) continue;
ibondtype = bond_type[i][ibond];

for (jbond = 0; jbond < num_bond[j]; jbond++) {
jnext = atom->map(bond_atom[j][jbond]);
if (jnext >= nlocal || jnext < 0) continue;
jbondtype = bond_type[j][jbond];

for (ibondcpy = 0; ibondcpy < num_bond[i]; ibondcpy++) {
if (bond_type[i][ibondcpy] == 2 || bond_type[i][ibondcpy] == 6) {
ibondtypecpy = bond_type[i][ibondcpy];

for (jbondcpy = 0; jbondcpy < num_bond[j]; jbondcpy++) {
if (bond_type[j][jbondcpy] == 2 || bond_type[j][jbondcpy] == 6) {
jbondtypecpy = bond_type[j][jbondcpy];

if (ibondtypecpy == jbondtypecpy) continue;
if (molecule[inext] != molecule[jnext]) continue;
if (inext == jnext || inext == j) continue;
if (dist_rsq(i,inext) >= cutsq) continue;
if (dist_rsq(j,jnext) >= cutsq) continue;
if (dist_rsq(i,jnext) >= cutsq) continue;
if (dist_rsq(j,inext) >= cutsq) continue;

Upon performing test runs and checking changes in bond topology, I see that the swaps that do not satisfy the condition (swaps between same bond-types: arms A-B-C and A-B-C, A-B-D and A-B-D) do occur. I also checked for atom types associated with types C and D instead of bond types and it gives the same result. I have attached both the cpp files here for reference. I am not sure if there is another place where the change needs to be implemented, any inputs is greatly appreciated.

Thank you,


fix_bond_swap-2.cpp (25.1 KB)

fix_bond_swap.cpp (25.1 KB)

Fix bond/swap has several known limitations. I don’t know the code well enough to comment on your modifications.
You may want to look into using fix bond/react instead which supports much more complex operations and has many more features.