]> hackdaworld.org Git - physik/posic.git/commitdiff
check_per_bound, comparing real numbers <- problem! think about it!
authorhackbard <hackbard>
Tue, 12 Dec 2006 15:58:40 +0000 (15:58 +0000)
committerhackbard <hackbard>
Tue, 12 Dec 2006 15:58:40 +0000 (15:58 +0000)
moldyn.c

index aaab0deb5270c0157ebcbc4a07e58ddd12bf0943..44b53b60b76324f441ad7c5492f942ebbd4c3195 100644 (file)
--- 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;i<moldyn->count;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;