  # ----------------------------------------------------------------------
  # --   General comment:                                               --
  # -- The write() and write_once() commands create and append text to  --
  # -- files (replacing variables beginning with @ or $ with counters.) --
  # -- File names beginning with "In " or "Data " are special.          --
  # -- They will be pasted into the LAMMPS input script and             --
  # -- data files which are generated by moltemplate.  The syntax       --
  # -- of these files is exactly the same as the syntax from the        --
  # -- corresponding sections of a LAMMPS input script or data file.    --
  # ----------------------------------------------------------------------


MonomerTypes {


  2bead {
    # atom-id  mol-id   atom-type    charge  x      y       z

    write("Data Atoms") {
      $atom:CA  $mol:...  @atom:CA    0.0   0.000  1.000  0.0000
      $atom:R   $mol:...  @atom:R     0.0   0.000  4.400  0.0000
    }

    # bond-id   bond-type           atom-id1  atom-id2

    write("Data Bonds") {
      $bond:CR  @bond:../sidechain  $atom:CA  $atom:R
    }

    # atom-type   mass

    write_once("Data Masses") {
      @atom:CA    12.0
      @atom:R     17.0
    }

    #            atom-type  atom-type   epsilon sigma

    write_once("In Settings") {
      pair_coeff @atom:CA   @atom:CA    0.10   2.0
      pair_coeff @atom:R    @atom:R     0.50   3.0
    }

  } # 2bead


  3bead {
    # atom-id  mol-id   atom-type    charge    x      y       z

    write("Data Atoms") {
      $atom:CA  $mol:...  @atom:CA     0.0   0.000  1.000   0.000
      $atom:R1  $mol:...  @atom:R      0.0   0.000  2.700   2.950
      $atom:R2  $mol:...  @atom:R      0.0   0.000  2.700  -2.950
    }

    # bond-id   bond-type            atom-id1  atom-id2

    write("Data Bonds") {
      $bond:CR1  @bond:../sidechain  $atom:CA  $atom:R1
      $bond:CR2  @bond:../sidechain  $atom:CA  $atom:R2
    }

    # atom-type   mass

    write_once("Data Masses") {
      @atom:CA    12.0
      @atom:R     17.0
    }

    #            atom-type  atom-type   epsilon sigma

    write_once("In Settings") {
      pair_coeff @atom:CA   @atom:CA    0.10   2.0
      pair_coeff @atom:R    @atom:R     0.50   3.0
    }
  } # 3bead


  write_once("In Settings") {
    #            bond-type          k     r0
    bond_coeff  @bond:sidechain   20.0   3.4
    bond_coeff  @bond:bb          20.0   3.4   # "bb" shorthand for "backbone"
  }

  # Although there's no need to define angular interactions (because this 
  # "molecule" only contains two atoms), we define the settings for angles
  # or dihedrals which might be present later when we build a polymer.

  write_once("In Settings") {
    #                angle-type         k    theta0
    angle_coeff     @angle:backbone   10.00  160
    angle_coeff     @angle:sidechain  10.00  120
    angle_coeff     @angle:RCR        10.00  120
    #                dihedral-type      K1     K2      K3      K4
    dihedral_coeff  @dihedral:backbn  0.10 -0.271016 3.145034 0.0
  }

  #  Rules for determining 3 and 4-body bonded interactions by type

  # angle-type       atomType1 atomType2 atomType3  bondType1 bondType2

  write_once("Data Angles By Type") {
    @angle:backbone  @atom:*/CA  @atom:*/CA @atom:*/CA  @bond:*   @bond:*
    @angle:sidechain @atom:*/CA  @atom:*/CA @atom:*/R   @bond:*   @bond:*
    @angle:RCR       @atom:*/R   @atom:*/CA @atom:*/R   @bond:*   @bond:*
  }

  # dihedral-type AtomType1 AtomType2 AtomType3 AtomType4 bondType1 btyp2 btyp3

  write_once("Data Dihedrals By Type") {
    @dihedral:backbn @atom:*/CA @atom:*/CA @atom:*/CA @atom:*/CA  * * *
  }

} # MonomerTypes

