]> hackdaworld.org Git - physik/posic.git/commitdiff
fixed (dank rolf)
authorhackbard <hackbard>
Fri, 12 May 2006 14:58:57 +0000 (14:58 +0000)
committerhackbard <hackbard>
Fri, 12 May 2006 14:58:57 +0000 (14:58 +0000)
Makefile
moldyn.c
posic.c
run
visual/visual.h

index 6539f22a09f5062ce0f09574723c2a74e0c4f1b8..7096b48dd563331d868dbaf47ced35742f0eb065 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-Wall
+CFLAGS=-Wall -DSIMPLE_TESTING
 LDFLAGS=-lm
 
 OBJS=init/init.o visual/visual.o math/math.o random/random.o list/list.o
index 6e76bc0c5be072ad40f4fbe88b90fae57adb594a..707fe032e2e51f87a13800e717f33a461f5e85b7 100644 (file)
--- a/moldyn.c
+++ b/moldyn.c
@@ -456,8 +456,8 @@ int link_cell_init(t_moldyn *moldyn) {
        printf("initializing linked cells (%d)\n",lc->cells);
 
        for(i=0;i<lc->cells;i++)
-               //list_init(&(lc->subcell[i]),1);
-               list_init(&(lc->subcell[i]),lc->listfd);
+               list_init(&(lc->subcell[i]),1);
+               //list_init(&(lc->subcell[i]),lc->listfd);
 
        link_cell_update(moldyn);
        
@@ -478,13 +478,13 @@ int link_cell_update(t_moldyn *moldyn) {
        ny=lc->ny;
        nz=lc->nz;
 
-       for(i=0;i<nx*ny*nz;i++)
+       for(i=0;i<lc->cells;i++)
                list_destroy(&(moldyn->lc.subcell[i]));
        
        for(count=0;count<moldyn->count;count++) {
-               i=atom[count].r.x/lc->x;
-               j=atom[count].r.y/lc->y;
-               k=atom[count].r.z/lc->z;
+               i=(atom[count].r.x+(moldyn->dim.x/2))/lc->x;
+               j=(atom[count].r.y+(moldyn->dim.y/2))/lc->y;
+               k=(atom[count].r.z+(moldyn->dim.z/2))/lc->z;
                list_add_immediate_ptr(&(moldyn->lc.subcell[i+j*nx+k*nx*ny]),
                                       &(atom[count]));
        }
@@ -510,7 +510,9 @@ int link_cell_neighbour_index(t_moldyn *moldyn,int i,int j,int k,t_list *cell) {
        count2=27;
        a=nx*ny;
 
+
        cell[0]=lc->subcell[i+j*nx+k*a];
+       printf("%d\n",i+j*nx+k*a);
        for(ci=-1;ci<=1;ci++) {
                bx=0;
                x=i+ci;
@@ -532,12 +534,17 @@ int link_cell_neighbour_index(t_moldyn *moldyn,int i,int j,int k,t_list *cell) {
                                        z=(z+nz)%nz;
                                        bz=1;
                                }
-                               if(!(x|y|z)) continue;
+                               if(!(ci|cj|ck)) continue;
+                               printf(" %d %d %d \n",x,y,z);
                                if(bx|by|bz) {
                                        cell[--count2]=lc->subcell[x+y*nx+z*a];
+                                       printf("%d\n",x+y*nx+z*a);
+                                       printf("--- %d\n",count2);
                                }
                                else {
                                        cell[count1++]=lc->subcell[x+y*nx+z*a];
+                                       printf("%d\n",x+y*nx+z*a);
+                                       printf("--- %d\n",count1);
                                }
                        }
                }
@@ -598,8 +605,6 @@ int moldyn_integrate(t_moldyn *moldyn) {
        moldyn->potential_force_function(moldyn);
 
        for(i=0;i<moldyn->time_steps;i++) {
-               /* show runs */
-               printf(".");
 
                /* neighbour list update */
                link_cell_update(moldyn);
@@ -642,9 +647,12 @@ int moldyn_integrate(t_moldyn *moldyn) {
 
                }
                if(v) {
-                       if(!(i%v))
+                       if(!(i%v)) {
                                visual_atoms(moldyn->visual,i*moldyn->tau,
                                             moldyn->atom,moldyn->count);
+                               printf("\rsteps: %d",i);
+                               fflush(stdout);
+                       }
                }
        }
 
@@ -722,9 +730,10 @@ int harmonic_oscillator(t_moldyn *moldyn) {
        u=0.0;
        for(i=0;i<count;i++) {
                /* determine cell + neighbours */
-               ni=atom[i].r.x/lc->x;
-               nj=atom[i].r.y/lc->y;
-               nk=atom[i].r.z/lc->z;
+               ni=(atom[i].r.x+(moldyn->dim.x/2))/lc->x;
+               nj=(atom[i].r.y+(moldyn->dim.y/2))/lc->y;
+               nk=(atom[i].r.z+(moldyn->dim.z/2))/lc->z;
+               printf("%d %d %d\n",ni,nj,nk);
                c=link_cell_neighbour_index(moldyn,ni,nj,nk,neighbour);
 
                /* processing cell of atom i */
@@ -818,10 +827,15 @@ int lennard_jones(t_moldyn *moldyn) {
        u=0.0;
        for(i=0;i<count;i++) {
                /* determine cell + neighbours */
-               ni=atom[i].r.x/lc->x;
-               nj=atom[i].r.y/lc->y;
-               nk=atom[i].r.z/lc->z;
+               ni=(atom[i].r.x+(moldyn->dim.x/2))/lc->x;
+               nj=(atom[i].r.y+(moldyn->dim.y/2))/lc->y;
+               nk=(atom[i].r.z+(moldyn->dim.z/2))/lc->z;
+                       printf("hier atom = %08x\n",&(atom[i]));
                c=link_cell_neighbour_index(moldyn,ni,nj,nk,neighbour);
+                       printf("da atom = %08x\n",&(atom[i]));
+                       printf("da atom = %08x\n",&(moldyn->atom[i]));
+
+               printf("c = %d (%d %d %d)\n",c,ni,nj,nk);
 
                /* processing cell of atom i */
                this=&(neighbour[0]);
@@ -830,7 +844,9 @@ int lennard_jones(t_moldyn *moldyn) {
                        btom=this->current->data;
                        if(btom==&(atom[i]))
                                continue;
+               puts("foo");
                        v3_sub(&distance,&(atom[i].r),&(btom->r));
+               puts("foo");
                        d=1.0/v3_absolute_square(&distance); /* 1/r^2 */
                        h1=d*d;         /* 1/r^4 */
                        h2*=d;          /* 1/r^6 */
@@ -844,6 +860,7 @@ int lennard_jones(t_moldyn *moldyn) {
                        d*=eps;
                        v3_scale(&force,&distance,d);
                        v3_add(&(atom[i].f),&(atom[i].f),&force);
+                       printf("test!!\n");
                } while(list_next(this)!=L_NO_NEXT_ELEMENT);
 
                /* neighbours not doing boundary condition overflow */
@@ -853,6 +870,7 @@ int lennard_jones(t_moldyn *moldyn) {
                        if(this->start!=NULL) {
 
                        do {
+                               printf("in bound: %d\n",j);
                                btom=this->current->data;
                                v3_sub(&distance,&(atom[i].r),&(btom->r));
                                d=v3_absolute_square(&distance); /* r^2 */
@@ -884,6 +902,7 @@ int lennard_jones(t_moldyn *moldyn) {
                        if(this->start!=NULL) {
 
                        do {
+                               printf("out bound: %d\n",j);
                                btom=this->current->data;
                                v3_sub(&distance,&(atom[i].r),&(btom->r));
                                v3_per_bound(&distance,&(moldyn->dim));
diff --git a/posic.c b/posic.c
index 2b18c79155caf6e2282eaf5bdb6101b6ffdb65d5..c185d16c7461df6f38d8cdd070be46ecaffa6a47 100644 (file)
--- a/posic.c
+++ b/posic.c
@@ -34,7 +34,8 @@ int main(int argc,char **argv) {
         * - random init
         *
         */
-       moldyn_init(&md,argc,argv);
+       a=moldyn_init(&md,argc,argv);
+       if(a<0) return a;
 
        /*
         * the following overrides possibly set interaction methods by argv !!
@@ -95,17 +96,17 @@ int main(int argc,char **argv) {
        printf("created silicon lattice (#atoms = %d)\n",md.count);
 #else
        md.count=2;
-       moldyn->atom=malloc(2*sizeof(t_atom));
-       moldyn->atom[0].r.x=0.13*sqrt(3.0)*LC_SI/2.0;
-       moldyn->atom[0].r.y=0;
-       moldyn->atom[0].r.z=0;
-       moldyn->atom[0].element=SI;
-       moldyn->atom[0].mass=M_SI;
-       moldyn->atom[1].r.x=-si[0].r.x;
-       moldyn->atom[1].r.y=0;
-       moldyn->atom[1].r.z=0;
-       moldyn->atom[1].element=SI;
-       moldyn->atom[1].mass=M_SI;
+       md.atom=malloc(2*sizeof(t_atom));
+       md.atom[0].r.x=0.13*sqrt(3.0)*LC_SI/2.0;
+       md.atom[0].r.y=0;
+       md.atom[0].r.z=0;
+       md.atom[0].element=SI;
+       md.atom[0].mass=M_SI;
+       md.atom[1].r.x=-md.atom[0].r.x;
+       md.atom[1].r.y=0;
+       md.atom[1].r.z=0;
+       md.atom[1].element=SI;
+       md.atom[1].mass=M_SI;
 #endif
 
        /* initial thermal fluctuations of particles */
@@ -114,7 +115,7 @@ int main(int argc,char **argv) {
        printf("setting thermal fluctuations (T=%f K)\n",md.t);
        thermal_init(&md);
 #else
-       for(a=0;a<md.count;a++) v3_zero(&(si[0].v));
+       for(a=0;a<md.count;a++) v3_zero(&(md.atom[0].v));
 #endif
 
        /* check kinetic energy */
@@ -132,7 +133,6 @@ int main(int argc,char **argv) {
               estimate_time_step(&md,3.0,md.t));
 
        /* initialize linked list / cell method */
-       printf("initializing linked cells\n");
        link_cell_init(&md);
 
        /*
diff --git a/run b/run
index 584a4462b121ad61eccc25e500280335e623ac52..841b3771b72374c6e1ac0bdcfb9375d9ca65abcd 100755 (executable)
--- a/run
+++ b/run
@@ -7,7 +7,7 @@ if [ "$?" == "0" ]; then
        if [ "$argv" ] ; then
                base=`echo $argv | awk -F'-V' '{ print $2 }' | \
                        awk '{ print $2 }'`
-               rasmol -nodisplay < ${base}.scr
+               rasmol -nodisplay < ${base}.scr > /dev/null 2>&1
                ./ppm2avi
        fi
 fi
index 8726741a274d28f3fb747ead9f70884343315a8d..416f82bd9482e80bb49bb4c02b262841c3c9ff44 100644 (file)
@@ -8,7 +8,6 @@
 #ifndef VISUAL_H
 #define VISUAL_H
 
-#include "../moldyn.h"
 #include "../math/math.h"
 
 /* datatypes */
@@ -19,6 +18,8 @@ typedef struct s_visual {
        t_3dvec dim;            /* dimensions of the simulation cell */
 } t_visual;
 
+#include "../moldyn.h"
+
 /* function prototypes */
 
 int visual_init(t_visual *v,char *filebase);