From: hackbard Date: Tue, 6 Oct 2009 10:45:26 +0000 (+0200) Subject: pc calc hopefully corrected now X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=facb6c3b0ab8d6a6dc1c9e15298fb2ec5e0317f5;p=physik%2Fposic.git pc calc hopefully corrected now --- diff --git a/vasp_tools/pc_calc.c b/vasp_tools/pc_calc.c index f37506f..db12f50 100644 --- a/vasp_tools/pc_calc.c +++ b/vasp_tools/pc_calc.c @@ -43,30 +43,76 @@ int get_line(int fd,char *line,int max) { } } +int get_max3_vals(char *buf,int amount,double *v1, double *v2,double *v3) { + + int i,j,k; + char temp[128]; + + i=0; + + for(k=0;k scale + cnt=get_line(fd,buf,256); + get_max3_vals(buf,1,&scale,NULL,NULL); + printf("scale: %f\n",scale); + + // third line -> X + cnt=get_line(fd,buf,256); + get_max3_vals(buf,3,&X1,&X2,&X3); + printf("X: %f %f %f\n",X1,X2,X3); + + // 4th line -> Y + cnt=get_line(fd,buf,256); + get_max3_vals(buf,3,&Y1,&Y2,&Y3); + printf("Y: %f %f %f\n",Y1,Y2,Y3); + + // 5th line -> Z + cnt=get_line(fd,buf,256); + get_max3_vals(buf,3,&Z1,&Z2,&Z3); + printf("Z: %f %f %f\n",Z1,Z2,Z3); + + // 6th line -> nsi + nc = ntot + cnt=get_line(fd,buf,256); + get_2_ints(buf,&nsi,&nc); + ntot=nsi+nc; + printf("Si: %d - C: %d - tot: %d\n",nsi,nc,ntot); + + // 7th line + cnt=get_line(fd,buf,256); + + // 8th line + cnt=get_line(fd,buf,256); + // read in atoms count=0; - while(1) { + while(countsx/2.0) - dx2-=sx; - else if(dx2<-sx/2.0) - dx2+=sx; - dx2*=dx2; - dy2=atom[i].y-atom[j].y; - if(dy2>sy/2.0) - dy2-=sy; - else if(dy2<-sy/2.0) - dy2+=sy; - dy2*=dy2; - dz2=atom[i].z-atom[j].z; - if(dz2>sz/2.0) - dz2-=sz; - else if(dz2<-sz/2.0) - dz2+=sz; - dz2*=dz2; - dist=sqrt(dx2+dy2+dz2); + dx=atom[i].x-atom[j].x; + if(dx>0.5) + dx-=1; + else if(dx<-0.5) + dx+=1; + + dy=atom[i].y-atom[j].y; + if(dy>0.5) + dy-=1; + else if(dy<-0.5) + dy+=1; + + dz=atom[i].z-atom[j].z; + if(dz>0.5) + dz-=1; + else if(dz<-0.5) + dz+=1; + + dxt=dx*X1+dy*Y1+dz*Z1; + dyt=dx*X2+dy*Y2+dz*Z2; + dzt=dx*X3+dy*Y3+dz*Z3; + + dist=sqrt(dxt*dxt+dyt*dyt+dzt*dzt); + dist*=scale; + if(dist>=MAXR) continue; k=dist/DELTA; @@ -168,13 +250,14 @@ int main(int argc,char **argv) { } } - close(fd); + close(fd); + } // normalization and output - for(i=1;i