Creating Bonds, Angles, Dihedrals in the LAMMPS input file

Hi

    I created a "moltemplate" example which is similar to what you
want to do (using different molecules). These instructions will show
you how to create a LAMMPS data file with angles, dihedrals and
impropers generated automatically. This example uses the OPLSAA
force-field, but you can change that, or just throw the force-field
information away, if you don't need it. (See the comments below.)

   Suppose you use PACKMOL to create a coordinate file (named
"system.xyz" in this example) containing the coordinates of all the
atoms in your system.

(The "system.xyz" file was too big to include in this post. But you
can generate it using packmol this way:
packmol < mix_ethylene+benzene.inp)

Once you have the "system.xyz" file, run moltemplate.sh this way:

moltemplate.sh -xyz coordinates.xyz system.lt

This will create 4 files: system.data, system.in.init,
system.in.settings, system.in.charges. With these files, you are
(nearly) ready to run LAMMPS. (You just have to specify the time
step, dump, constraints (if applicable), and run-time fixes you need.)

-------- Details ---------

(The "system.in.settings" file created by moltemplate.sh will
containing all the OPLSAA force-field parameters for your simulation.
Feel free to throw it away if you are not using the OPLSAA
force-field. However, before you run moltemplate.sh, make sure you
have a file containing the rules for generating angles, dihedrals, and
impropers according to atom type. In this example, the "oplsaa.lt"
file contains these rules, as well as force-field parameters. You may
want to change this file you are not using OPLSAA. That file is also
attached to this email along with other needed files.)

Here are some excerpts from the input files in this example:

----------- benzene.lt file ------------

import "oplsaa.lt"

Benzene inherits OPLSAA {
  # We just need a list of atom types and bonds.
  # Set the charge and xyz coords (columns 4,5,6,7) to 0.00
  write('Data Atoms') {
    $atom:C1 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:C2 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:C3 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:C4 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:C5 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:C6 $mol @atom:87 0.00 0.00 0.00 0.00 # "Aromatic C"
    $atom:H11 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
    $atom:H21 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
    $atom:H31 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
    $atom:H41 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
    $atom:H51 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
    $atom:H61 $mol @atom:88 0.00 0.00 0.00 0.00 # "Aromatic H-C"
  }

  write('Data Bond List') {
    $bond:C12 $atom:C1 $atom:C2
    $bond:C23 $atom:C2 $atom:C3
    $bond:C34 $atom:C3 $atom:C4
    $bond:C45 $atom:C4 $atom:C5
    $bond:C56 $atom:C5 $atom:C6
    $bond:C61 $atom:C6 $atom:C1
    $bond:C1H1 $atom:C1 $atom:H11
    $bond:C2H2 $atom:C2 $atom:H21
    $bond:C3H3 $atom:C3 $atom:H31
    $bond:C4H4 $atom:C4 $atom:H41
    $bond:C5H5 $atom:C5 $atom:H51
    $bond:C6H6 $atom:C6 $atom:H61
  }
}

----------- ethylene.lt file ------------

import "oplsaa.lt"

Ethylene inherits OPLSAA {
  # We just need a list of atom types and bonds.
  # Set the charge and xyz coords (columns 4,5,6,7) to 0.00
  write('Data Atoms') {
    $atom:C1 $mol @atom:85 0.00 0.00 0.00 0.00 # CM "Alkene H2-C="
    $atom:C2 $mol @atom:85 0.00 0.00 0.00 0.00 # CM "Alkene H2-C="
    $atom:H11 $mol @atom:86 0.00 0.00 0.00 0.00 # HC "Alkene H-C="
    $atom:H12 $mol @atom:86 0.00 0.00 0.00 0.00 # HC "Alkene H-C="
    $atom:H21 $mol @atom:86 0.00 0.00 0.00 0.00 # HC "Alkene H-C="
    $atom:H22 $mol @atom:86 0.00 0.00 0.00 0.00 # HC "Alkene H-C="
  }

  write('Data Bond List') {
    $bond:C12 $atom:C1 $atom:C2
    $bond:C1H1 $atom:C1 $atom:H11
    $bond:C1H2 $atom:C1 $atom:H12
    $bond:C2H1 $atom:C2 $atom:H21
    $bond:C2H2 $atom:C2 $atom:H22
  }
}

----------- system.lt ------------

import "ethylene.lt"
import "benzene.lt"

benzene = new benzene [1000]
ethylene = new ethylene [1000]

write_once("Data Boundary") {
   0.0 80.00 xlo xhi
   0.0 80.00 ylo yhi
   0.0 80.00 zlo zhi
}

----------- notes --------------------

If you have VMD installed, then run moltemplate this way instead:

moltemplate.sh -vmd -xyz coordinates.xyz system.lt

This will automatically start VMD, and display the system you have just created.

Note: The "oplsaa.lt" file can be written by hand. It's fairly
readable and it's not very long. (However it is usually not generated
by hand Instead, it is usually generated gy Jason Lambert's
"oplsaa_moltemplate.py" script located in the
tools/moltemplate/common/oplsaa directory. Read the README.TXT file
located there. Atom type numbers, for example @atom:85, @atom:88 are
defined in the oplsaa.txt file, which is also located in that
directory. Hopefully I am using the correct atom types.

Hope this is useful
Cheers!

Andrew

benzene.lt (1.92 KB)

ethylene.lt (1.31 KB)

system.lt (655 Bytes)

mix_ethylene+benzene.inp (721 Bytes)

benzene.xyz (373 Bytes)

ethylene.xyz (229 Bytes)

oplsaa.lt (4.17 KB)

benzene.jpg

ethylene.jpg

ethylene+benzene_box80x80x80_LR.jpg

   Suppose you use PACKMOL to create a coordinate file (named
"system.xyz" in this example) containing the coordinates of all the
atoms in your system.
you can generate it using packmol this way:
packmol < mix_ethylene+benzene.inp)
Once you have the "system.xyz" file, run moltemplate.sh this way:
moltemplate.sh -xyz coordinates.xyz system.lt

Oops. Try this instead:

moltemplate.sh -xyz system.xyz system.lt

(The file name is "system.xyz", not "coordinates.xyz".)
Sorry for the confusion.

Andrew
P.S.
Thanks, Helene for the correction.