5 # author: frank.zirkelbach@physik.uni-augsburg.de
10 cat >> temp.pov <<-EOF
12 <$1, $3, $2>, <$4, $6, $5>, 0.05
13 pigment { color White }
18 cat >> temp.pov <<-EOF
20 <$1, $3, $2>, <$4, $6, $5>, $7
21 pigment { color Blue }
29 directory="doesnt_exist____for_sure"
33 x0="-0.6"; y0="-0.6"; z0="-0.6";
34 x1="0.6"; y1="0.6"; z1="0.6";
36 lx="0"; ly="-100"; lz="100";
38 bx0=""; by0=""; bz0="";
39 bx1=""; by1=""; bz1="";
41 clx="0"; cly="0"; clz="0";
54 -d) directory=$2; shift 2;;
55 -w) width=$2; shift 2;;
56 -h) height=$2; shift 2;;
57 -r) radius=$2; shift 2;;
58 -nll) x0=$2; y0=$3; z0=$4; shift 4;;
59 -fur) x1=$2; y1=$3; z1=$4; shift 4;;
60 -c) cx=$2; cy=$3; cz=$4; shift 4;;
61 -L) clx=$2; cly=$3; clz=$4; shift 4;;
62 -l) lx=$2; ly=$3; lz=$4; shift 4;;
63 -o) ortographic=1; shift 1;;
64 -b) bx0=$2; by0=$3; bz0=$4;
65 bx1=$5; by1=$6; bz1=$7; shift 7;;
68 -e) extra=1; shift 1;;
69 -D) displace=$2; shift 2;;
70 -m) mx1=$2; mx2=$3; mx3=$4;
71 my1=$5; my2=$6; my3=$7;
72 mz1=$8; mz2=$9; mz3=${10};
75 anr=$2; cutoff=$3; shift 3;;
79 echo "directory to progress:"
80 echo " -d <directory> (mandatory)"
86 echo " -B <bond cylinder radius>"
88 echo " -C <lattice constant>"
89 echo " -m <dimX> <dimY> <dimZ> (mirror atoms)"
90 echo "visualization volume:"
91 echo " -nll <x> <y> <z> (near lower left)"
92 echo " -fur <x> <y> <z> (far upper right)"
93 echo " -o (ortographic)"
95 echo " -b <x0> <y0> <z0> <x1> <y1> <z1>"
97 echo " -c <x> <y> <z> (camera position)"
98 echo " -L <x> <y> <z> (camera look)"
99 echo " -l <x> <y> <z> (light source)"
101 echo " -ab <atom number> <cutoff> (auto bonds)"
106 # calculation from lattic eunits to angstroms
108 [ "$lc" = "sic" ] && lc=4.359
109 [ "$lc" = "si" ] && lc=5.480
110 [ "$lc" = "c" ] && lc=3.566
112 #offset=`echo 0.125 \* $lc | bc`
115 x0=`echo $x0 \* $lc + $offset | bc`
116 y0=`echo $y0 \* $lc + $offset | bc`
117 z0=`echo $z0 \* $lc + $offset | bc`
118 x1=`echo $x1 \* $lc + $offset | bc`
119 y1=`echo $y1 \* $lc + $offset | bc`
120 z1=`echo $z1 \* $lc + $offset | bc`
122 mx1=`echo $mx1 \* $lc + $offset | bc`
123 my1=`echo $my1 \* $lc + $offset | bc`
124 mz1=`echo $mz1 \* $lc + $offset | bc`
125 mx2=`echo $mx2 \* $lc + $offset | bc`
126 my2=`echo $my2 \* $lc + $offset | bc`
127 mz2=`echo $mz2 \* $lc + $offset | bc`
128 mx3=`echo $mx3 \* $lc + $offset | bc`
129 my3=`echo $my3 \* $lc + $offset | bc`
130 mz3=`echo $mz3 \* $lc + $offset | bc`
132 clx=`echo $clx \* $lc + $offset | bc`
133 cly=`echo $cly \* $lc + $offset | bc`
134 clz=`echo $clz \* $lc + $offset | bc`
136 if [ -n "$cx" -a -n "$cy" -a -n "$cz" ]; then
137 cx=`echo $cx \* $lc + $offset | bc`
138 cy=`echo $cy \* $lc + $offset | bc`
139 cz=`echo $cz \* $lc + $offset | bc`
142 if [ -n "$bx0" ]; then
143 bx0=`echo $bx0 \* $lc + $offset | bc`
144 by0=`echo $by0 \* $lc + $offset | bc`
145 bz0=`echo $bz0 \* $lc + $offset | bc`
146 bx1=`echo $bx1 \* $lc + $offset | bc`
147 by1=`echo $by1 \* $lc + $offset | bc`
148 bz1=`echo $bz1 \* $lc + $offset | bc`
153 POVRAY="povray -W${width} -H${height} -d"
157 COPTS="-font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
158 COPTS="$COPTS -depth 8 -fill white -stroke blue -pointsize 24"
162 if [ -d $directory ]; then
163 filesource=$directory/atomic_conf_*.xyz
166 if [ -f $directory ]; then
167 filesource=$directory
170 for file in $filesource; do
172 cat > temp.pov <<-EOF
173 #include "colors.inc"
174 #include "textures.inc"
175 #include "shapes.inc"
177 #include "metals.inc"
179 #include "stones.inc"
183 count=`grep '# \[P\]' $file | awk '{ print $3 }'`
184 time=`grep '# \[P\]' $file | awk '{ print $4 }'`
185 camloc=`grep '# \[P\]' $file | awk '{ print $5 }'`
186 [ -n "$cx" -a -n "$cy" -a -n "$cz" ] && camloc="<$cx,$cz,$cy>"
189 #echo "-----> $x0 $y0 $z0 $x1 $y1 $z1 <-----"
190 if [ -n "$x0" ]; then
191 export x0 y0 z0 x1 y1 z1 radius extra
196 cat $file | grep -v '#' | awk '\
198 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
199 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
200 mx1=ENVIRON["mx1"]; my1=ENVIRON["my1"];
201 mz1=ENVIRON["mz1"]; mx2=ENVIRON["mx2"];
202 my2=ENVIRON["my2"]; mz2=ENVIRON["mz2"];
203 mx3=ENVIRON["mx3"]; my3=ENVIRON["my3"];
204 mz3=ENVIRON["mz3"]; mirror=ENVIRON["mirror"];
205 radius=ENVIRON["radius"]; extra=ENVIRON["extra"];
209 if(($2>=x0)&&($3>=y0)&&($4>=z0)&&\
210 ($2<=x1)&&($3<=y1)&&($4<=z1)) {
211 print "sphere { <"$2","$4","$3">, "radius" ";
213 print "texture { pigment { color rgb<"$6/4.4",0,"1-$6/4.4"> } ";
215 print "texture { pigment { color "$5" } ";
216 print "finish { phong 1 metallic } } }";
221 nx=$2-mx1; ny=$3-mx2; nz=$4-mx3;
222 if((nx>=x0)&&(ny>=y0)&&(nz>=z0)&&\
223 (nx<=x1)&&(ny<=y1)&&(nz<=z1)) {
224 print "// translation: "$2/5.480" "$3/5.480" "$4/5.480" -> "nx/5.480" "ny/5.480" "nz/5.480" ...";
225 print "sphere { <"nx","nz","ny">, "radius" ";
227 print "texture { pigment { color rgb<"$6/4.4",0,"1-$6/4.4"> } ";
229 print "texture { pigment { color "$5" } ";
230 print "finish { phong 1 metallic } } }";
232 nx=$2-my1; ny=$3-my2; nz=$4-my3;
233 if((nx>=x0)&&(ny>=y0)&&(nz>=z0)&&\
234 (nx<=x1)&&(ny<=y1)&&(nz<=z1)) {
235 print "sphere { <"nx","nz","ny">, "radius" ";
237 print "texture { pigment { color rgb<"$6/4.4",0,"1-$6/4.4"> } ";
239 print "texture { pigment { color "$5" } ";
240 print "finish { phong 1 metallic } } }";
242 nx=$2-mz1; ny=$3-mz2; nz=$4-mz3;
243 if((nx>=x0)&&(ny>=y0)&&(nz>=z0)&&\
244 (nx<=x1)&&(ny<=y1)&&(nz<=z1)) {
245 print "sphere { <"nx","nz","ny">, "radius" ";
247 print "texture { pigment { color rgb<"$6/4.4",0,"1-$6/4.4"> } ";
249 print "texture { pigment { color "$5" } ";
250 print "finish { phong 1 metallic } } }";
257 cat $file | grep -v '#' | while read name x y z color temp; do
258 cat >> temp.pov <<-EOF
260 <$x, $z, $y>, $radius
262 pigment { color $color }
274 if [ -z "$bx0" ]; then
276 #if [ -z "$x0" ]; then
278 cat $file | grep '# \[D\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do
279 draw_cyl $x1 $y1 $z1 $x2 $y2 $z2 0.05
284 # manually drawing the 3x4 boundaries ...
285 # draw_cyl $x0 $y0 $z0 $x1 $y0 $z0
286 # draw_cyl $x0 $y0 $z0 $x0 $y1 $z0
287 # draw_cyl $x1 $y1 $z0 $x1 $y0 $z0
288 # draw_cyl $x0 $y1 $z0 $x1 $y1 $z0
290 # draw_cyl $x0 $y0 $z1 $x1 $y0 $z1
291 # draw_cyl $x0 $y0 $z1 $x0 $y1 $z1
292 # draw_cyl $x1 $y1 $z1 $x1 $y0 $z1
293 # draw_cyl $x0 $y1 $z1 $x1 $y1 $z1
295 # draw_cyl $x0 $y0 $z1 $x0 $y0 $z0
296 # draw_cyl $x0 $y1 $z1 $x0 $y1 $z0
297 # draw_cyl $x1 $y0 $z1 $x1 $y0 $z0
298 # draw_cyl $x1 $y1 $z1 $x1 $y1 $z0
303 # manually drawing the 3x4 boundaries specified by argv ...
304 draw_cyl $bx0 $by0 $bz0 $bx1 $by0 $bz0
305 draw_cyl $bx0 $by0 $bz0 $bx0 $by1 $bz0
306 draw_cyl $bx1 $by1 $bz0 $bx1 $by0 $bz0
307 draw_cyl $bx0 $by1 $bz0 $bx1 $by1 $bz0
309 draw_cyl $bx0 $by0 $bz1 $bx1 $by0 $bz1
310 draw_cyl $bx0 $by0 $bz1 $bx0 $by1 $bz1
311 draw_cyl $bx1 $by1 $bz1 $bx1 $by0 $bz1
312 draw_cyl $bx0 $by1 $bz1 $bx1 $by1 $bz1
314 draw_cyl $bx0 $by0 $bz1 $bx0 $by0 $bz0
315 draw_cyl $bx0 $by1 $bz1 $bx0 $by1 $bz0
316 draw_cyl $bx1 $by0 $bz1 $bx1 $by0 $bz0
317 draw_cyl $bx1 $by1 $bz1 $bx1 $by1 $bz0
322 if [ -n "$bcr" ]; then
324 if [ -z "$x0" ]; then
326 cat $file | grep '# \[B\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do
327 draw_bond $x1 $z1 $y1 $x2 $z2 $y2 $bcr
332 export x0 y0 z0 x1 y1 z1 bcr
333 cat $file | grep '# \[B\]' | awk '\
335 x0=ENVIRON["x0"]; y0=ENVIRON["y0"]; z0=ENVIRON["z0"];
336 x1=ENVIRON["x1"]; y1=ENVIRON["y1"]; z1=ENVIRON["z1"];
340 if(($3>=x0)&&($4>=y0)&&($5>=z0)&&\
341 ($3<=x1)&&($4<=y1)&&($5<=z1)) {
343 print "<"$3","$5","$4">,";
344 print "<"$6","$8","$7">, "bcr;
345 print "pigment { color Blue }";
354 if [ "$ab" = "1" ]; then
356 line="`sed -n ${tmp}p $file`"
357 aX=`echo $line | awk '{ print $2 }'`
358 aY=`echo $line | awk '{ print $3 }'`
359 aZ=`echo $line | awk '{ print $4 }'`
360 export aX aY aZ cutoff mirror
361 cat $file | grep -v '#' | awk '\
363 x=ENVIRON["aX"]; y=ENVIRON["aY"]; z=ENVIRON["aZ"];
364 co=ENVIRON["cutoff"]; dist=0; bcr=ENVIRON["bcr"];
365 mx1=ENVIRON["mx1"]; my1=ENVIRON["my1"];
366 mz1=ENVIRON["mz1"]; mx2=ENVIRON["mx2"];
367 my2=ENVIRON["my2"]; mz2=ENVIRON["mz2"];
368 mx3=ENVIRON["mx3"]; my3=ENVIRON["my3"];
369 mz3=ENVIRON["mz3"]; mirror=ENVIRON["mirror"];
372 dist=sqrt((x-$2)^2+(y-$3)^2+(z-$4)^2);
373 if((dist<=co)&&(dist>0.01)) {
375 print "<"x","z","y">,";
376 print "<"$2","$4","$3">, "bcr;
377 print "pigment { color Blue }";
382 nx=$2-mx1; ny=$3-mx2; nz=$4-mx3;
383 dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
384 if((dist<=co)&&(dist>0.01)) {
386 print "<"x","z","y">,";
387 print "<"nx","nz","ny">, "bcr;
388 print "pigment { color Blue }";
391 nx=$2-my1; ny=$3-my2; nz=$4-my3;
392 dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
393 if((dist<=co)&&(dist>0.01)) {
395 print "<"x","z","y">,";
396 print "<"nx","nz","ny">, "bcr;
397 print "pigment { color Blue }";
400 nx=$2-mz1; ny=$3-mz2; nz=$4-mz3;
401 dist=sqrt((x-nx)^2+(y-ny)^2+(z-nz)^2)
402 if((dist<=co)&&(dist>0.01)) {
404 print "<"x","z","y">,";
405 print "<"nx","nz","ny">, "bcr;
406 print "pigment { color Blue }";
414 # add camera and light source
415 cat >> temp.pov <<-EOF
418 if [ -n "$ortographic" ]; then cat >> temp.pov <<-EOF
422 cat >> temp.pov <<-EOF
424 look_at <$clx,$clz,$clz>
426 light_source { <0,100,-100> color White shadowless }
430 $POVRAY temp.pov > /dev/null 2>&1
431 time=`basename $file | awk -F. '{ print $1 }' | awk -F_ '{ print $3 }'`
432 if [ ! -z $displace ]; then
433 convert $COPTS -draw "text 5,20 'd = $displace %'" temp.png temp.png
435 convert $COPTS -draw "text 5,20 't = $time fs'" temp.png temp.png
437 mv temp.png `echo $file | sed 's/\.xyz/\.png/'`