
import "graphene.lt"

# -------------- graphene sheet -----------------

# Notes:
#    Hexagonal lattice with:
# d = length of each hexagonal side  = 1.42 Angstroms
# L = length of each hexagon = 2*d   = 2.84 Angstroms
# W =  width of each hexagon = 2*d*sqrt(3)/2 = 2.4595121467478 Angstroms
# w =  width of hexagon rows = 1.5*d = 2.13 Angstroms

Wall {
  unitcells = new Graphene/2AtomCellAlignX [14].move(1.2297560733739, 2.13, 0)
                                           [13].move(2.4595121467478,   0,  0)
  unitcells[*][*].move(-24.595121467478, -14.91, 0.000)

  # Now cut a hole in the graphene sheet roughly where the nanotube is located
  delete unitcells[5][7-8]   # delete 2 unit cells (2 atoms each, 4 atoms total)
  delete unitcells[6][6-8]   # delete 3 unit cells (2 atoms each, 6 atoms total)
  delete unitcells[7][5-8]   # delete 4 unit cells (2 atoms each, 8 atoms total)
  delete unitcells[8][5-7]   # delete 3 unit cells (2 atoms each, 6 atoms total)
  delete unitcells[9][5-6]   # delete 2 unit cells (2 atoms each, 4 atoms total)
  # Optional fine tuning: delete a few additional atoms around the edges
  delete unitcells[5][6]/C2   # delete a single atom
  delete unitcells[6][5]/C2   # delete a single atom
  delete unitcells[6][9]/C1   # delete a single atom
  delete unitcells[8][4]/C2   # delete a single atom
  delete unitcells[8][8]/C1   # delete a single atom
  delete unitcells[9][7]/C1   # delete a single atom
}

# Make two copies of the wall, and place them on either end of the nanotube

wall1 = new Wall.move(0, 0, 32.0)
wall2 = new Wall.move(0, 0, 58.26)


# WARNING:  A reader has emailed me to point out that:
#         THIS IS NOT A REALISTIC MODEL OF A GRAPHENE-NANOTUBE JUNCTION.
#           A real junction would be curved and deformed near the boundary,
#           (not 90 degrees) and it would not be built entirely from hexagons.
#           (This is not a problem in this example because the carbon atoms
#           are immobilized.)  If you want to simulate the behavior of
#           real graphene or nanotube junctions, you must be more careful.
#          To solve this problem:
#           Moltemplate allows you to move, customize or delete individual
#           atoms near the boundary.  You can move atoms by overwriting their 
#           coordinates using additional write("Data Atoms") statements (after
#           the walls and tube are created).  You can also change their charge.
#          Alternately, you could start with the structure provided here, and 
#           relax/minimize the coordinates of the carbon atoms using LAMMPS
#           before using it in other simulations.
#          Or you could do both (customization & minimization).
