From: hackbard Date: Thu, 2 Aug 2007 17:07:29 +0000 (+0200) Subject: sualization mods + adabtions X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=863fae26146496ac4bc3bc6c95cbffff7bb6eca2;p=physik%2Fposic.git sualization mods + adabtions --- diff --git a/run b/run index 6e120d7..c7d454c 100755 --- a/run +++ b/run @@ -4,7 +4,7 @@ if [ "$?" == "0" ]; then #./perms if [ "$1" ] ; then - ./visualize $1 + ./visualize -d $1 #rasmol -32 -nodisplay < $1/visualize.scr > /dev/null 2>&1 ./ppm2avi $1 fi diff --git a/sic.c b/sic.c index 1f9bbbe..bf33e16 100644 --- a/sic.c +++ b/sic.c @@ -25,7 +25,9 @@ #define NR_ATOMS 1 #define R_C 1.0 #define T_C 10.0 -#define LCNT 3 +#define LCNT 5 +#define PRERUN 200 +#define POSTRUN 500 typedef struct s_hp { int a_count; /* atom count */ @@ -58,7 +60,7 @@ int hook(void *moldyn,void *hook_params) { /* last schedule add if there is enough carbon inside */ if(hp->a_count==(INJECT*NR_ATOMS)) { hp->quit=1; - moldyn_add_schedule(md,5000,1.0); + moldyn_add_schedule(md,POSTRUN,1.0); return 0; } @@ -74,12 +76,17 @@ int hook(void *moldyn,void *hook_params) { for(j=0;jrandom))-0.5)*md->dim.x*0.37; r.y=(rand_get_double(&(md->random))-0.5)*md->dim.y*0.37; r.z=(rand_get_double(&(md->random))-0.5)*md->dim.z*0.37; - //r.x=(1.0*atoi(hp->argv[3])-4.5)/9.0*ALBE_LC_SI; - //r.y=(1.0*atoi(hp->argv[4])-4.5)/9.0*ALBE_LC_SI; - //r.z=(1.0*atoi(hp->argv[5])-4.5)/9.0*ALBE_LC_SI; + r.x=(1.0*atoi(hp->argv[3])-4.5)/9.0*ALBE_LC_SI; + r.y=(1.0*atoi(hp->argv[4])-4.5)/9.0*ALBE_LC_SI; + r.z=(1.0*atoi(hp->argv[5])-4.5)/9.0*ALBE_LC_SI; + */ + r.x=(rand_get_double(&(md->random))-0.5)*LC_SI; + r.y=(rand_get_double(&(md->random))-0.5)*LC_SI; + r.z=(rand_get_double(&(md->random))-0.5)*LC_SI; /* assume valid coordinates */ run=0; for(i=0;icount;i++) { @@ -124,9 +131,6 @@ int main(int argc,char **argv) { t_tersoff_mult_params tp; t_albe_mult_params ap; - /* atom injection counter */ - int inject; - /* testing location & velocity vector */ t_3dvec r,v; memset(&r,0,sizeof(t_3dvec)); @@ -330,7 +334,7 @@ int main(int argc,char **argv) { set_pressure(&md,BAR); /* set amount of steps to skip before average calc */ - set_avg_skip(&md,1000); + set_avg_skip(&md,PRERUN); /* set p/t scaling */ //set_pt_scale(&md,0,0,T_SCALE_BERENDSEN,100.0); @@ -343,17 +347,7 @@ int main(int argc,char **argv) { thermal_init(&md,TRUE); /* create the simulation schedule */ - moldyn_add_schedule(&md,1000,1.0); - //moldyn_add_schedule(&md,1000,1.0); - //moldyn_add_schedule(&md,1000,1.0); - //moldyn_add_schedule(&md,1000,1.0); - //moldyn_add_schedule(&md,1000,1.0); - //moldyn_add_schedule(&md,1000,1.0); - /* adding atoms */ - //for(inject=0;injectfb,filebase,128); memset(file,0,128+8); - sprintf(file,"%s/visualize.scr",v->fb); + //sprintf(file,"%s/visualize.scr",v->fb); // obsolete! + /* obsolete! v->fd=open(file,O_WRONLY|O_CREAT|O_EXCL,S_IRUSR|S_IWUSR); if(v->fd<0) { perror("open visual fd"); return -1; } dprintf(v->fd,"set write on\n"); + */ return 0; } int visual_tini(t_visual *v) { + /* obsolete! if(v->fd) { dprintf(v->fd,"quit\n"); close(v->fd); } + */ return 0; } @@ -73,13 +99,15 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { int i,fd; char file[128+64]; t_3dvec dim; + double help; dim.x=v->dim.x; dim.y=v->dim.y; dim.z=v->dim.z; - //sprintf(file,"%s/visualize_%07.f.xyz",v->fb,time); - sprintf(file,"%s/povray_%07.f.in",v->fb,time); + help=(dim.x+dim.y); + + sprintf(file,"%s/atomic_conf_%07.f.xyz",v->fb,time); fd=open(file,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR); if(fd<0) { perror("open visual save file fd"); @@ -87,6 +115,7 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { } /* script file update */ + /* obsolete! dprintf(v->fd,"load xyz %s\n",file); dprintf(v->fd,"spacefill 200\n"); dprintf(v->fd,"rotate x 100\n"); @@ -98,17 +127,19 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { sprintf(file,"%s/visualize_%07.f.ppm",v->fb,time); dprintf(v->fd,"write ppm %s\n",file); dprintf(v->fd,"zap\n"); + */ /* write the actual data file */ //dprintf(fd,"%d\n",(dim.x==0)?n:n+8); - dprintf(fd,"# [C] %d\n",n); - dprintf(fd,"# [T] %07.f\n",time); - dprintf(fd,"# [L] <%f,%f,%f>\n",-1.0*dim.x/4.0, - 1.5*dim.y,1.5*dim.z); + dprintf(fd,"# [P] %d %07.f <%f,%f,%f>\n", + n,time,help/40.0,help/40.0,-0.8*help); for(i=0;i $1" - exit +# +# visualization script +# author: frank.zirkelbach@physik.uni-augsburg.de +# + +directory="doesnt_exist____for_sure" +width="1024" +height="768" +radius="1.0" +x0=""; y0=""; z0=""; +x1=""; y1=""; z1=""; +cx=""; cy=""; cz=""; +lx="0"; ly="-100"; lz="100"; + +while [ "$1" ]; do + case "$1" in + -d) directory=$2; shift 2;; + -w) width=$2; shift 2;; + -h) height=$2; shift 2;; + -r) radius=$2; shift 2;; + -nll) x0=$2; y0=$3; z0=$4; shift 4;; + -fur) x1=$2; y1=$3; z1=$4; shift 4;; + -c) cx=$2; cy=$3; cz=$4; shift 4;; + -l) lx=$2; ly=$3; lz=$4; shift 4;; + -o) ortographic=1; shift 1;; + *) + echo "options:" + echo "########" + echo "directory to progress:" + echo " -d (mandatory)" + echo "png dim:" + echo " -w " + echo " -h " + echo "atom size:" + echo " -r " + echo "visualization volume:" + echo " -nll (near lower left)" + echo " -fur (far upper right)" + echo " -o (ortographic)" + echo "povray:" + echo " -c (camera position)" + echo " -l (light source)" + exit 1;; + esac +done + +if [ ! -d $directory ] ; then + echo "no valid directory" + exit 1 fi -POVRAY="povray -W1024 -H768 -d" +POVRAY="povray -W${width} -H${height} -d" -echo "processing $1 ..." +for file in $directory/atomic_conf_*.xyz; do -for file in $1/povray_*.in ; do cat > temp.pov <<-EOF #include "colors.inc" #include "textures.inc" @@ -21,49 +66,75 @@ for file in $1/povray_*.in ; do EOF # meta info - count=`grep '# \[C\]' $file | awk '{ print $3 }'` - time=`grep '# \[T\]' $file | awk '{ print $3 }'` - camloc=`grep '# \[L\]' $file | awk '{ print $3 }'` + count=`grep '# \[P\]' $file | awk '{ print $3 }'` + time=`grep '# \[P\]' $file | awk '{ print $4 }'` + camloc=`grep '# \[P\]' $file | awk '{ print $5 }'` + [ -n "$cx" -a -n "$cy" -a -n "$cz" ] && camloc="<$cx,$cz,$cy>" # atoms - cat $file | grep -v '#' | while read radius x y z ; do #temp dis; do - cat >> temp.pov <<-EOF + if [ -n "$x0" ]; then + export x0 y0 z0 x1 y1 z1 radius + cat $file | grep -v '#' | awk '\ + BEGIN { + x0=ENVIRON["x0"]; y0==ENVIRON["y0"]; z0==ENVIRON["z0"]; + x1=ENVIRON["x1"]; y0==ENVIRON["y1"]; z0==ENVIRON["z1"]; + radius=ENVIRON["radius"]; + } + { + if(($2>=x0)&&($3>=y0)&&($4>=z0)&&\ + ($2<=x1)&&($3<=y1)&&($4<=z1)) { + print "sphere { <"$2","$4","$3">, "radius" "; + print "texture { pigment { color "$5" } "; + print "finish { phong 1, metallic } } }"; + } + }' >> temp.pov + else + cat $file | grep -v '#' | while read name x y z color temp; do + cat >> temp.pov <<-EOF sphere { - <$x, $z, $y>, $radius - texture { - pigment { color Yellow } - finish { - phong 1 - metallic - } - } +<$x, $z, $y>, $radius +texture { +pigment { color $color } +finish { +phong 1 +metallic +} +} } EOF - done + done + fi # boundaries + if [ -z "$x0" ]; then cat $file | grep '# \[D\]' | while read foo bar x1 y1 z1 x2 y2 z2 ; do cat >> temp.pov <<-EOF cylinder { - <$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05 - pigment { color White } +<$x1, $z1, $y1>, <$x2, $z2, $y2>, 0.05 +pigment { color White } } EOF done + fi # add camera and light source cat >> temp.pov <<-EOF camera { -// orthographic - location $camloc - look_at <0,0,0> +EOF + if [ -n "$ortographic" ]; then cat >> temp.pov <<-EOF +orthographic +EOF + fi + cat >> temp.pov <<-EOF +location $camloc +look_at <0,0,0> } -light_source { <0,10000,0> color White shadowless } +light_source { <0,100,-100> color White shadowless } EOF # mv png $POVRAY temp.pov > /dev/null 2>&1 - mv temp.png `echo $file | sed 's/\.in/\.png/'` + mv temp.png `echo $file | sed 's/\.xyz/\.png/'` done