git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3996 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,201 +0,0 @@
|
|||||||
|
|
||||||
This directory contains utility scripts for using VMD to visualize and analyze
|
|
||||||
LAMMPS trajectories (hopefully in the future this will turn into a plugin or
|
|
||||||
proper library). Below are short descriptions and examples on how to use
|
|
||||||
them. Additional information on VMD as well as additional scripts can be found
|
|
||||||
at: http://www.ks.uiuc.edu/Research/vmd/
|
|
||||||
and: http://www.theochem.rub.de/go/cpmd-vmd.html
|
|
||||||
|
|
||||||
The scripts are maintained by Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>;
|
|
||||||
please contact him through the LAMMPS mailing list in case of problems.
|
|
||||||
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
0. Installation.
|
|
||||||
|
|
||||||
The scripts below define new tcl procedures for use with the tcl script
|
|
||||||
interpreter embedded into VMD. To activate them, you can load them by using
|
|
||||||
the "source" command. However it is more convenient to have VMD load them
|
|
||||||
automatically on demand. To do this, you need to modify your .vmdrc (or
|
|
||||||
vmd.rc) file (see the VMD User's Guide for details) and add the and adapted
|
|
||||||
version of the following code.
|
|
||||||
|
|
||||||
# add local (auto-loaded) scripts to the interpreter search path
|
|
||||||
set auto_path [concat $env(HOME)/lammps/tools/lmp2vmd $auto_path]
|
|
||||||
|
|
||||||
With this change the "source" command lines below are no longer needed. If
|
|
||||||
you add new files or procedures to this directory, you have to run the
|
|
||||||
mkindex script to update the tclIndex file.
|
|
||||||
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
1. lmpbonds2vmd.tcl - translate bonding information from a LAMMPS data
|
|
||||||
file into VMD.
|
|
||||||
|
|
||||||
1a. Background.
|
|
||||||
With VMD one typically reads bonding information from a topology file and
|
|
||||||
then reads a trajectory with the coordinate information on top of that. The
|
|
||||||
most common use is the combination of a (CHARMM or X-PLOR style) PSF file
|
|
||||||
and a DCD file (the latter can be produced by LAMMPS directly). If the
|
|
||||||
bonding information is not available, VMD uses a heuristic guess which
|
|
||||||
works reasonably well with biological systems, but can be particularly
|
|
||||||
cumbersome in coarse grained MD or similar model systems. The
|
|
||||||
lmpbonds2vmd.tcl script provides an option to transfer bonding information
|
|
||||||
from a LAMMPS data file into VMD.
|
|
||||||
|
|
||||||
1b. Usage.
|
|
||||||
The script defines a new procedure "lmpbondsfromdata". To activate it type
|
|
||||||
at the VMD command prompt:
|
|
||||||
|
|
||||||
source lmpbonds2vmd.tcl
|
|
||||||
|
|
||||||
To then build a PSF file for use in subsequent visualizations you can load
|
|
||||||
one just frame of a native LAMMPS trajectory (not binary, not custom!), for
|
|
||||||
example perusing the output from the micelle example.
|
|
||||||
|
|
||||||
mol new dump.micelle type lammpstrj waitfor all
|
|
||||||
lmpbondsfromdata [molinfo top] data.micelle
|
|
||||||
|
|
||||||
Now you should only see the bonds that actually have bonded interactions.
|
|
||||||
|
|
||||||
To avoid having to run the script all the time you can save the bonding
|
|
||||||
information in an (incomplete) PSF file.
|
|
||||||
|
|
||||||
animate write psf micelle.psf
|
|
||||||
|
|
||||||
In the future you can now load this PSF file first and then the LAMMPS dump
|
|
||||||
file(s) (or a more compact and faster loading DCD or XTC file) with:
|
|
||||||
|
|
||||||
vmd micelle.psf -lammpstrj dump.micelle
|
|
||||||
|
|
||||||
1c. Problems.
|
|
||||||
The LAMMPS data file format is quite flexible and thus not always easy to
|
|
||||||
parse independently from context. As a consequence, the lmpbondsfromdata
|
|
||||||
parser may be confused by your specific setup.
|
|
||||||
|
|
||||||
1d. History.
|
|
||||||
First version. 2007, Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
Added a sanity check 03/2008, Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
2. lmpresid2vmd.tcl - translate residue information from a LAMMPS data file
|
|
||||||
into VMD.
|
|
||||||
|
|
||||||
2a. Background.
|
|
||||||
LAMMPS dump files contain information about the (numerical) atom type, but
|
|
||||||
not a molecule or residue id as it is typically used in PSF or PDB files
|
|
||||||
to define subunits of a system. Adding this information can be very helpful
|
|
||||||
for analysis and post-processing of LAMMPS data in VMD.
|
|
||||||
|
|
||||||
2b. Usage.
|
|
||||||
The script defines a new procedure "lmpresidfromdata". To activate it type
|
|
||||||
at the VMD command prompt:
|
|
||||||
|
|
||||||
source lmpresid2vmd.tcl
|
|
||||||
|
|
||||||
To then add the residue information to a PSF file, see the steps for from
|
|
||||||
item 1 from above and then type into the VMD console.
|
|
||||||
|
|
||||||
lmpresidfromdata [molinfo top] data.micelle
|
|
||||||
|
|
||||||
To avoid having to run the script all the time you can save the residue
|
|
||||||
information in an (incomplete) PSF file.
|
|
||||||
|
|
||||||
animate write psf micelle2.psf
|
|
||||||
|
|
||||||
In the future you can now load this PSF file first and then the LAMMPS dump
|
|
||||||
file(s) (or a more compact and faster loading DCD or XTC file) with:
|
|
||||||
|
|
||||||
vmd micelle2.psf -lammpstrj dump.micelle
|
|
||||||
|
|
||||||
You can use the residue information to join bonds split across the periodic
|
|
||||||
boundaries with:
|
|
||||||
|
|
||||||
pbc join residue -all
|
|
||||||
|
|
||||||
and then enjoy a nice visualization of the micelle example with VMD. :)
|
|
||||||
|
|
||||||
2c. Problems.
|
|
||||||
The LAMMPS data file format is quite flexible and thus not always easy to
|
|
||||||
parse independent from context. As a consequence, the lmpresidfromdata
|
|
||||||
parser may be confused by your specific setup.
|
|
||||||
|
|
||||||
2d. History.
|
|
||||||
First version. 2008, Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
3. lmpname2vmd.tcl - set atom names based on LAMMPS type in VMD.
|
|
||||||
|
|
||||||
3a. Background.
|
|
||||||
LAMMPS dump files contain information about the (numerical) atom type, but
|
|
||||||
not atom names like in PSF or PDB files. The names are used in VMD to guess
|
|
||||||
element, radius and (default) coloring. Adding this information can be very
|
|
||||||
helpful to set convenient defaults for visualization of LAMMPS data in VMD.
|
|
||||||
|
|
||||||
3b. Usage.
|
|
||||||
The script defines a new procedure "lmptypetoname". To activate it type
|
|
||||||
at the VMD command prompt:
|
|
||||||
|
|
||||||
source lmpname2vmd.tcl
|
|
||||||
|
|
||||||
To then add atom name information, e.g., to a PSF file, see the steps for
|
|
||||||
item 1 from above and then type into the VMD console.
|
|
||||||
|
|
||||||
lmptypetoname [molinfo top] "SOL HDR TL1 TL2"
|
|
||||||
|
|
||||||
To avoid having to run the script all the time you can save the bonding
|
|
||||||
information in an (incomplete) PSF file.
|
|
||||||
|
|
||||||
animate write psf micelle3.psf
|
|
||||||
|
|
||||||
In the future you can now load this PSF file first and then the LAMMPS dump
|
|
||||||
file(s) (or a more compact and faster loading DCD or XTC file) with:
|
|
||||||
|
|
||||||
vmd micelle3.psf -lammpstrj dump.micelle
|
|
||||||
|
|
||||||
And you'll see that VMD will assign different colors to the atom types. You
|
|
||||||
cat get the previous coloring back by using the "Type" coloring scheme.
|
|
||||||
|
|
||||||
3c. Problems.
|
|
||||||
This script assumes the data originates from a LAMMPS dump file and thus
|
|
||||||
the atoms types are numerical starting from 1. If those have been modified
|
|
||||||
by some means, no name will be assigned.
|
|
||||||
|
|
||||||
3d. History.
|
|
||||||
First version. 2008, Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
|
|
||||||
-------------------------
|
|
||||||
|
|
||||||
4. lmpradius2vmd.tcl - set VdW radius based on LAMMPS type in VMD.
|
|
||||||
|
|
||||||
4a. Background.
|
|
||||||
The radii used for VDW and derived representations in VMD are guessed from
|
|
||||||
the atom names. This script offers a convenient way to reset them (e.g. by
|
|
||||||
using the sigma parameters from matching LJ interactions).
|
|
||||||
|
|
||||||
4b. Usage.
|
|
||||||
The script defines a new procedure "lmptypetoradius". To activate it type
|
|
||||||
at the VMD command prompt:
|
|
||||||
|
|
||||||
source lmpradius2vmd.tcl
|
|
||||||
|
|
||||||
To then add atom radius information, see the steps for
|
|
||||||
item 1 from above and then type into the VMD console.
|
|
||||||
|
|
||||||
lmptypetoradius [molinfo top] "1.00 1.00 0.75 0.50"
|
|
||||||
|
|
||||||
4c. Problems.
|
|
||||||
This script assumes the data originates from a LAMMPS dump file and thus
|
|
||||||
the atoms types are numerical starting from 1. If those have been modified
|
|
||||||
by some means, no name will be assigned. There is currently no file format
|
|
||||||
that exports the radius information, so this script/command has to be
|
|
||||||
added, e.g., to "saved states" and other visualization scripts.
|
|
||||||
|
|
||||||
|
|
||||||
4d. History.
|
|
||||||
First version. 2008, Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,67 +0,0 @@
|
|||||||
# small script to extract bonding info from a lammps data file
|
|
||||||
# so that VMD will display the correct bonds for CG-MD.
|
|
||||||
# (c) 2007 Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
proc lmpbondsfromdata {mol filename} {
|
|
||||||
|
|
||||||
if {"$mol" == "top"} {
|
|
||||||
set mol [molinfo top]
|
|
||||||
}
|
|
||||||
|
|
||||||
# create an empty bondlist
|
|
||||||
set na [molinfo $mol get numatoms]; # number of atoms
|
|
||||||
set nb 0; # number of bonds
|
|
||||||
set bl {}; # bond list
|
|
||||||
for {set i 0} {$i < $na} {incr i} {
|
|
||||||
lappend bl {}
|
|
||||||
}
|
|
||||||
|
|
||||||
# open lammps data file
|
|
||||||
if {[catch {open $filename r} fp]} {
|
|
||||||
puts stderr "could not open file $filename"
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
# read file line by line until we hit the Bonds keyword
|
|
||||||
while {[gets $fp line] >= 0} {
|
|
||||||
# pick number of bonds
|
|
||||||
regexp {^\s*(\d+)\s+bonds} $line dummy nb
|
|
||||||
|
|
||||||
if { [regexp {^\s*Bonds} $line] } {
|
|
||||||
puts "nbonds= $nb\nnow reading Bonds section"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# skip one line
|
|
||||||
gets $fp line
|
|
||||||
# read the bonds data
|
|
||||||
for {set i 0} {$i < $nb} {incr i} {
|
|
||||||
gets $fp line
|
|
||||||
# grep bond numbers from entry and adjust to VMD numbering style
|
|
||||||
regexp {^\s*\d+\s+\d+\s+(\d+)\s+(\d+)} $line dummy ba bb
|
|
||||||
incr ba -1
|
|
||||||
incr bb -1
|
|
||||||
|
|
||||||
# sanity check
|
|
||||||
if { ($ba > $na) || ($bb > $na) } {
|
|
||||||
puts stderr "number of atoms in VMD molecule ($na) does not match data file"
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
set bn [lindex $bl $ba]
|
|
||||||
lappend bn $bb
|
|
||||||
set bl [lreplace $bl $ba $ba $bn]
|
|
||||||
|
|
||||||
set bn [lindex $bl $bb]
|
|
||||||
lappend bn $ba
|
|
||||||
set bl [lreplace $bl $bb $bb $bn]
|
|
||||||
}
|
|
||||||
close $fp
|
|
||||||
|
|
||||||
set sel [atomselect $mol all]
|
|
||||||
$sel setbonds $bl
|
|
||||||
$sel delete
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
# small script to assign atom names to type numbers in LAMMPS .
|
|
||||||
# (c) 2008 Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
proc lmptypetoname {mol names} {
|
|
||||||
if {"$mol" == "top"} {
|
|
||||||
set mol [molinfo top]
|
|
||||||
}
|
|
||||||
|
|
||||||
set t 0
|
|
||||||
foreach n $names {
|
|
||||||
incr t
|
|
||||||
set sel [atomselect $mol "type $t"]
|
|
||||||
$sel set name $n
|
|
||||||
$sel delete
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
# small script to assign a radius by type number in VMD
|
|
||||||
# (c) 2008 Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
proc lmptypetoradius {mol rlist} {
|
|
||||||
if {"$mol" == "top"} {
|
|
||||||
set mol [molinfo top]
|
|
||||||
}
|
|
||||||
|
|
||||||
set t 0
|
|
||||||
foreach r $rlist {
|
|
||||||
incr t
|
|
||||||
set sel [atomselect $mol "type $t"]
|
|
||||||
$sel set radius $r
|
|
||||||
$sel delete
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,58 +0,0 @@
|
|||||||
# small script to extract residue info from a lammps data file
|
|
||||||
# (c) 2008 Axel Kohlmeyer <akohlmey@cmm.chem.upenn.edu>
|
|
||||||
|
|
||||||
proc lmpresidfromdata {mol filename} {
|
|
||||||
|
|
||||||
if {"$mol" == "top"} {
|
|
||||||
set mol [molinfo top]
|
|
||||||
}
|
|
||||||
|
|
||||||
# create an empty bondlist
|
|
||||||
set na [molinfo $mol get numatoms]; # number of atoms of molecule
|
|
||||||
set da 0; # number of atoms in data file
|
|
||||||
set rl {}; # resid list
|
|
||||||
for {set i 0} {$i < $na} {incr i} {
|
|
||||||
lappend rl 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# open lammps data file
|
|
||||||
if {[catch {open $filename r} fp]} {
|
|
||||||
puts stderr "could not open file $filename"
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
# read file line by line until we hit the Bonds keyword
|
|
||||||
while {[gets $fp line] >= 0} {
|
|
||||||
# pick number of atoms
|
|
||||||
regexp {^\s*(\d+)\s+atoms} $line dummy da
|
|
||||||
|
|
||||||
if { [regexp {^\s*Atoms} $line] } {
|
|
||||||
# sanity check
|
|
||||||
if {$na != $da} {
|
|
||||||
puts stderr \
|
|
||||||
"number of atoms in VMD molecule ($na) does not match data file ($da)"
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
puts "atoms= $da\nnow reading Atoms section"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# skip one line
|
|
||||||
gets $fp line
|
|
||||||
# read the Atoms data
|
|
||||||
for {set i 0} {$i < $da} {incr i} {
|
|
||||||
gets $fp line
|
|
||||||
# grep bond numbers from entry and adjust to VMD numbering style
|
|
||||||
regexp {^\s*(\d+)\s+(\d+)\s+\d+.*} $line dummy ba bb
|
|
||||||
incr ba -1
|
|
||||||
lset rl $ba $bb
|
|
||||||
}
|
|
||||||
close $fp
|
|
||||||
|
|
||||||
set sel [atomselect $mol all]
|
|
||||||
$sel set resid $rl
|
|
||||||
$sel delete
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/tclsh
|
|
||||||
# recreate the tcl index file for on demand loading.
|
|
||||||
#
|
|
||||||
# Copyright (c) 2003 by <Axel.Kohlmeyer@theochem.ruhr-uni-bochum.de>
|
|
||||||
#
|
|
||||||
auto_mkindex . *.tcl
|
|
||||||
|
|
||||||
############################################################
|
|
||||||
# Local Variables:
|
|
||||||
# mode: tcl
|
|
||||||
# time-stamp-format: "%u %02d.%02m.%y %02H:%02M:%02S %s"
|
|
||||||
# End:
|
|
||||||
############################################################
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
# Tcl autoload index file, version 2.0
|
|
||||||
# This file is generated by the "auto_mkindex" command
|
|
||||||
# and sourced to set up indexing information for one or
|
|
||||||
# more commands. Typically each line is a command that
|
|
||||||
# sets an element in the auto_index array, where the
|
|
||||||
# element name is the name of a command and the value is
|
|
||||||
# a script that loads the command.
|
|
||||||
|
|
||||||
set auto_index(lmptypetoname) [list source [file join $dir lmpname2vmd.tcl]]
|
|
||||||
set auto_index(lmpresidfromdata) [list source [file join $dir lmpresid2vmd.tcl]]
|
|
||||||
set auto_index(lmpbondsfromdata) [list source [file join $dir lmpbonds2vmd.tcl]]
|
|
||||||
set auto_index(lmptypetoradius) [list source [file join $dir lmpradius2vmd.tcl]]
|
|
||||||
Reference in New Issue
Block a user