generating random polymers in Moltemplate with obstacles

I want to generate a polyethylene of desired density with periodic
boundary conditions with from a monomer unit containing 200 monomers. The
example you have given is for a monomer unit having only 50 units. Is it
possible to generate a box with bigger chains with random walks? If yes,
your help will be appreciated. Also, further I want to leave a space inside
this box to fill the empty space with a nano filler say CNT. Are both
structures possible in moltemplate?

Hi Rajesh

   This is just a short answer for now. Ill try to find time for a more
detailed answer later.

If you don't have the nanotube to worry about, then it's easy:

To generate the coordinates that define the curve that your polymer will
follow, take a look at the "ndmansfield" program, and the
"interpolate_coords.py" script, currently downloadable at:

Other Code

The ndmansfield program makes a jagged looking lattice polymer shape. The
optional interpolate_curve.py script can smooth that curve and rescale the
coordinates. These two programs make a curve for a self avoiding polymer
packed into a rectangle, but the curve lacks the molecular details.

To add those you would use the "genpoly_lt.py" script to "wrap" the CH2
subunits around the curve you created above, and connect them together with
bonds. You would use the same "ch2group.lt" file included with the
alkane_chain example that you mentioned. Documentation for that script is
here:

https://github.com/jewettaij/moltemplate/blob/master/doc/utils/docs_genpoly_lt.txt

If there's a nanotube, or some other object in the way, then I would try
packing the polymer into a rectangular region that avoids the nanotube. The
density of the polymer will be higher, but you can is minimization to
gradually relax the polymer so that it fills up the rest of the available
space.

It should not be too hard, but it will take a.little bit of effort.

Let me know if you have questions with any of these tools.

Andrew

Dear Andrew
Thank you for your guidance. As you said we can avoid intersection of cnt
and polymer, so, is there any option to specify the empty part inside the
main box so that no polymer chain can be in that region like in packmol?

Simulations of polymer melts are a headache. I'd eventually like to
create a nice tutorial. (I might want to submit a new pair_style to
make this process easier as well.) But for now, you'll have to settle
for a few hastily written emails that outline the process.

By far the easiest way to solve your problem is to generate an initial
polymer conformation which initially fills a rectangular volume which
is smaller than the desired volume and avoids overlapping with your
nanotube object. To do this you will have to pack the polymer tightly
at high density into this rectangular region, and then run a
simulation allowing the polymer to relax and fill the space around the
nanotube. The reason I suggest starting with the polymer packed in a
rectangular box is because there are several tools (namely
"ndmansfield", "interpolate_curve.py", and "genpoly_lt.py") which are
good at making polymers in rectangular boxes.

Alternatively, you could write short nested python for-loop to
generate points along a curve which wrap around the space occupied by
the nanotube like a spool of thread (for example). (I suppose you
could also try using "ndmansfield" to generate a curve which does not
fill a rectangular space. I attempted to explain how one might try to
do that at the end of this email, but I'm not positive it will work.)

Either way, the initial polymer conformation will probably require
some kind of minimization before it can be used in an ordinary
simulation. In my experience, the "minimize" command almost always
fails under these conditions. Instead I often have to run a series of
short LAMMPS Langevin simulations to allow the shape of the polymer to
relax and fill up the available volume. Initially the conformational
energy of the polymer will be very high, so I have to use very small
timesteps and fast damping rates (equivalent to a small "t_damp"
parameter) to suck away all that energy to keep my simulation from
exploding. Gradually I increase the timestep (and increase "t_damp").
To do this I use several iterations of "fix langevin", "run", and
"unfix", gradually increasing timestep and t_damp.
The commands you would need to use to run a Langevin simulation are
explained here:

Once the polymer fills up the available volume uniformly, it's still
not a very realistic representation of a polymer melt because it is
not very random. It will bear some similarity to the initial polymer
conformation. You can randomize the shape of the polymer by running
a simulation where you allow the polymer to pass through itself. This
will generate a polymer shape containing many overlaps. You will have
to very gradually turn on repulsion between the atoms in the polymer
back on to eliminate these overlaps. I do this by running the
simulation for a short time, using the pair_coeff command to increase
the repulsion between atoms, and iterating. After enough iterations,
the atoms no longer overlap, and you should have a random polymer
which occupies the volume of interest. The liquid-crystalline-like
polymer conformations shown here were generated using this procedure:

To do this, I recommend using one of these pair_styles:

To keep the forces between atoms as realistic as possible during this
process, it may be advantageous to use "soft" forces (at small
distances) which resemble Lennard-Jones forces at long distances. To
do that, you could try using "pair_style lj/charmm/coul/charmm/inter".
The only drawback to using this pair style is that it is complicated,
it's not GPU-accelerated, and it's not official LAMMPS code. The
source code and documentation for this pair_style are here:
http://moltemplate.org/lammps_code/index.html
http://moltemplate.org/lammps_code/pair_lj_charmm_coul_charmm_inter.html
(If you decide to use that pair style, then scroll down to the place
where it discusses the "rsoftcore" arguments.)

I hope this gets you started.

Andrew

---- using ndmansfield to generate curves which fill a non-rectangular space ---

   I don't know if this works. Even if it does, it's probably easier
to use one of the methods above. You should probably stop reading
here.

The "ndmansfield" program by default generates a random jagged
non-overlapping curve that fills a rectangular box. You can change
the shape and size of the box (of size Nx,Ny,Nz, which are positive
integers), but it must still be a box. The coordinates of the curve
that ndmansfield generates are all positive integers, and you must
rescale them and smooth the curve before they can be converted into a
polymer (using "genpoly_lt.py"). One way to rescale and smooth this
jagged curve is to use the "interpolate_curve.py" script (currently
available at "http://www.moltemplate.org/other/"\)

However, in principle, you don't have to completely fill that box. I
have never tried this, but I think If you want to use a different
geometry, then you can create a 3-column text file ("init_crd.raw")
containing a non-overlapping path which only occupies only some of the
sites on the lattice, (in your case the ones which don't overlap
occupied by the nanotube).
Each line of this file should contain 3 integers (in the range 1...Nx,
1...Ny, 1...Nz).
Once you have this curve you can run ndmansfield with these additional
command line arguments:

-startcrd init_crd.raw

This will generate a new random curve which occupies the same sites on
the lattice as the original curve. You will have to play with the
-tsave and -tstop arguments to generate a random curve. (You can
usually tell if it's random by looking at the numbers printed to the
terminal as its running.)

I fear the program might get confused if the polymer length is less
than the number of sites in the rectangular box (Nx*Ny*Nz). If that
happens, download the source code for ndmansfield, and edit the
"ndmansfield.cpp" file and set the poly_length variable to the desired
number of lattice sites that you want your polymer to occupy).

Again, I've never tried this. It should work, but you may run into
some problems which you will have to fix yourself, I'm afraid. (If
so, feel free to send me the changes you made, or do a git pull
request and I'll update ndmansfield.)

Cheers