CMAP support in moltemplate

Dear Neda

    I just added a patch to moltemplate to enable it to understand
CMAP interactions. The "" data-file converter script
understands these interactions as well. This means you should be able
to convert your origial data file into moltemplate format with and run on the resulting .LT file. (Note:
This has not been tested carefully. Let me know if you run into any

    Because I'm lazy, it might take a while before I create a pull
request so that this patch gets merged with the version of moltemplate
included with LAMMPS. Generally, I always recommend users download
the latest version of moltemplate from:
(instructions below for other users who read this message)

    Here is an example showing what the CMAP section of the DATA file
looks like in moltemplate format:

write("Data CMAP") {
  $cmap:cm1 1 $atom:c1 $atom:c2 $atom:c3 $atom:c4 $atom:c5
  $cmap:cm2 1 $atom:c2 $atom:c3 $atom:c4 $atom:c5 $atom:c6
  $cmap:cm3 5 $atom:c3 $atom:c4 $atom:c5 $atom:c6 $atom:c7
  $cmap:cm4 3 $atom:c4 $atom:c5 $atom:c6 $atom:c7 $atom:c8
  $cmap:cm5 1 $atom:c5 $atom:c6 $atom:c7 $atom:c8 $atom:c9

The 3rd,4th,5th,6th,7th columns of the CMAP section are interpreted as
atom-ID numbers and are represented by $atom style variables. (In this
example, I chose the names "c1",...,"c9" arbitrarily. I have no idea
if these are usually carbon atoms.)

1st column:
   The 1st column should be $cmap counters, not integers. (This way
they will be updated if many copies of the molecule you define are
created. I chose the names "cm1", "cm2", ... arbitrarily.)

2nd column:
    In the current implementation, the second column should be left as
integers. (...Don't use "@cmap"-style counter variables. The CMAP
force-field parameters are stored in external files which are not
managed by moltemplate, such as "charmm36.cmap". The integers in the
second column should correspond to the corresponding entry in this

   --- new counter variable: $cmap ---

Moltemplate supports variables which know how to keep track of $atoms,
$bonds, $angles, $dihedrals, and $impropers. It does not know about
$cmap counters, so the end user must add this variable type using the
"category" command. It's a good idea to add the following line
somewhere near the beginning of your .LT file:

category $cmap(1,1)

(If you're curious, this is explained in appendix D.2 of the
moltemplate manual. This means the "$cmap" counter begins at 1, and
increments by 1.)

Note: If you are using to create the LT file, it should
now do all of this for you automatically.

When you run, it will generate a lot of warning
messages ("Unrecognised template variable category: "cmap"). Ignore

   --- visualization ---

    VMD warning: Moltemplate's "-vmd" argument will not work because
it invokes topotools, and the 1.7 version does not yet know about the
CMAP interactions yet.
Either way, if you strip the "CMAP" section out of the ""
file, VMD should be able to visualize the data file. You can do this
manually, or you can use this command: -n CMAP < >

...and then, start VMD.
In VMD, use the "Extensions"->"Tk Console" menu option
and enter:

topo readlammpsdata full
animate write psf system.psf

(This should accomplish the same thing as running moltemplate with the
"-vmd" argument.)

    Thank you (Neda Rafiee) for supplying me with excellent bug
reports and test data! (Although I might grumble occasionally) I'm
really grateful when people send examples where moltemplate fails.
Contributions like this are critical. Much appreciated.


One caveat I forgot to clarify:

The current version of moltemplate now allows you to include CMAP interactions in your molecule definitions. However moltemplate does not yet know how to generate these interactions automatically. Currently the user must determine which atoms participate in these interactions, and then list them all out manually in the “Data CMAP” section of their .LT files.

(For comparison, moltemplate can automatically generated angles, dihedrals and impropers based on bond connectivity. The user almost never has to manually specify these interactions.)


P.S. If someone needs me to add this feature to moltemplate, I can definitely do that. (I don’t think it would be a difficult feature to add.) In particular, if somebody is interested to convert one of the CHARMM force fields into moltemplate format, then I will implement this feature. I can help you with the conversion and I can show you how to include CMAP interactions in the .LT file so that moltemplate can generate CMAPs automatically from bond topology. This would make it possible to create LAMMPS input and data files without using tools like charmm2lammps. (I have no idea if there is any demand for this, and I feel a little bit guilty soliciting help. However if lack of CMAP generation is what’s holding anyone back from contributing a CHARMM force field, then let me know and I will implement this.)