This tutorial part collects a variety of short explanation of different operations using TopoTools.
Reconstruct a .pdb/.psf files from a LAMMPS data file for use with visualization programs![]() The process starts with reading in the data file (note: the atom style has to be known):
topo readlammpsdata data.hdpe-x5 fullWith this information loaded, we would get a visualization like in the left side of the image. Now we can try to guess the element names from the atomic masses and use those to set other properties like atom name or radius. Of course, this step only works, if the masses are actually given in the data file:
topo guessatom element masstopo guessatom name elementtopo guessatom radius elementset selc [atomselect top {name C}]$selc set type CT$selc set resname HDPE# set residue ID to a 1-based index.
set resid {}
foreach r [$selc get residue] { incr r; lappend resid $r }$selc set resid $residtopo clearimpropersFinally we let VMD reanalyze the molecular information and write out the information in the desired formats:
mol reanalyze topanimate write psf hdpe-x5.psfanimate write pdb hdpe-x5.pdbFor a single-walled carbon nanotube (data.swcnt-5,5) we could perform the same operation, but in this case, we need to keep impropers and would benefit from setting a different atom type (for aromatic carbons) as shown in the script reconstructswcnt.tcl. Combine multiple data files with overlap detection and removal![]() ::TopoTools::mergemols procedure, no test is made to check for overlapping atoms or molecules, but elimination of overlaps can be done on the combined molecule just as easily:set mindist 2.5 ; # minimum required distance between atoms# load solute moleculeset solute [mol new solute.psf waitfor all]mol addfile solute.pdb mol $solute waitfor all# load solvent box, suitable sized and translatedset solvent [mol new solvent.psf waitfor all]mol addfile solvent.pdb mol $solvent waitfor all# merge and transfer solvent box dimensionsset combined [TopoTools::mergemols "$solute $solvent"]molinfo $combined set {a b c alpha beta gamma} [molinfo $solvent get {a b c alpha beta gamma}# define a macro that make it easy to determine the soluteset sel [atomselect $solute all]atomselect macro solute "index < [$sel num]"$sel delete# create selection of non-overlapping atomsset sel [atomselect $combined "not (same fragment as (exwithin $mindist of solute))"]$sel writepsf merged.psf$sel writepdb merged.pdb |

