]> hackdaworld.org Git - physik/posic.git/commitdiff
auto bond feature added
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 23 Sep 2009 16:31:45 +0000 (18:31 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Wed, 23 Sep 2009 16:31:45 +0000 (18:31 +0200)
vasp_tools/visualize

index 8d1e98f9230aac59acf8ab4561c45a9b7160339d..793e72eb85946b3f2cbcf931962ef07d6e22cbd5 100755 (executable)
@@ -37,7 +37,7 @@ lx="0"; ly="-100"; lz="100";
 ortographic=""
 bx0=""; by0=""; bz0="";
 bx1=""; by1=""; bz1="";
-bcr="";
+bcr="0.1";
 clx="0"; cly="0"; clz="0";
 extra=0
 displace=""
@@ -45,6 +45,7 @@ mirror=0
 mx1=0; mx2=0; mx3=0;
 my1=0; my2=0; my3=0;
 mz1=0; mz2=0; mz3=0;
+ab=0
 
 # parse argv
 
@@ -70,7 +71,8 @@ while [ "$1" ]; do
                                my1=$5; my2=$6; my3=$7;
                                mz1=$8; mz2=$9; mz3=${10};
                                mirror=1;               shift 10;;
-
+               -A)             ab=1;
+                               anr=$2; cutoff=$3;      shift 3;;
                *)
                                echo "options:"
                                echo "########"
@@ -95,6 +97,8 @@ while [ "$1" ]; do
                                echo "  -c <x> <y> <z> (camera position)"
                                echo "  -L <x> <y> <z> (camera look)"
                                echo "  -l <x> <y> <z> (light source)"
+                               echo "bonds:"
+                               echo "  -ab <atom number> <cutoff> (auto bonds)"
                                exit 1;;
        esac
 done
@@ -344,7 +348,68 @@ EOF
                }' >> temp.pov
 
                fi
-       fi      
+       fi
+
+       # auto bonds
+       if [ "$ab" = "1" ]; then
+               ((tmp=anr+1))
+               line="`sed -n ${tmp}p $file`"
+               aX=`echo $line | awk '{ print $2 }'`
+               aY=`echo $line | awk '{ print $3 }'`
+               aZ=`echo $line | awk '{ print $4 }'`
+               export aX aY aZ cutoff mirror
+               cat $file | grep -v '#' | awk '\
+               BEGIN {
+                       x=ENVIRON["aX"]; y=ENVIRON["aY"]; z=ENVIRON["aZ"];
+                       co=ENVIRON["cutoff"]; dist=0; bcr=ENVIRON["bcr"];
+                       mx1=ENVIRON["mx1"]; my1=ENVIRON["my1"];
+                       mz1=ENVIRON["mz1"]; mx2=ENVIRON["mx2"];
+                       my2=ENVIRON["my2"]; mz2=ENVIRON["mz2"];
+                       mx3=ENVIRON["mx3"]; my3=ENVIRON["my3"];
+                       mz3=ENVIRON["mz3"]; mirror=ENVIRON["mirror"];
+               }
+               {
+                       dist=sqrt((x-$2)^2+(y-$3)^2+(z-$4)^2);
+                       if((dist<=co)&&(dist>0.01)) {
+                               print "cylinder {";
+                               print "<"x","z","y">,";
+                               print "<"$2","$4","$3">, "bcr;
+                               print "pigment { color Blue }";
+                               print "}";
+                       }
+
+                       if(mirror) {
+                               nx=$2-mx1; ny=$3-mx2; nz=$4-mx3;
+                               dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
+                               if((dist<=co)&&(dist>0.01)) {
+                                       print "cylinder {";
+                                       print "<"x","z","y">,";
+                                       print "<"nx","nz","ny">, "bcr;
+                                       print "pigment { color Blue }";
+                                       print "}";
+                               }
+                               nx=$2-my1; ny=$3-my2; nz=$4-my3;
+                               dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
+                               if((dist<=co)&&(dist>0.01)) {
+                                       print "cylinder {";
+                                       print "<"x","z","y">,";
+                                       print "<"nx","nz","ny">, "bcr;
+                                       print "pigment { color Blue }";
+                                       print "}";
+                               }
+                               nx=$2-mz1; ny=$3-mz2; nz=$4-mz3;
+                               dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
+                               if((dist<=co)&&(dist>0.01)) {
+                                       print "cylinder {";
+                                       print "<"x","z","y">,";
+                                       print "<"nx","nz","ny">, "bcr;
+                                       print "pigment { color Blue }";
+                                       print "}";
+                               }
+                       }
+
+               }' >> temp.pov
+       fi
 
        # add camera and light source
        cat >> temp.pov <<-EOF