how to improve moltemplate performance

CC'd to the list. This conversation could be relevant to others
struggling to run moltemplate on large systems.

I have been using now for a while moltemplate as a way to generate
lammps data files...
The thing is moltemplate it is extremely slow for lots of small
molecules (e.g ~9 hours to generate the system for 500000 atoms of
benzenes molecules). Furthermore as far as I know moltemplate is not
parallelized either. Would the internal loops be easy to parallelize
using the multiprocessing package in Python for example? That was the
situation the last time I checked and I wanted to know if there are any
new improvements on performance in this regard?
Many thanks in advance,

Hi Eduardo

See the end of this email for my long term strategy to solve this problem.
(In this reply I added some new suggestions to the email I sent you earlier.)
For now, this is what I would do:

1) Run with the optional "-nocheck" argument. This
will improve performance by a factor of 1.5x up to 2x.

    (Only do this this *after* you have eliminated all of the syntax
errors from your files. I would not use the "-nocheck" when you are
initially building your first system. For what it's worth, even my
own moltemplate .LT files usually contain at least a couple errors
that would be difficult to find without "-nocheck". So I run
moltemplate on a small version of my system without "-nocheck" and get
rid of these errors. And then I increase the system size and run again on the full-sized system using "-nocheck")

2) Avoid using the "" script. (This is also
known as the "" script.) It slows
down moltemplate by a factor of about 2x or 3x. So avoid it if you
can. If you do that, then the data file will contain references to
many atom types (and bond, angle, dihedral, and improper types) which
you don't need in your simulation. This isn't a problem. Having
several hundred extra atom types present doesn't slow down the
simulation more than 1-2% (on CPUs at least), and behavior of the
simulation will be identical. But it makes it a little harder to use
certain 3rd party tools (like VMD) which expect the number of atom
types to be small (less than 10 for VMD). (See below for VMD usage

3) Try this only if you are desperate:
    Try consolidating your system into a few large objects, each with
many atoms, instead of many small molecules. I suggest this because I
am under the strong impression that the speed of moltemplate is
(mostly) determined by the number of objects that it has to create
(and much less so by the number of atoms in the system).
    To consolidate your system you could create a smaller version of
your system and use to create a LAMMPS data file and
input scripts for this small system (eg "",
"", ""...).
    Then you can run "" on these newly created files to
create one object (eg. "SmallSystem") describing the entire (small)
system. -name SmallSystem \ \

Then you can create a new "" file containing many copies of

------ example of "" file ------

import ""
subs = new SmallSystem
           [5].move(60.0, 0, 0)
           [5].move(0, 60.0, 0)
           [5].move(0, 0, 60.0)

write_once("Data Boundary") {
  0 300.0 xlo xhi
  0 300.0 ylo yhi
  0 300.0 zlo zhi