From: Olaf Lenz (olenz_at_icp.uni-stuttgart.de)
Date: Tue Jul 17 2012 - 14:15:45 CDT

Hi!

On 07/17/2012 08:10 PM, Fatemesadat Emami wrote:
> I have simulated a surface (infinite with periodic bonds) with namd.
> When I visualize it in vmd the bonds over the boundaries are shown.
> Is there any way to not visualize the periodic bonds to have a
> cleaner visualization?

The following proc removes all bonds over a given length. Just put it
into your ~/.vmdrc and call

   remove_long_bonds <L>

where <L> is the maximal length of a bond. Just set it to a number which
is e.g. half the simulation box length. Note, however, that this will
remove all bonds from the whole simulation, so this is not a good option
in the case of several time steps.

proc remove_long_bonds { max_length } {
     for { set i 0 } { $i < [ molinfo top get numatoms ] } { incr i } {
         set bead [ atomselect top "index $i" ]
         set bonds [ lindex [$bead getbonds] 0 ]

         if { [ llength bonds ] > 0 } {
             set bonds_new {}
             set xyz [ lindex [$bead get {x y z}] 0 ]

             foreach j $bonds {
                 set bead_to [ atomselect top "index $j" ]
                 set xyz_to [ lindex [$bead_to get {x y z}] 0 ]
                 if { [ vecdist $xyz $xyz_to ] < $max_length } {
                     lappend bonds_new $j
                 }
             }
             $bead setbonds [ list $bonds_new ]
         }
     }
}

Olaf

-- 
Dr. rer. nat. Olaf Lenz
Institut für Computerphysik, Pfaffenwaldring 27, D-70569 Stuttgart
Phone: +49-711-685-63607