Geometry optimization of a polymer

Dear all,

I am new to LAMMPS. I need to geometrically optimize a polymer. I read that I need a data file and an input file. Is there a clear example -that shows in details- what to include in these files and how to add the force fields? Any suggestion would be really appreciated.


Elie M

Dear Ellie

There are several molecule builders available on

There is also a newly-announced molecule builder here:

There is a tutorial for a very simple polymer here:

As for the force-field, it's not clear what kind of polymer you want
to simulate, and what type of simulation you are running. Some MD
programs like AMBER come with molecule-building scripts which will
"automagically" determine the force field parameters according to the
atom types. LAMMPS does not.

Perhaps Molecular Dynamics Studio (link above) can choose the
force-field parameters for you. (Hopefully Bruce will chime in.)

Currently you have to manually specify the parameters for every single
one of your bonded and non-bonded interactions in your model. (There
can be quite a few for an all-atom system.) Both moltemplate and
topotools will generate topology for you automatically, and both have
web page tutorials how to do this, but the force-field parameters have
to be specified by you.
(I could probably port some of AMBER's potentials over to moltemplate
format, but I can't guarantee that it would be correct. Somebody
would have to use it and tell me if I did it correctly, because I
don't use these force fields.)


Dear Andrew,

thanks very much. I will try to fiddle with these myself and try my best and see how it goes.


See the examples directories. There are several data files there,
e.g. in the peptide dir.


Your welcome!

The "peptide" example Steve mentioned is very useful for learning the
format of a lammps data file read by LAMMPS (I also liked the
"micelle" example.) Both "moltemplate" and "topotools" create data
files, but even if you use these tools, it helps to be familiar with
this data file format beforehand.

Feel free to post a question if you get stuck.


Hello again. I got stuck pretty fast with the executable; when I execute it on my PDB file, I get the error:

“/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: bc: command not found
/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: [: -eq: unary operator expected
/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: bc: command not found
/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: [: -eq: unary operator expected
/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: bc: command not found
/home/user/lammps-17Oct12/tools/moltemplate/src/ line 414: [: -eq: unary operator expected
Traceback (most recent call last):
File “/home/user/lammps-17Oct12/tools/moltemplate/src/”, line 26, in
from lttree import *
File “/home/user/lammps-17Oct12/tools/moltemplate/src/”, line 31, in
from ttree import *
File “/home/user/lammps-17Oct12/tools/moltemplate/src/”, line 79, in
from ordereddict import OrderedDict
ImportError: No module named ordereddict”

What is the cource of this error? I tried googling it but in vain.



That is strange. It seems like there is an installation problem and
also a shell script bug.

1) Type "python" into your shell. When I do this, it says:
Python 2.7.2+ (default, Jul 20 2012, 22:15:08)
[GCC 4.6.1] on linux2

Are you using a new enough version of python? (I think you need 2.6 or later.)

2) Try the "waterSPCE_from_PDBfile" example:
It is located in this directory

Go to this directory and type:

What happens?
Does it work?
If yes, then it should print out this:

Molecular Dynamics Studio allows the user to define templates for molecules. One molecule created per molecular machine part file (mmp).
The template is built by using the NanoEngineer-1 CAD software. The user should select the energy minimization button once the molecule
is completely drawn to remove any stress from the structure, which can play havoc later in simulation. You use the
force field chooser to select atom types for your atoms as you build the molecule. This is not an automatic process - yet. I think
several open source chemistry packages have a ring perception algorithm which can be added to NanoEngineer-1 and a rules-based
atom typer can be written for it. These are on my to-do list. The labor saving component here is the atom typing is done on the molecule
template and PACKMOL will replicate this data into an MD cell.

Once the molecule(s) is/are drawn you build an input file for PACKMOL. The molecule(s) you created templates for are now referenced
in the PACKMOL input file along with the number of each and the geometry of the MD cell you want to build. Read the PACKMOL papers
it is quite a fantastic approach to building an MD cell. All my modifications do is carry atom types through the process. PACKMOL gives
you a pseudo-random MD cell containing X number of molecules that are some tolerance distance between all atoms so repulsive forces
don’t affect your initial simulation. The MD cell is also an MMP file. You can edit it in NanoEngineer-1 and modify its structure.

Finally, running MSI2LMP converts from the MMP file structure to the LAMMPS geometry input file structure. This is where the force field parameters are applied. MSI2LMP is a work of art as well. It runs in linear time. The modifications I made were to handle the MMP file format
and I converted atom types from character strings to integer to preclude parsing issues of atom types in NanoEngineer-1. Atom types can be any combination of ASCII characters and therefore any parsing token could eventually be part of an atom type, which could break the parser code.
I shift the atomic number by 2 decimal places so carbon is 6 and becomes 600. Now every atom type is assigned a number from 0 to 99. This gives me 100 atom types per element.