- x=moldyn->dim.x/2;
- y=moldyn->dim.y/2;
- z=moldyn->dim.z/2;
-
- for(i=0;i<lc->cells;i++)
- list_destroy_f(&(lc->subcell[i]));
-
- for(count=0;count<moldyn->count;count++) {
- 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_f(&(lc->subcell[i+j*nx+k*nx*ny]),
- &(atom[count]));
-//if(i==0&&j==0&&k==0) printf(" --- add one here! %d %p ----\n",count,lc->subcell[0].current);
- }
-
- return 0;
-}
-
-int link_cell_neighbour_index(t_moldyn *moldyn,int i,int j,int k,t_list *cell) {
-
- t_linkcell *lc;
- int a;
- int count1,count2;
- int ci,cj,ck;
- int nx,ny,nz;
- int x,y,z;
- u8 bx,by,bz;
-
- lc=&(moldyn->lc);
- nx=lc->nx;
- ny=lc->ny;
- nz=lc->nz;
- count1=1;
- count2=27;
- a=nx*ny;
-
- cell[0]=lc->subcell[i+j*nx+k*a];
- for(ci=-1;ci<=1;ci++) {
- bx=0;
- x=i+ci;
- if((x<0)||(x>=nx)) {
- x=(x+nx)%nx;
- bx=1;
- }
- for(cj=-1;cj<=1;cj++) {
- by=0;
- y=j+cj;
- if((y<0)||(y>=ny)) {
- y=(y+ny)%ny;
- by=1;
- }
- for(ck=-1;ck<=1;ck++) {
- bz=0;
- z=k+ck;
- if((z<0)||(z>=nz)) {
- z=(z+nz)%nz;
- bz=1;
- }
- if(!(ci|cj|ck)) continue;
- if(bx|by|bz) {
- cell[--count2]=lc->subcell[x+y*nx+z*a];
- }
- else {
- cell[count1++]=lc->subcell[x+y*nx+z*a];
- }
- }
- }
- }
-
- lc->dnlc=count1;
-
- return count1;
-}
-
-int link_cell_shutdown(t_moldyn *moldyn) {
-
- int i;
- t_linkcell *lc;
-
- lc=&(moldyn->lc);
-
-printf("FOO:\n");
- for(i=0;i<lc->nx*lc->ny*lc->nz;i++) {
-printf(" %d\n",i);
- list_destroy_f(&(moldyn->lc.subcell[i]));
-printf(" %d!\n",i);
-}
-
- free(lc->subcell);
-
- return 0;
-}
-
-#endif
-
-int moldyn_add_schedule(t_moldyn *moldyn,int runs,double tau) {
-
- int count;
- void *ptr;
- t_moldyn_schedule *schedule;
-
- schedule=&(moldyn->schedule);
- count=++(schedule->total_sched);
-
- ptr=realloc(schedule->runs,count*sizeof(int));
- if(!ptr) {
- perror("[moldyn] realloc (runs)");
- return -1;
- }
- schedule->runs=ptr;
- schedule->runs[count-1]=runs;
-
- ptr=realloc(schedule->tau,count*sizeof(double));
- if(!ptr) {
- perror("[moldyn] realloc (tau)");
- return -1;
- }
- schedule->tau=ptr;
- schedule->tau[count-1]=tau;
-
- printf("[moldyn] schedule added:\n");
- printf(" number: %d | runs: %d | tau: %f\n",count-1,runs,tau);
-
-
- return 0;
-}
-
-int moldyn_set_schedule_hook(t_moldyn *moldyn,set_hook hook,void *hook_params) {
-
- moldyn->schedule.hook=hook;
- moldyn->schedule.hook_params=hook_params;
-
- return 0;
-}
-
-/*
- *
- * 'integration of newtons equation' - algorithms
- *
- */
-
-/* start the integration */
-
-int moldyn_integrate(t_moldyn *moldyn) {
-
- int i;
- unsigned int e,m,s,v,p,t;
- t_3dvec momentum;
- t_moldyn_schedule *sched;
- t_atom *atom;
- int fd;
- char dir[128];
- double ds;
- double energy_scale;
- struct timeval t1,t2;
- //double tp;
-
- sched=&(moldyn->schedule);
- atom=moldyn->atom;
-
- /* initialize linked cell method */
- link_cell_init(moldyn,VERBOSE);
-
- /* logging & visualization */
- e=moldyn->ewrite;
- m=moldyn->mwrite;
- s=moldyn->swrite;
- v=moldyn->vwrite;
- p=moldyn->pwrite;
- t=moldyn->twrite;