From: hackbard Date: Tue, 12 Dec 2006 15:58:40 +0000 (+0000) Subject: check_per_bound, comparing real numbers <- problem! think about it! X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7493af81c40106bd17811b67c6421eff7697e4ab;p=physik%2Fposic.git check_per_bound, comparing real numbers <- problem! think about it! --- diff --git a/moldyn.c b/moldyn.c index aaab0de..44b53b6 100644 --- a/moldyn.c +++ b/moldyn.c @@ -236,10 +236,11 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, count=a*b*c; + /* how many atoms do we expect */ if(type==FCC) count*=4; - if(type==DIAMOND) count*=8; + /* allocate space for atoms */ moldyn->atom=malloc(count*sizeof(t_atom)); if(moldyn->atom==NULL) { perror("malloc (atoms)"); @@ -262,9 +263,10 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, /* debug */ if(ret!=count) { - printf("ok, there is something wrong ...\n"); - printf("calculated -> %d atoms\n",count); - printf("created -> %d atoms\n",ret); + printf("[moldyn] creating lattice failed\n"); + printf(" amount of atoms\n"); + printf(" - expected: %d\n",count); + printf(" - created: %d\n",ret); return -1; } @@ -280,7 +282,6 @@ int create_lattice(t_moldyn *moldyn,u8 type,double lc,int element,double mass, check_per_bound(moldyn,&(moldyn->atom[count].r)); } - return ret; } @@ -971,9 +972,9 @@ int check_per_bound(t_moldyn *moldyn,t_3dvec *a) { dim=&(moldyn->dim); - x=0.5*dim->x; - y=0.5*dim->y; - z=0.5*dim->z; + x=dim->x/2; + y=dim->y/2; + z=dim->z/2; if(moldyn->status&MOLDYN_STAT_PBX) { if(a->x>=x) a->x-=dim->x; @@ -987,6 +988,7 @@ int check_per_bound(t_moldyn *moldyn,t_3dvec *a) { if(a->z>=z) a->z-=dim->z; else if(-a->z>z) a->z+=dim->z; } +printf("%f %f %f\n",a->x,x,a->x/x); return 0; } @@ -1642,13 +1644,13 @@ int moldyn_bc_check(t_moldyn *moldyn) { for(i=0;icount;i++) { if(atom[i].r.x>=dim->x/2||-atom[i].r.x>dim->x/2) printf("FATAL: atom %d: x: %.20f (%.20f)\n", - i,atom[i].r.x*1e10,dim->x/2*1e10); + i,atom[i].r.x,dim->x/2); if(atom[i].r.y>=dim->y/2||-atom[i].r.y>dim->y/2) printf("FATAL: atom %d: y: %.20f (%.20f)\n", - i,atom[i].r.y*1e10,dim->y/2*1e10); + i,atom[i].r.y,dim->y/2); if(atom[i].r.z>=dim->z/2||-atom[i].r.z>dim->z/2) printf("FATAL: atom %d: z: %.20f (%.20f)\n", - i,atom[i].r.z*1e10,dim->z/2*1e10); + i,atom[i].r.z,dim->z/2); } return 0;