From: hackbard Date: Fri, 12 May 2006 14:58:57 +0000 (+0000) Subject: fixed (dank rolf) X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c38fe34069adb9697683235f8b1e2311a3122e8f;p=physik%2Fposic.git fixed (dank rolf) --- diff --git a/Makefile b/Makefile index 6539f22..7096b48 100644 --- 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 diff --git a/moldyn.c b/moldyn.c index 6e76bc0..707fe03 100644 --- 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;icells;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;icells;i++) list_destroy(&(moldyn->lc.subcell[i])); for(count=0;countcount;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;itime_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;ix; - 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;ix; - 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 2b18c79..c185d16 100644 --- 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 /dev/null 2>&1 ./ppm2avi fi fi diff --git a/visual/visual.h b/visual/visual.h index 8726741..416f82b 100644 --- a/visual/visual.h +++ b/visual/visual.h @@ -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);