jewettaij / moltemplate

A general cross-platform tool for preparing simulations of molecules and complex molecular assemblies
http://www.moltemplate.org
MIT License
249 stars 98 forks source link

Dihedrals in ethene? #84

Closed YunxingZuo closed 1 year ago

YunxingZuo commented 1 year ago

Hi Andrew,

Attached are the chemical.lt for a simple ethene molecule and the corresponding system.lt. When I followed the guideline and used path/moltemplate.sh system.lt, I found 4 dihedrals in system.data, which doesn't seem make sense as all the atoms in ethene lie in one plane. Please let me know what you think about this. Thanks!

chemical.lt

import "oplsaa.lt"

chemical inherits OPLSAA {
    write('Data Atoms') {
        $atom:0 $mol @atom:88 -0.39937 0.666  -0.000   0.000
        $atom:1 $mol @atom:88 -0.39937 -0.666   0.000  -0.000
        $atom:2 $mol @atom:89 0.199685 1.241  -0.924  -0.000
        $atom:3 $mol @atom:89 0.199685 1.240   0.924  -0.000
        $atom:4 $mol @atom:89 0.199685 -1.240  -0.924   0.000
        $atom:5 $mol @atom:89 0.199685 -1.241   0.925   0.000
    }

    write('Data Bond List') {
        $bond:0 $atom:0 $atom:1
        $bond:1 $atom:0 $atom:2
        $bond:2 $atom:0 $atom:3
        $bond:3 $atom:1 $atom:4
        $bond:4 $atom:1 $atom:5
    }
}

system.lt

import "chemical.lt"

# Periodic boundary conditions
write_once("Data Boundary") {
    0.0  32.0  xlo xhi
    0.0  32.0  ylo yhi
    0.0  64.0  zlo zhi
}

Chemical = new chemical
Chemical.move(0.0, 0.0, 0.0)

system.data

LAMMPS Description

     6  atoms
     5  bonds
     6  angles
     4  dihedrals
     6  impropers

     906  atom types
     379  bond types
     1017  angle types
     800  dihedral types
     6  improper types

  0.0 32.0 xlo xhi
  0.0 32.0 ylo yhi
  0.0 64.0 zlo zhi
...
jewettaij commented 1 year ago

Hi YunxingZuo. Here is a picture of ethene:

   h11             h21
       \          /
         c1 == c2
       /          \
   h12             h22

Unless the angles, dihedrals, and impropers are explicitly listed in the molecule definition (see spce.lt, for example), the dihedral interactions will be generated automatically by looking for every possible way that 4 atoms in your molecule can be directly connected by covalent bonds. In this molecule, there are 4 ways:

h11 -- c1 == c2 -- h21
h11 -- c1 == c2 -- h22
h12 -- c1 == c2 -- h21
h12 -- c1 == c2 -- h22

so moltemplate.sh will generate all 4 of them. I think nearly all molecular simulation preparation programs do something similar to this.

If you are curious, the type of the dihedral interaction is named "@dihedral:046_047_047_046" (because the H and C atom types belong to the the 046 and 047 bond type groups, which are defined by "replace" statements). For details, see lines 1974, 1975, 7082 of the oplsaa.lt file. (Incidentally, the "replace" statement used in that is explained here and demonstrated in a more simple version of the "oplsaa.lt" file here. Download the "oplsaa_simple.lt" file located there and open it up in a text editor to see how it works. Moltemplate users don't necessarily need to understand these messy details to use moltemplate. But you seemed a little bit more interested in how things work, so I thought I'd add some links in case they help.)

Other comments:

1) There's an example using ethene with the OPLSAA force field here (named ethylene.lt). It is very similar to your file, but the $atom names are easier to understand. 2) Incidentally, after you build your system using "moltemplate.sh system.lt", there are many different atom types (and bond types, etc...). This is because (by default) the files that moltemplate.sh generates (including system.data, system.in.settings) will contain all of the atom types and force-field parameters in the entire OPLSAA force field, even if you only need a few of them. To clean this up, you can try running:

   cleanup_moltemplate.sh

(documented here to simplify your system.data and system.in.* files. Your new files will only have 2 atom types, 3 bond types, 2 dihedral types, and 1 improper type (I think).

jewettaij commented 1 year ago

(I should warn you that I have very limited time to provide technical support at the moment. I just started a new job. But hopefully, this gets you started. I appreciate your efforts to contact me to report bugs in moltemplate.sh. If you find more bugs in moltemplate or its examples, I will definitely respond. Thanks for doing that!)