Make a bond between two beads and Build infinite mesomolecule along a cell direction

Jian-Jie Liang posted some info on how to make an infinite chain for an atomistic system with periodic boundary conditions. A similar query came up for systems with mesomolecules.

At least in the past one had to use a script to make a bond between two beads. This idea is picked up in the attached example to make an infinite mesomolecule.

The idea is the following:

  1. Put your finite mesomolecule into a box with periodic boundary conditions so that the chain goes over a cell boundary (Mesomolecule.xsd).
  2. Measure the distance between head and tail where we want to make a bond (there must be no further measured distance in the cell). They should be in the same cell.
  3. Run the script make_bond_for_distance.pl from the attached example.

The resulting structure is quite artificial according to my opinion and has to undergo further relaxation.