How to extend an existing force-field

Rather than create an entire force field file from scratch, users typically want to modify an existing force field to add some custom atom types or bond types. You can do that either by:
1) modifying the original force field file and copying it into the folder with your other .lt files
2) creating a new file that only contains the changes. This approach is demonstrated below.

Suppose we want to extend the "forcefield.lt" file from this simple example.

# --- new file "forcefield_variant.lt" ---

import "forcefield.lt"  #<--defines "ForceField"

ForceField {
  # ADD YOUR NEW ATOM TYPES AND BONDED INTERACTIONS HERE
  # Note: This will not overwrite the preexisting "ForceField" object.
  #       (Instead, it augments the "ForceField" object defined earlier.)

  # Now add a new atom type ("@atom:CB")
  write_once("Data Masses") {
    @atom:CB 20.0
  }
  :

  # Define a new dihedral interaction:
  write_once("Data Dihedrals By Type") {
    @dihedral:XCCX @atom:* @atom:CA @atom:CA @atom:*
  }
  :
}
(Incidentally, this is how the LOPLS force field was implemented. See loplsaa.lt .)

In the last line of this example, "@atom:*" will match with "@atom:CA", "@atom:R", and "@atom:CB", since they all belong to the same "ForceField" object. In the last line of this example, "@atom:*" will match with "@atom:CA", "@atom:R", and "@atom:CB", since they all belong to the same "ForceField" object. Molecules that use the new force field version will import the new "forcefield_variant.lt" file.

import "forcefield_variant.lt"

MoleculeV2 inherits ForceField {
   # Here you can refer to @atoms, @bonds, etc... defined in either file:
   # - "forcefield.lt"  (eg. @atom:CA, @atom:R, ...)
   # - "forcefield_variant.lt"  (eg. @atom:CB, @dihedral:XCCX)
}

Note: Don't try to create a new force-field object containing only the new @atom, @bond, @angle, @dihedral or @improper types. (For example "ForceField2 inherits ForceField".) See section 7.8 of the moltemplate manual for details.