<commit_before>{
 "metadata": {
  "name": "",
  "signature": "sha256:61c0fbfd656da0101a745e69b0bd7a5f1e2631a7f05f20bfd277773d1996e736"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This notebook contains a tutorial to perform MD simulations of an Octamethyl Silsesquioxane molecule with NAMD and the AMBER force field\n",
      "\n",
      "<h1>me8t8</h1>\n",
      "<a id='Table of Contents'></a><h3>Table of Contents</h3>\n",
      " \n",
      "<a href='#me8t8'>Octa-methyl Silsesqioxane</a>  \n",
      "<a href='#carry_MD'>Carry out the simulation</a>  \n",
      "<a href='#visualize'>Plot thermodynamic and energetic quantities</a>  \n",
      "<a href='#visualize2'>Visualize the trajectory</a>  \n",
      "<a href='#carry_MD_NVE'>Carry out the simulation in the NVE ensemble</a>  \n",
      "<a href='#RMSD'>Remove global translations and rotations with AmberTools</a>  \n",
      "<a href='#extra'>Additional tutorials from the NAMD/VMD webpage</a>  \n",
      "<a href='#view'>View/Edit the contents on an ASCII file</a>\n",
      "\n",
      "\n",
      "<a href='#Section'><h4>Section</h4></a>\n",
      "\n",
      "* <a href='#Section.subsection'>subsection</a>  \n",
      "\n",
      "<a href='#Syntax'>Examples of HTML and Markdown syntax</a></br>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='me8t8'></a><h3>Octa-methyl Silsesqioxane (mPOSS)</h3>\n",
      "The mPOSS molecule is composed of a cubic cage where silicon atoms occupy the cube vertices, and oxygen atoms are located in the cube edges (see below figure). Thus, each Si atom has a tetrahedral coordination to three O atoms and one methyl group. Methyl substitution by other chemical species makes POSS molecules highly versatile, with applications as organic solvents, polymer dispersants, catalysts, nanocomposites, diodes, and many other uses. In particular, mPOSS has found application as a coating for carbon fibers and low-dielectric films.  \n",
      "<center><a href=\"files/supporting/me8t8_molecule.png\"><img src=\"files/supporting/me8t8_molecule.png\" width=\"300\" height=\"300\" alt=\"me8t8_molecule.png\"></a></center>  \n",
      "mPOSS molecule composed of Si (yellow), O (red), C (cyan), and H (grey) atoms. Nine different chains of consecutive O-Si-C-H covalent bonds can be constructed for each methyl group, due to the three different oxygen and hydrogen atoms that can be selected at the extremes of the chain.\n",
      "<center><a href=\"files/supporting/me8t8_crystal.png\"><img src=\"files/supporting/me8t8_crystal.png\" width=\"300\" height=\"300\" alt=\"me8t8_crystal.png\"></a></center>  \n",
      "mPOSS molecule non-vibrational degrees of freedom are restricted to dicrete rotational diffusion of the methyl groups (-CH3). In the AMBER force field the barrier to rotation is described by a dihedral 4-body term.  \n",
      "<center>$V(\\phi)=K[1+cos(3\\phi)]$</center>  \n",
      "Where $\\phi$ is the dihedral angle defined by one of the nine combinations that can be formed with the four linked atoms O, Si, C, and H.  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='carry_MD'></a><h3>Carry out the simulation</h3>\n",
      "\n",
      "We will simulate a single molecule. The neccesary files to carry out the simulation are:  \n",
      "\n",
      "* me8t8.pdb (list of atoms and molecule name)\n",
      "* me8t8.prmtop (force field and topology)\n",
      "* run0.restart.coor (initial coordinates)\n",
      "* run1.conf (NAMD run options)\n",
      "\n",
      "Inspect file <i>run1.conf</i> (there are many ways in Linux to <a href='#view'>view/edit the contents on an ASCII file</a>)  How long is the simulation? How many snapshots, or frames, will be saved? Which ensemble are we running?\n",
      "\n",
      "1 <b>In the terminal</b>, go to the directory containing the files, then create a subdirectory in your scratch area and copy the files there. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "mkdir -p /SNS/local/scratch/$USER/me8t8/\n",
      "cd $HOME/SHUG2015/molecular_dynamics/examples/me8t8/\n",
      "cp me8t8.pdb  me8t8.prmtop  run0.restart.coor  run1.conf /SNS/local/scratch/$USER/me8t8/\n",
      "cd /SNS/local/scratch/$USER/me8t8/"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "2 Load the NAMD module. This will make available the namd command to actually run the simulation"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "module load namd\n",
      "which namd2  #will print the path to the namd executable"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now run the simulation. We ask that you limit to four cores. It should take about 6 minutes"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "time namd2 +idlepoll +p4 run1.conf > run1.log"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "After the simulation is done, it will print out in the terminal the take it took. New files are generated:  \n",
      "\n",
      "* run1.log  #thermodynamic quantites are saved here. (ASCII file).\n",
      "* run1.dcd  #snapshots are saved here (binary file).\n",
      "* run1.restart.coor  #coordinates of the system when the simulation finished, in high precision\n",
      "* run1.restart.vel   #velocities of the system when the simulation finished, in high precision\n",
      "* run1.restart.xsc   #geometric boundaries of the system when the simulation finished\n",
      "\n",
      "One can elongate the simulation by running a second simulation using as starting conformation files files run1.restart.coor, run1.restart.vel,run1.restart.xsc "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='visualize'></a><h3>Plot thermodynamic and energetic quantities</h3>\n",
      "\n",
      "We will use the [VMD](http://www.ks.uiuc.edu/Research/vmd/) program to visualize results. Thermodynamic quantities are stored in file <i>run1.log</i> and can be plotted with the [namdplot](http://www.ks.uiuc.edu/Research/vmd/plugins/namdplot/) plugin. In the terminal, start vmd:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "%%bash\n",
      "vmd &  #starts the vmd program"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The plugin is accessible from the Extensions tab:  \n",
      "<center><a href=\"files/supporting/namd_plot.png\"><img src=\"files/supporting/namd_plot.png\" width=\"500\" height=\"500\" alt=\"namd_plot.png\"></a></center>  \n",
      "The interface is pretty self explanatory. Loading of the file and plotting the desired quantities are accessible from the File menu:  \n",
      "<center><a href=\"files/supporting/namd_plot.2.png\"><img src=\"files/supporting/namd_plot.2.png\" width=\"300\" height=\"300\" alt=\"namd_plot.2.png\"></a></center>  \n",
      "You can inspect the different energy terms (BOND, ANGLE, DIHEDRAL, IMPROP, ELEC, VDW) as well as total energy (TOTAL) and temperature (TEMP). Since this is a simulation in \"infinite\" vacuum, there is no relevant information on volume or pressure. Plotting quantities like total energy and temperature is a miniminal and easy test to check that the simulation did not go wrong.   "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='visualize2'></a><h3>Visualize the trajectory</h3>  \n",
      "Next, we will visualize the simulation as a movie. We will also use VMD for this purpose and you can use the current VMD session.  \n",
      "First we need to load the PDB file <i>me8t8.pdb</i>. From the <i>File</i> menu select <i>New Molecule</i> and load the molecule by browsing to the file and then click the <i>Load</i> button.  \n",
      "<center><table><tr>\n",
      "<td><center><a href=\"files/supporting/load_pdb.png\"><img src=\"files/supporting/load_pdb.png\" width=\"300\" height=\"300\" alt=\"load_pdb.png\"></a></center></td> \n",
      "<td><center><a href=\"files/supporting/loaded_pdb.png\"><img src=\"files/supporting/loaded_pdb.png\" width=\"300\" height=\"300\" alt=\"loaded_pdb.png\"></a></center> </td>\n",
      "</tr></table></center>  \n",
      "\n",
      "Although the PDB contains only the names of the atoms and the coordinates of a conformation, VMD is smart enough to figure out which atoms are bonded to each other, thus creating a topology for the molecule and will show the bonds. \n",
      "Once we have topology, we can load the time evoluiton of coordinates with the trajectory file <i>run1.dcd</i>. In the main window, select molecule \"me8t8.pdb\" with a left click. The selection will be highlighted. Then, right-click and select <i>Load Data Into Molecule</i>\" from the pop up menu.  \n",
      "\n",
      "<center><a href=\"files/supporting/load_data.1.png\"><img src=\"files/supporting/load_data.1.png\" width=\"400\" height=\"400\" alt=\"load_data.1.png\"></a></center>   \n",
      "\n",
      "The <i>Molecule File Browser</i> will appear. Browse to file <i>run1.dcd</i> and then click in <i>Load</i>.  \n",
      "<center><a href=\"files/supporting/load_data.2.png\"><img src=\"files/supporting/load_data.2.png\" width=\"400\" height=\"400\" alt=\"load_data.2.png\"></a></center>  \n",
      "\n",
      "There are 4000 frames to be loaded so it will take about a minute to load them all. Once finished, the Main window will show that there are 4001 frames loaded: 1 for the initial PDB, and 4000 for the trajectory.  \n",
      "\n",
      "<center><a href=\"files/supporting/loaded_data.1.png\"><img src=\"files/supporting/loaded_data.1.png\" width=\"400\" height=\"400\" alt=\"loaded_data.1.png\"></a></center>  \n",
      "\n",
      "The lower portion of the windows feature the progress bar. By sliding the bar you can select any frame. Right now it shows the last frame, which is frame with index 4000. Notice that indexes begin at zero, thus frame number 4001 has index 4000.  \n",
      "You probably have noticed that the molecule has vanished from the OpenGL Display window!  \n",
      "\n",
      "<center><a href=\"files/supporting/loaded_data.2.png\"><img src=\"files/supporting/loaded_data.2.png\" width=\"200\" height=\"200\" alt=\"loaded_data.2.png\"></a></center>  \n",
      "\n",
      "The reason is the following: the coordinates stored in the PDB file <i>run1.pdb</i> are numerically very different than the tipical coordinates in trajectory file <i>run1.dcd</i>. The molecule \"makes a big jump\" in transitioning from frame with index=0 (the PDB file) to frame with index=1 (the first frame of the trajectory). It's like if the molecule suddenly jumped behind our back and we could not see it any more. To fix this, let's rewind the movie by pressing the \"Jump to the beginning\" button:  \n",
      "\n",
      "<center><table><tr>\n",
      "<td><a href=\"files/supporting/rewind.2.png\"><img src=\"files/supporting/rewind.2.png\" width=\"300\" height=\"300\" alt=\"rewind.2.png\"></a>\n",
      "<a href=\"files/supporting/rewind.3.png\"><img src=\"files/supporting/rewind.3.png\" width=\"300\" height=\"300\" alt=\"rewind.3.png\"></a></td></tr></table>\n",
      "<a href=\"files/supporting/loaded_pdb.png\"><img src=\"files/supporting/loaded_pdb.png\" width=\"300\" height=\"300\" alt=\"loaded_pdb.png\"></a></center>  \n",
      "\n",
      "We are back to the conformation of the PDB file (index=0). Now let's advance to the first frame of the trajectory by pressing the \"Step forward\" button:  \n",
      "\n",
      "<center><table><tr><td>\n",
      "<a href=\"files/supporting/advance.1.png\"><img src=\"files/supporting/advance.1.png\" width=\"300\" height=\"300\" alt=\"advance.1.png\"></a>\n",
      "<a href=\"files/supporting/advance.2.png\"><img src=\"files/supporting/advance.2.png\" width=\"300\" height=\"300\" alt=\"advance.2.png\"></a></td></table>\n",
      "<a href=\"files/supporting/loaded_data.2.png\"><img src=\"files/supporting/loaded_data.2.png\" width=\"300\" height=\"300\" alt=\"loaded_data.2.png\"></a></center>  \n",
      "\n",
      "As expected, the molecule has vanished from the OpenGL Display Window. We can change our perspective by resetting the view from the <i>Display</i> menu:   \n",
      "\n",
      "<center><table><tr><td> \n",
      "<a href=\"files/supporting/reset_view.1.png\"><img src=\"files/supporting/reset_view.1.png\" width=\"300\" height=\"300\" alt=\"reset_view.1.png\"></a></td>\n",
      "<td><a href=\"files/supporting/reset_view.2.png\"><img src=\"files/supporting/reset_view.2.png\" width=\"300\" height=\"300\" alt=\"reset_view.2.png\"></a></td>\n",
      "</tr></table></center>  \n",
      "\n",
      "Now we are looking at the first frame of the trajectory and are ready to watch the movie. Click in the \"play forward\" button (red circle in the picture). Also, you can modify how fast the movie plays and whether you want to skip frames with the tools highlighted in the green elipse in the picture below:  \n",
      "\n",
      "<center><table><tr><td> \n",
      "<a href=\"files/supporting/advance_play.1.png\"><img src=\"files/supporting/advance_play.1.png\" width=\"300\" height=\"300\" alt=\"advance_play.1.png\"></a> \n",
      "<a href=\"files/supporting/advance_play.3.png\"><img src=\"files/supporting/advance_play.3.png\" width=\"300\" height=\"300\" alt=\"advance_play.3.png\"></a> \n",
      "</td></tr></table>\n",
      "<a href=\"files/supporting/advance_play.2.png\"><img src=\"files/supporting/advance_play.2.png\" width=\"300\" height=\"300\" alt=\"advance_play.2.png\"></a></center>\n",
      "\n",
      "The molecule does not stay put, it rotates as a whole and its center of mass translates. This is typical of molecules subject to Brownian motion, but since the molecule is surrounded only by vacuum, why is undergoing Brownian motion?  \n",
      "The answer is the molecule is surrounded by \"ghost particles\" due to the heat bath we imposed to maintain a constant temperature. The section in configuration file <i>run1.conf</i>:  "
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "# Constant Temperature Control\n",
      "temperature   $temperature\n",
      "langevin            on    ;# do langevin dynamics\n",
      "langevinDamping     5.0   ;# damping coefficient (gamma) of 1/ps (5.0 for equilibrium runs)\n",
      "langevinHydrogen    off   ;# don't couple langevin bath to hydrogens\n",
      "langevinTemp  $temperature ;#target temperature"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "prescribes Langevin dynamics where random forces prevent conservation of total angular momentum (hence the rotational diffusion) and total momentum (hence the diffusion of the center of mass)."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='carry_MD_NVE'></a><h3>Carry out the simulation in the NVE ensemble</h3>\n",
      "As a comparison, let's run the simulation at constant energy (NVE ensemble). Think for a minute how would you modify configuration file <i>run1.conf</i> for such simulation.  \n",
      "\n",
      "The appropriate <i>run1.conf</i> file is located in your <i>$HOME/SHUG2015/molecular_dynamics/examples/me8t8/NVE/ directory</i>. The only difference with the run at constant temperature is the commenting out of the lines corresponding to the Constant Temperature Control section. Notice we have left out a line uncommented:"
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "temperature   $temperature"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This line will assign to each atom a velocity vector with random orientation and modulus sample from a Maxwell distribution of velocities at temperature $temperature. In order to start the simulation, we need initial velocities in addition to initial coordinates.  \n",
      "Create another directory in your scratch area, for instance:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "mkdir -p /SNS/local/scratch/$USER/me8t8/NVE\n",
      "cd $HOME/SHUG2015/molecular_dynamics/examples/me8t8/\n",
      "cp me8t8.pdb  me8t8.prmtop  run0.restart.coor NVE/run1.conf /SNS/local/scratch/$USER/me8t8/NVE/\n",
      "cd /SNS/local/scratch/$USER/me8t8/NVE/"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Run the simulation and use the NamdPlot plugin in VMD to check the evolution of the total energy (quantity named \"TOTAL\") versus time.  \n",
      "\n",
      "* Is it constant? If not, why?\n",
      "* How do the fluctuations of the total energy in the NVE simulation compare to the fluctuations of the total energy in the previous NVT simulation? What about the fluctuations of the temperature?  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='RMSD'></a><h3>Remove global translations and rotations with AmberTools</h3>\n",
      "As we saw in the simulation at constant temperature, the molecule undergoes Brownian motion. It's diffussion coefficient depends on  parameter <i>LangevingDamping</i> we used in the Constant Temperature Control section of file <i>run1.conf</i>.  \n",
      "    If we want to look at the internal dynamics of the molecule, where it is expected that the particular heat bath has much less influence, we have to remove these global rotations and translations.  We will use [AmberTools](http://ambermd.org/#AmberTools), the analysis tools provided by the AMBER developers. In particular, we will use the terminal command <i>cpptraj</i> that allows transformations of a molecular dynamics trajectory as well as computacp rmtion of many quantities. For details, read the cpptraj section in the [Amber14](files/supporting/Amber14.pdf) guide.  \n",
      "First, let's open the file containing the commands that will be passed to cpptraj, <i>$HOME/SHUG2015/molecular_dynamics/examples/me8t8/rms2first.cpptraj</i>.  "
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "trajin run1.dcd\n",
      "rms first time 1.0 out rms2first.dat\n",
      "trajout run1_rms2first.dcd dcd\n",
      "quit"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The first line commands cpptraj to load the trajectory onto memory. The second line will perform an RMS superposition of each frame in the trajectory to the first frame. We also indicate we want to output the RMS values onto file rms2first.dat, and indicate that consecutive frames in the trajectory are separated by 1ps. The third lane will save the trajectory in file <i>run1_rms2first.dcd</i>. This is the trajectory without global translations and rotations.  \n",
      "To run cpptraj, we have to load the amber module:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd /SNS/local/scratch/$USER/me8t8/\n",
      "cp $HOME/SHUG2015/molecular_dynamics/examples/me8t8/rms2first.cpptraj ./\n",
      "module load amber\n",
      "cpptraj -p me8t8.prmtop -i rms2first.cpptraj"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "cpptraj needs also the topology file <i>me8t8.prmtop</i>, although we could have used the PDB file <i>me8t8.pdb</i>. After we have entered these lines in the terminal, we can plot the RMS values:   "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "xmgrace rms2first.dat &"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<center><table><tr>\n",
      "<td><center><a href=\"files/supporting/rms2first.1.png\"><img src=\"files/supporting/rms2first.1.png\" width=\"400\" height=\"400\" alt=\"rms2first.1.png\"></a></center></td>\n",
      "<td><center><a href=\"files/supporting/rms2first.2.png\"><img src=\"files/supporting/rms2first.2.png\" width=\"400\" height=\"400\" alt=\"rms2first.2.png\"></a></center></td>\n",
      "</tr></table></center>  \n",
      "The RMS values increase rapidly from zero (the RMS of the first frame to itself must be zero) to a value $<RMS>=$1.0A.  \n",
      "\n",
      "Next, use VMD to visualize the new trajectory. First load the trajectory:   "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "vmd me8t8.pdb run1_rms2first.dcd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Rewind the trajectory to frame with index=1 (review the instructions in section <a href='#visualize2'>Visualize the trajectory</a> ) and then play the movie. What are the motions of the molecule now?  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='extra'></a><h3>Additional tutorials from the NAMD/VMD webpage</h3>\n",
      "There are many tutorials to master both NAMD and VMD from the [training webpage](http://www.ks.uiuc.edu/Training/Tutorials/)."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='view'></a><h3>View/Edit the contents on an ASCII file</h3>\n",
      "For those not familiar with the Linux operating system, we enumerate here a few ways to view and/or edit an ASCII file:  \n",
      "\n",
      "1 File is shown in the terminal:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "cat file  #will dump all contents of the file to the terminal\n",
      "less file #will fill the terminal with beginning of the file, and wait for user input\n",
      "vi file #the best Linux text editor according to vi fans\n",
      "emacs -nw file #the best Linux text editor according to emacs fans"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "2 File is shown in a separate window"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "emacs file &\n",
      "gedit file  & #recommended for those familiar with windows, similar to notepad\n",
      "openoffice.org file & #like WORD, maybe to much for a simple ASCII file"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Section'></a><h2>Section</h2>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Section.subsection'></a><h3>Subsection</h3>\n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Syntax'></a><h3>Markdown Syntax Examples</h3>\n",
      "local link: [link](files/link)</br>\n",
      "remote link: <a href=\"http://ambermd.org/\">http://ambermd.org</a>\n",
      "<font face=\"courier new\"> font face=\"courier new\" </font><br/>\n",
      "$$S_{model}(Q,E)=A(Q)\\cdot S_{elastic}(E) + B(Q)\\cdot S_{simulation}(Q,E)\\otimes S_{elastic}(E) + C(Q)+D(Q)\\cdot E$$\n",
      "<pre> Quoted text </pre>\n",
      "<center><table><tr>\n",
      "<td><a href=\"files/image.png\"><img src=\"files/image.png\" width=\"300\" height=\"250\" alt=\"image here\"></a> <br/>\n",
      "    <i>image caption</i></td>\n",
      "<td>some text</td>\n",
      "</tr></table></center>"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}<commit_msg>Fix 12<commit_after>{
 "metadata": {
  "name": "",
  "signature": "sha256:61c0fbfd656da0101a745e69b0bd7a5f1e2631a7f05f20bfd277773d1996e736"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This notebook contains a tutorial to perform MD simulations of an Octamethyl Silsesquioxane molecule with NAMD and the AMBER force field\n",
      "\n",
      "<h1>me8t8</h1>\n",
      "<a id='Table of Contents'></a><h3>Table of Contents</h3>\n",
      " \n",
      "<a href='#me8t8'>Octa-methyl Silsesqioxane</a>  \n",
      "<a href='#carry_MD'>Carry out the simulation</a>  \n",
      "<a href='#visualize'>Plot thermodynamic and energetic quantities</a>  \n",
      "<a href='#visualize2'>Visualize the trajectory</a>  \n",
      "<a href='#carry_MD_NVE'>Carry out the simulation in the NVE ensemble</a>  \n",
      "<a href='#RMSD'>Remove global translations and rotations with AmberTools</a>  \n",
      "<a href='#extra'>Additional tutorials from the NAMD/VMD webpage</a>  \n",
      "<a href='#view'>View/Edit the contents on an ASCII file</a>\n",
      "\n",
      "\n",
      "<a href='#Section'><h4>Section</h4></a>\n",
      "\n",
      "* <a href='#Section.subsection'>subsection</a>  \n",
      "\n",
      "<a href='#Syntax'>Examples of HTML and Markdown syntax</a></br>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='me8t8'></a><h3>Octa-methyl Silsesqioxane (mPOSS)</h3>\n",
      "The mPOSS molecule is composed of a cubic cage where silicon atoms occupy the cube vertices, and oxygen atoms are located in the cube edges (see below figure). Thus, each Si atom has a tetrahedral coordination to three O atoms and one methyl group. Methyl substitution by other chemical species makes POSS molecules highly versatile, with applications as organic solvents, polymer dispersants, catalysts, nanocomposites, diodes, and many other uses. In particular, mPOSS has found application as a coating for carbon fibers and low-dielectric films.  \n",
      "<center><a href=\"files/supporting/me8t8_molecule.png\"><img src=\"files/supporting/me8t8_molecule.png\" width=\"300\" height=\"300\" alt=\"me8t8_molecule.png\"></a></center>  \n",
      "mPOSS molecule composed of Si (yellow), O (red), C (cyan), and H (grey) atoms. Nine different chains of consecutive O-Si-C-H covalent bonds can be constructed for each methyl group, due to the three different oxygen and hydrogen atoms that can be selected at the extremes of the chain.\n",
      "<center><a href=\"files/supporting/me8t8_crystal.png\"><img src=\"files/supporting/me8t8_crystal.png\" width=\"300\" height=\"300\" alt=\"me8t8_crystal.png\"></a></center>  \n",
      "mPOSS molecule non-vibrational degrees of freedom are restricted to dicrete rotational diffusion of the methyl groups (-CH3). In the AMBER force field the barrier to rotation is described by a dihedral 4-body term.  \n",
      "<center>$V(\\phi)=K[1+cos(3\\phi)]$</center>  \n",
      "Where $\\phi$ is the dihedral angle defined by one of the nine combinations that can be formed with the four linked atoms O, Si, C, and H.  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='carry_MD'></a><h3>Carry out the simulation</h3>\n",
      "\n",
      "We will simulate a single molecule. The neccesary files to carry out the simulation are:  \n",
      "\n",
      "* me8t8.pdb (list of atoms and molecule name)\n",
      "* me8t8.prmtop (force field and topology)\n",
      "* run0.restart.coor (initial coordinates)\n",
      "* run1.conf (NAMD run options)\n",
      "\n",
      "Inspect file <i>run1.conf</i> (there are many ways in Linux to <a href='#view'>view/edit the contents on an ASCII file</a>)  How long is the simulation? How many snapshots, or frames, will be saved? Which ensemble are we running?\n",
      "\n",
      "1 <b>In the terminal</b>, go to the directory containing the files, then create a subdirectory in your scratch area and copy the files there. "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "mkdir -p /SNS/local/scratch/$USER/me8t8/\n",
      "cd $HOME/SHUG2015/molecular_dynamics/examples/me8t8/\n",
      "cp me8t8.pdb  me8t8.prmtop  run0.restart.coor  run1.conf /SNS/local/scratch/$USER/me8t8/\n",
      "cd /SNS/local/scratch/$USER/me8t8/"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "2 Load the NAMD module. This will make available the namd command to actually run the simulation"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "module load namd\n",
      "which namd2  #will print the path to the namd executable"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now run the simulation. We ask that you limit to four cores. It should take about 6 minutes"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "time namd2 +idlepoll +p4 run1.conf > run1.log"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "After the simulation is done, it will print out in the terminal the take it took. New files are generated:  \n",
      "\n",
      "* run1.log  #thermodynamic quantites are saved here. (ASCII file).\n",
      "* run1.dcd  #snapshots are saved here (binary file).\n",
      "* run1.restart.coor  #coordinates of the system when the simulation finished, in high precision\n",
      "* run1.restart.vel   #velocities of the system when the simulation finished, in high precision\n",
      "* run1.restart.xsc   #geometric boundaries of the system when the simulation finished\n",
      "\n",
      "One can elongate the simulation by running a second simulation using as starting conformation files files run1.restart.coor, run1.restart.vel,run1.restart.xsc "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='visualize'></a><h3>Plot thermodynamic and energetic quantities</h3>\n",
      "\n",
      "We will use the [VMD](http://www.ks.uiuc.edu/Research/vmd/) program to visualize results. Thermodynamic quantities are stored in file <i>run1.log</i> and can be plotted with the [namdplot](http://www.ks.uiuc.edu/Research/vmd/plugins/namdplot/) plugin. In the terminal, start vmd:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [
      "%%bash\n",
      "vmd &  #starts the vmd program"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The plugin is accessible from the Extensions tab:  \n",
      "<center><a href=\"files/supporting/namd_plot.png\"><img src=\"files/supporting/namd_plot.png\" width=\"500\" height=\"500\" alt=\"namd_plot.png\"></a></center>  \n",
      "The interface is pretty self explanatory. Loading of the file and plotting the desired quantities are accessible from the File menu:  \n",
      "<center><a href=\"files/supporting/namd_plot.2.png\"><img src=\"files/supporting/namd_plot.2.png\" width=\"300\" height=\"300\" alt=\"namd_plot.2.png\"></a></center>  \n",
      "You can inspect the different energy terms (BOND, ANGLE, DIHEDRAL, IMPROP, ELEC, VDW) as well as total energy (TOTAL) and temperature (TEMP). Since this is a simulation in \"infinite\" vacuum, there is no relevant information on volume or pressure. Plotting quantities like total energy and temperature is a miniminal and easy test to check that the simulation did not go wrong.   "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='visualize2'></a><h3>Visualize the trajectory</h3>  \n",
      "Next, we will visualize the simulation as a movie. We will also use VMD for this purpose and you can use the current VMD session.  \n",
      "First we need to load the PDB file <i>me8t8.pdb</i>. From the <i>File</i> menu select <i>New Molecule</i> and load the molecule by browsing to the file and then click the <i>Load</i> button.  \n",
      "<center><table><tr>\n",
      "<td><center><a href=\"files/supporting/load_pdb.png\"><img src=\"files/supporting/load_pdb.png\" width=\"300\" height=\"300\" alt=\"load_pdb.png\"></a></center></td> \n",
      "<td><center><a href=\"files/supporting/loaded_pdb.png\"><img src=\"files/supporting/loaded_pdb.png\" width=\"300\" height=\"300\" alt=\"loaded_pdb.png\"></a></center> </td>\n",
      "</tr></table></center>  \n",
      "\n",
      "Although the PDB contains only the names of the atoms and the coordinates of a conformation, VMD is smart enough to figure out which atoms are bonded to each other, thus creating a topology for the molecule and will show the bonds. \n",
      "Once we have topology, we can load the time evoluiton of coordinates with the trajectory file <i>run1.dcd</i>. In the main window, select molecule \"me8t8.pdb\" with a left click. The selection will be highlighted. Then, right-click and select <i>Load Data Into Molecule</i>\" from the pop up menu.  \n",
      "\n",
      "<center><a href=\"files/supporting/load_data.1.png\"><img src=\"files/supporting/load_data.1.png\" width=\"400\" height=\"400\" alt=\"load_data.1.png\"></a></center>   \n",
      "\n",
      "The <i>Molecule File Browser</i> will appear. Browse to file <i>run1.dcd</i> and then click in <i>Load</i>.  \n",
      "<center><a href=\"files/supporting/load_data.2.png\"><img src=\"files/supporting/load_data.2.png\" width=\"400\" height=\"400\" alt=\"load_data.2.png\"></a></center>  \n",
      "\n",
      "There are 4000 frames to be loaded so it will take about a minute to load them all. Once finished, the Main window will show that there are 4001 frames loaded: 1 for the initial PDB, and 4000 for the trajectory.  \n",
      "\n",
      "<center><a href=\"files/supporting/loaded_data.1.png\"><img src=\"files/supporting/loaded_data.1.png\" width=\"400\" height=\"400\" alt=\"loaded_data.1.png\"></a></center>  \n",
      "\n",
      "The lower portion of the windows feature the progress bar. By sliding the bar you can select any frame. Right now it shows the last frame, which is frame with index 4000. Notice that indexes begin at zero, thus frame number 4001 has index 4000.  \n",
      "You probably have noticed that the molecule has vanished from the OpenGL Display window!  \n",
      "\n",
      "<center><a href=\"files/supporting/loaded_data.2.png\"><img src=\"files/supporting/loaded_data.2.png\" width=\"200\" height=\"200\" alt=\"loaded_data.2.png\"></a></center>  \n",
      "\n",
      "The reason is the following: the coordinates stored in the PDB file <i>run1.pdb</i> are numerically very different than the tipical coordinates in trajectory file <i>run1.dcd</i>. The molecule \"makes a big jump\" in transitioning from frame with index=0 (the PDB file) to frame with index=1 (the first frame of the trajectory). It's like if the molecule suddenly jumped behind our back and we could not see it any more. To fix this, let's rewind the movie by pressing the \"Jump to the beginning\" button:  \n",
      "\n",
      "<center><table><tr>\n",
      "<td><a href=\"files/supporting/rewind.2.png\"><img src=\"files/supporting/rewind.2.png\" width=\"300\" height=\"300\" alt=\"rewind.2.png\"></a>\n",
      "<a href=\"files/supporting/rewind.3.png\"><img src=\"files/supporting/rewind.3.png\" width=\"300\" height=\"300\" alt=\"rewind.3.png\"></a></td></tr></table>\n",
      "<a href=\"files/supporting/loaded_pdb.png\"><img src=\"files/supporting/loaded_pdb.png\" width=\"300\" height=\"300\" alt=\"loaded_pdb.png\"></a></center>  \n",
      "\n",
      "We are back to the conformation of the PDB file (index=0). Now let's advance to the first frame of the trajectory by pressing the \"Step forward\" button:  \n",
      "\n",
      "<center><table><tr><td>\n",
      "<a href=\"files/supporting/advance.1.png\"><img src=\"files/supporting/advance.1.png\" width=\"300\" height=\"300\" alt=\"advance.1.png\"></a>\n",
      "<a href=\"files/supporting/advance.2.png\"><img src=\"files/supporting/advance.2.png\" width=\"300\" height=\"300\" alt=\"advance.2.png\"></a></td></table>\n",
      "<a href=\"files/supporting/loaded_data.2.png\"><img src=\"files/supporting/loaded_data.2.png\" width=\"300\" height=\"300\" alt=\"loaded_data.2.png\"></a></center>  \n",
      "\n",
      "As expected, the molecule has vanished from the OpenGL Display Window. We can change our perspective by resetting the view from the <i>Display</i> menu:   \n",
      "\n",
      "<center><table><tr><td> \n",
      "<a href=\"files/supporting/reset_view.1.png\"><img src=\"files/supporting/reset_view.1.png\" width=\"300\" height=\"300\" alt=\"reset_view.1.png\"></a></td>\n",
      "<td><a href=\"files/supporting/reset_view.2.png\"><img src=\"files/supporting/reset_view.2.png\" width=\"300\" height=\"300\" alt=\"reset_view.2.png\"></a></td>\n",
      "</tr></table></center>  \n",
      "\n",
      "Now we are looking at the first frame of the trajectory and are ready to watch the movie. Click in the \"play forward\" button (red circle in the picture). Also, you can modify how fast the movie plays and whether you want to skip frames with the tools highlighted in the green elipse in the picture below:  \n",
      "\n",
      "<center><table><tr><td> \n",
      "<a href=\"files/supporting/advance_play.1.png\"><img src=\"files/supporting/advance_play.1.png\" width=\"300\" height=\"300\" alt=\"advance_play.1.png\"></a> \n",
      "<a href=\"files/supporting/advance_play.3.png\"><img src=\"files/supporting/advance_play.3.png\" width=\"300\" height=\"300\" alt=\"advance_play.3.png\"></a> \n",
      "</td></tr></table>\n",
      "<a href=\"files/supporting/advance_play.2.png\"><img src=\"files/supporting/advance_play.2.png\" width=\"300\" height=\"300\" alt=\"advance_play.2.png\"></a></center>\n",
      "\n",
      "The molecule does not stay put, it rotates as a whole and its center of mass translates. This is typical of molecules subject to Brownian motion, but since the molecule is surrounded only by vacuum, why is undergoing Brownian motion?  \n",
      "The answer is the molecule is surrounded by \"ghost particles\" due to the heat bath we imposed to maintain a constant temperature. The section in configuration file <i>run1.conf</i>:  "
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "# Constant Temperature Control\n",
      "temperature   $temperature\n",
      "langevin            on    ;# do langevin dynamics\n",
      "langevinDamping     5.0   ;# damping coefficient (gamma) of 1/ps (5.0 for equilibrium runs)\n",
      "langevinHydrogen    off   ;# don't couple langevin bath to hydrogens\n",
      "langevinTemp  $temperature ;#target temperature"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "prescribes Langevin dynamics where random forces prevent conservation of total angular momentum (hence the rotational diffusion) and total momentum (hence the diffusion of the center of mass)."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='carry_MD_NVE'></a><h3>Carry out the simulation in the NVE ensemble</h3>\n",
      "As a comparison, let's run the simulation at constant energy (NVE ensemble). Think for a minute how would you modify configuration file <i>run1.conf</i> for such simulation.  \n",
      "\n",
      "The appropriate <i>run1.conf</i> file is located in your <i>&#36;HOME/SHUG2015/molecular_dynamics/examples/me8t8/NVE/ directory</i>. The only difference with the run at constant temperature is the commenting out of the lines corresponding to the Constant Temperature Control section. Notice we have left out a line uncommented:"
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "temperature   $temperature"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This line will assign to each atom a velocity vector with random orientation and modulus sample from a Maxwell distribution of velocities at temperature &#36;temperature. In order to start the simulation, we need initial velocities in addition to initial coordinates.  \n",
      "Create another directory in your scratch area, for instance:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "mkdir -p /SNS/local/scratch/$USER/me8t8/NVE\n",
      "cd $HOME/SHUG2015/molecular_dynamics/examples/me8t8/\n",
      "cp me8t8.pdb  me8t8.prmtop  run0.restart.coor NVE/run1.conf /SNS/local/scratch/$USER/me8t8/NVE/\n",
      "cd /SNS/local/scratch/$USER/me8t8/NVE/"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Run the simulation and use the NamdPlot plugin in VMD to check the evolution of the total energy (quantity named \"TOTAL\") versus time.  \n",
      "\n",
      "* Is it constant? If not, why?\n",
      "* How do the fluctuations of the total energy in the NVE simulation compare to the fluctuations of the total energy in the previous NVT simulation? What about the fluctuations of the temperature?  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='RMSD'></a><h3>Remove global translations and rotations with AmberTools</h3>\n",
      "As we saw in the simulation at constant temperature, the molecule undergoes Brownian motion. It's diffussion coefficient depends on  parameter <i>LangevingDamping</i> we used in the Constant Temperature Control section of file <i>run1.conf</i>.  \n",
      "    If we want to look at the internal dynamics of the molecule, where it is expected that the particular heat bath has much less influence, we have to remove these global rotations and translations.  We will use [AmberTools](http://ambermd.org/#AmberTools), the analysis tools provided by the AMBER developers. In particular, we will use the terminal command <i>cpptraj</i> that allows transformations of a molecular dynamics trajectory as well as computacp rmtion of many quantities. For details, read the cpptraj section in the [Amber14](files/supporting/Amber14.pdf) guide.  \n",
      "First, let's open the file containing the commands that will be passed to cpptraj, <i>&#36;HOME/SHUG2015/molecular_dynamics/examples/me8t8/rms2first.cpptraj</i>.  "
     ]
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "trajin run1.dcd\n",
      "rms first time 1.0 out rms2first.dat\n",
      "trajout run1_rms2first.dcd dcd\n",
      "quit"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The first line commands cpptraj to load the trajectory onto memory. The second line will perform an RMS superposition of each frame in the trajectory to the first frame. We also indicate we want to output the RMS values onto file rms2first.dat, and indicate that consecutive frames in the trajectory are separated by 1ps. The third lane will save the trajectory in file <i>run1_rms2first.dcd</i>. This is the trajectory without global translations and rotations.  \n",
      "To run cpptraj, we have to load the amber module:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "cd /SNS/local/scratch/$USER/me8t8/\n",
      "cp $HOME/SHUG2015/molecular_dynamics/examples/me8t8/rms2first.cpptraj ./\n",
      "module load amber\n",
      "cpptraj -p me8t8.prmtop -i rms2first.cpptraj"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "cpptraj needs also the topology file <i>me8t8.prmtop</i>, although we could have used the PDB file <i>me8t8.pdb</i>. After we have entered these lines in the terminal, we can plot the RMS values:   "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "xmgrace rms2first.dat &"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<center><table><tr>\n",
      "<td><center><a href=\"files/supporting/rms2first.1.png\"><img src=\"files/supporting/rms2first.1.png\" width=\"400\" height=\"400\" alt=\"rms2first.1.png\"></a></center></td>\n",
      "<td><center><a href=\"files/supporting/rms2first.2.png\"><img src=\"files/supporting/rms2first.2.png\" width=\"400\" height=\"400\" alt=\"rms2first.2.png\"></a></center></td>\n",
      "</tr></table></center>  \n",
      "The RMS values increase rapidly from zero (the RMS of the first frame to itself must be zero) to a value $<RMS>=$1.0A.  \n",
      "\n",
      "Next, use VMD to visualize the new trajectory. First load the trajectory:   "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "vmd me8t8.pdb run1_rms2first.dcd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Rewind the trajectory to frame with index=1 (review the instructions in section <a href='#visualize2'>Visualize the trajectory</a> ) and then play the movie. What are the motions of the molecule now?  "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='extra'></a><h3>Additional tutorials from the NAMD/VMD webpage</h3>\n",
      "There are many tutorials to master both NAMD and VMD from the [training webpage](http://www.ks.uiuc.edu/Training/Tutorials/)."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='view'></a><h3>View/Edit the contents on an ASCII file</h3>\n",
      "For those not familiar with the Linux operating system, we enumerate here a few ways to view and/or edit an ASCII file:  \n",
      "\n",
      "1 File is shown in the terminal:  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "cat file  #will dump all contents of the file to the terminal\n",
      "less file #will fill the terminal with beginning of the file, and wait for user input\n",
      "vi file #the best Linux text editor according to vi fans\n",
      "emacs -nw file #the best Linux text editor according to emacs fans"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "2 File is shown in a separate window"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%bash\n",
      "emacs file &\n",
      "gedit file  & #recommended for those familiar with windows, similar to notepad\n",
      "openoffice.org file & #like WORD, maybe to much for a simple ASCII file"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Section'></a><h2>Section</h2>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Section.subsection'></a><h3>Subsection</h3>\n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "(<a href='#Table of Contents'>Top</a>)<a id='Syntax'></a><h3>Markdown Syntax Examples</h3>\n",
      "local link: [link](files/link)</br>\n",
      "remote link: <a href=\"http://ambermd.org/\">http://ambermd.org</a>\n",
      "<font face=\"courier new\"> font face=\"courier new\" </font><br/>\n",
      "$$S_{model}(Q,E)=A(Q)\\cdot S_{elastic}(E) + B(Q)\\cdot S_{simulation}(Q,E)\\otimes S_{elastic}(E) + C(Q)+D(Q)\\cdot E$$\n",
      "<pre> Quoted text </pre>\n",
      "<center><table><tr>\n",
      "<td><a href=\"files/image.png\"><img src=\"files/image.png\" width=\"300\" height=\"250\" alt=\"image here\"></a> <br/>\n",
      "    <i>image caption</i></td>\n",
      "<td>some text</td>\n",
      "</tr></table></center>"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.16489054438977752, 'fraction_numerical': 0.018405274585184154, 'mean_word_length': 2.936333699231614, 'pattern_counts': {'":': 298, '<': 655, '<?xml version=': 0, '>': 657, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '404966', 'n_tokens_mistral': 16915, 'n_tokens_neox': 16088, 'n_words': 4949}