Command for data bonds

Hi
If we have a polymer made up of 120 monomers with only one atom type, we can produce a data file for “data bonds” by this command:

write(“Data Bonds”) {
$bond:bb1 @bond:Monomer/bb $atom:monomers[0]/CA $atom:monomers[1]/CA
$bond:bb2 @bond:Monomer/bb $atom:monomers[1]/CA $atom:monomers[2]/CA
$bond:bb3 @bond:Monomer/bb $atom:monomers[2]/CA $atom:monomers[3]/CA
$bond:bb4 @bond:Monomer/bb $atom:monomers[3]/CA $atom:monomers[4]/CA
$bond:bb5 @bond:Monomer/bb $atom:monomers[4]/CA $atom:monomers[5]/CA
$bond:bb6 @bond:Monomer/bb $atom:monomers[5]/CA $atom:monomers[6]/CA
$bond:bb7 @bond:Monomer/bb $atom:monomers[6]/CA $atom:monomers[7]/CA
$bond:bb8 @bond:Monomer/bb $atom:monomers[7]/CA $atom:monomers[8]/CA
$bond:bb9 @bond:Monomer/bb $atom:monomers[8]/CA $atom:monomers[9]/CA
$bond:bb10 @bond:Monomer/bb $atom:monomers[9]/CA $atom:monomers[10]/CA
.
.
$bond:bb119 @bond:Monomer/bb $atom:monomers[10]/CA $atom:monomers[119]/CA
}

Is there any way to get the same from a single command ?
Thankyou
Andri Sharma
Ph.d student
IISER Mohali,India

p.s-I am totally new to this group as well as to LAMMPS. I read the manual but i am unable to find any way.

I’m thinking your code is Perl?

If you mean a simple bead-spring model, the tools directory in LAMMPS
has a chain.f program (Fortran) that builds chains one monomer at a time
using a reasonably smart algorithm. The same is available in Python
in the Pizza.py toolkit’s chain.py tool - see the LAMMPS webpage
for a link, or pizza.sandia.gov. Both create LAMMPS data files.
In either case you need to un-overlap the atoms by running
with pair_style soft initially.

Steve

Andri,

this is a question about moltemplate, and not really about LAMMPS.
you should contact andrew jewett (cc'd) about this, since he is the
author, maintainer, and main supporter of moltemplate.

axel.

I'm thinking your code is Perl?

nope, moltemplate. it cannot be perl because there are no semi-colons. :wink:

axel.

Sorry Andrew - I see [email protected]#! characters in code and I think Perl or cursing. Or both.

Steve

Sorry Andrew - I see [email protected]#! characters in code and I think Perl or cursing. Or both.

steve,

i suppose, you have never had to edit a sendmail configuration file, eh?
that one's syntax is occasionally referred to as "random modem noise".
reading perl is a pleasure in comparison :wink:

... and the comprehensive sendmail book (aka the bat book) has only
half as many pages as the LAMMPS manual:
http://shop.oreilly.com/product/9780596510299.do

there is still a lot of cursing involved, tho.

axel.

Axel,

Thankyou for the reference

Andri.

Hi
If we have a polymer made up of 120 monomers with only one atom type, we can produce a data file for "data bonds" by this command:
write("Data Bonds") {
    $bond:bb1 @bond:Monomer/bb $atom:monomers[0]/CA $atom:monomers[1]/CA
    $bond:bb2 @bond:Monomer/bb $atom:monomers[1]/CA $atom:monomers[2]/CA
    $bond:bb3 @bond:Monomer/bb $atom:monomers[2]/CA $atom:monomers[3]/CA
    $bond:bb4 @bond:Monomer/bb $atom:monomers[3]/CA $atom:monomers[4]/CA
    $bond:bb5 @bond:Monomer/bb $atom:monomers[4]/CA $atom:monomers[5]/CA
    $bond:bb6 @bond:Monomer/bb $atom:monomers[5]/CA $atom:monomers[6]/CA
    $bond:bb7 @bond:Monomer/bb $atom:monomers[6]/CA $atom:monomers[7]/CA
    $bond:bb8 @bond:Monomer/bb $atom:monomers[7]/CA $atom:monomers[8]/CA
    $bond:bb9 @bond:Monomer/bb $atom:monomers[8]/CA $atom:monomers[9]/CA
    $bond:bb10 @bond:Monomer/bb $atom:monomers[9]/CA $atom:monomers[10]/CA
.
.
    $bond:bb119 @bond:Monomer/bb $atom:monomers[10]/CA $atom:monomers[119]/CA
  }
Is there any way to get the same from a single command ?

My apologies for the long delay befor replying. (I've been traveling
and gmail was hard to access.)

I am deeply embarrassed to say that the answer is no. You can't.

I originally planned to add for-loops to moltemplate, but by that
point, I decided that moltemplate was getting too complicated.
Moltemplate resembles a half-assed programming language. (The
moltemplate code happens to be written in python, but the the user
interacts with it by creating LT files which do not contain python
code. These files contain moltemplate "code".) Rather than try to
add programming language features to the .LT format, I've been
thinking about creating a new version of moltemplate which will allow
users to describe their molecules using python commands. (That way,
python users could type "import moltemplate", write for-loops, compute
mathematical expressions, and have more control over the placement of
molecules and monomers. It should also make moltemplate faster and
use less memory.) This keeps getting pushed back, but it's something
I really want to do.

Until then, you have to generate this long list of bonds manually, as
you are doing. (For long polymers, I write a for-loop to generate
them, and then save them in a text file (.LT file). You can do this
in a couple lines of python or even bash.

------ genpoly_lt.py -----

Incidentally, one of the more complicated scripts I use to generate
lists of bonds is actually included with moltemplate. It's called
"genpoly_lt.py", and it's described here:

http://moltemplate.org/images/misc/polymers_follow_a_curve.png
https://github.com/jewettaij/moltemplate/blob/master/doc/utils/docs_genpoly_lt.txt

If you can generate the coordinates of a curve, then you can "wrap"
the polymer of your choice around this curve using this script. It
will also connect consecutive (or even non-consecutive) monomers
together with bonds, angles, dihedrals, and impropers so you don't
have to write this list yourself. You can also specify the desired
helicity (if applicable).

Hope this helps

Andrew

Steve Plimpton wrote:

Sorry Andrew - I see [email protected]#! characters in code and I think Perl or cursing. Or both.

:slight_smile:
This is syntactic sugar. The choice of and @ was arbitrary\. This syntax allows moltemplate to create arbitrary custom text files while reducing the number of keystrokes that the user has to type\. Anywhere in the file that has words beginning with or @ characters
will be substituted later with integers. (eg "bond:bb1\) The "" refer to atom-IDs or molecule-IDs (or even bond-IDs, although
LAMMPS discards them internally).
The "@" variables (typically) refer to atom-Types, bond-Types,
angle-Types, etc...
That way, if someone invents some new LAMMPS feature that requires a
new kind of text file format, then users will have no problem writing
a moltemplate file (.LT file) which generates this new file format.

Sorry it took me so long to reply to all these emails.