t_atom *atom;
double *aslot,*bslot,*cslot;
- int acnt,bcnt,ccnt,cnt,count,slots;
+ int cnt,count,fcnt,slots;
int fd;
char buf[256],*wptr;
int i,j,k;
double dx2,dy2,dz2,dist,norm;
double sx,sy,sz;
- if(argc!=5) {
- printf("usage: %s file sx sy sz\n",argv[0]);
+ atom=NULL;
+
+ if(argc<5) {
+ printf("usage: %s sx sy sz file1 file2 ...\n",argv[0]);
return -1;
}
- fd=open(argv[1],O_RDONLY);
+ sx=atof(argv[1]);
+ sy=atof(argv[2]);
+ sz=atof(argv[3]);
+
+ // prepare pc
+
+ slots=MAXR/DELTA;
+ aslot=malloc(slots*sizeof(double));
+ if(aslot==NULL) {
+ perror("slot a\n");
+ return -1;
+ }
+ memset(aslot,0,slots*sizeof(double));
+ bslot=malloc(slots*sizeof(double));
+ if(bslot==NULL) {
+ perror("slot a\n");
+ return -1;
+ }
+ memset(bslot,0,slots*sizeof(double));
+ cslot=malloc(slots*sizeof(double));
+ if(cslot==NULL) {
+ perror("slot a\n");
+ return -1;
+ }
+ memset(cslot,0,slots*sizeof(double));
+
+ printf("i: allocated 3 times %d slots ...\n",slots);
+
+ // use all given files ...
+ printf("using files:\n");
+ for(fcnt=4;fcnt<argc;fcnt++)
+ printf(" %d: %s\n",fcnt-4,argv[fcnt]);
+
+ for(fcnt=4;fcnt<argc;fcnt++) {
+
+ fd=open(argv[fcnt],O_RDONLY);
if(fd<0) {
perror("open file\n");
return fd;
}
- sx=atof(argv[2]);
- sy=atof(argv[3]);
- sz=atof(argv[4]);
-
// first line
cnt=get_line(fd,buf,256);
printf("i: read in %d atoms ...\n",count);
- // prepare pc
-
- slots=MAXR/DELTA;
- aslot=malloc(slots*sizeof(double));
- if(aslot==NULL) {
- perror("slot a\n");
- return -1;
- }
- memset(aslot,0,slots*sizeof(double));
- bslot=malloc(slots*sizeof(double));
- if(bslot==NULL) {
- perror("slot a\n");
- return -1;
- }
- memset(bslot,0,slots*sizeof(double));
- cslot=malloc(slots*sizeof(double));
- if(cslot==NULL) {
- perror("slot a\n");
- return -1;
- }
- memset(cslot,0,slots*sizeof(double));
-
- printf("i: allocated 3 times %d slots ...\n",slots);
-
- acnt=0;
- bcnt=0;
- ccnt=0;
-
// calc pc
for(i=0;i<count;i++) {
k=dist/DELTA;
if((atom[i].type=='S')&&(atom[j].type=='S')) {
aslot[k]+=1;
- acnt+=1;
}
else if((atom[i].type=='C')&&(atom[j].type=='C')) {
bslot[k]+=1;
- bcnt+=1;
}
else {
cslot[k]+=1;
- ccnt+=1;
}
}
}
+ close(fd);
+ }
+
// normalization and output
for(i=1;i<slots;i++) {
free(atom);
- close(fd);
-
return 0;
}
exit
fi
-if [ ! -f $1/OUTCAR ]; then
+app=""
+if [ ! -z $2 ]; then
+ app=".${2}"
+fi
+
+if [ ! -f $1/OUTCAR${app} ]; then
echo "no vasp data found in $1 ..."
exit
fi
-if [ ! -d $1/video ]; then
+if [ ! -d $1/video${app} ]; then
echo "no video directory found ..."
echo "forgot to run outcar2moldyn?"
exit
echo "WARNING !!!!"
echo
-line=`sed -n -e '/length of/,/FORCES/p' $1/OUTCAR | grep ^\ \ \ | tail -1`
+line=`sed -n -e '/length of/,/FORCES/p' $1/OUTCAR${app} | \
+ grep ^\ \ \ | tail -1`
sx=`echo $line | awk '{ print $1 }'`
sy=`echo $line | awk '{ print $2 }'`
sz=`echo $line | awk '{ print $3 }'`
-file=`ls $1/video/atomic_conf*.xyz | tail -1`
+if [ -z $2 ] ; then
+ files=`ls $1/video/atomic_conf*.xyz | tail -1`
+else
+ files=`ls $1/video${app}/atomic_conf*.xyz`
+fi
-echo "running on $file using $sx $sy $sz ..."
+echo "running on $files using $sx $sy $sz ..."
-./pc_calc $file $sx $sy $sz | grep ^pc | \
+#./pc_calc $sx $sy $sz $files
+./pc_calc $sx $sy $sz $files | grep ^pc | \
awk '{ print $2 " " $3 " " $4 " "$5 }' > pc.txt
echo "done"