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);
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]));
}
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;
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);
}
}
}
moldyn->potential_force_function(moldyn);
for(i=0;i<moldyn->time_steps;i++) {
- /* show runs */
- printf(".");
/* neighbour list update */
link_cell_update(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);
+ }
}
}
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 */
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]);
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 */
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 */
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 */
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));
* - 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 !!
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 */
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 */
estimate_time_step(&md,3.0,md.t));
/* initialize linked list / cell method */
- printf("initializing linked cells\n");
link_cell_init(&md);
/*