printf("--- physics options ---\n");
printf("-T <temperature> [K] (%f)\n",MOLDYN_TEMP);
printf("-t <timestep tau> [s] (%.15f)\n",MOLDYN_TAU);
+ printf("-C <cutoff radius> [m] (%.15f)\n",MOLDYN_CUTOFF);
printf("-R <runs> (%d)\n",MOLDYN_RUNS);
printf(" -- integration algo --\n");
printf(" -I <number> (%d)\n",MOLDYN_INTEGRATE_DEFAULT);
case 't':
moldyn->tau=atof(argv[++i]);
break;
+ case 'C':
+ moldyn->cutoff=atof(argv[++i]);
+ break;
case 'R':
moldyn->time_steps=atoi(argv[++i]);
break;
return 0;
}
-int moldyn_log_init(t_moldyn *moldyn,void *v) {
+int moldyn_log_init(t_moldyn *moldyn) {
moldyn->lvstat=0;
t_visual *vis;
- vis=v;
+ vis=&(moldyn->vis);
if(moldyn->ewrite) {
moldyn->efd=open(moldyn->efb,O_WRONLY|O_CREAT|O_TRUNC);
return 0;
}
-int moldyn_shutdown(t_moldyn *moldyn) {
+int moldyn_log_shutdown(t_moldyn *moldyn) {
if(moldyn->efd) close(moldyn->efd);
if(moldyn->mfd) close(moldyn->efd);
return 0;
}
+int moldyn_init(t_moldyn *moldyn,int argc,char **argv) {
+
+ int ret;
+
+ ret=moldyn_parse_argv(moldyn,argc,argv);
+ if(ret<0) return ret;
+
+ ret=moldyn_log_init(moldyn);
+ if(ret<0) return ret;
+
+ rand_init(&(moldyn->random),NULL,1);
+ moldyn->random.status|=RAND_STAT_VERBOSE;
+
+ moldyn->status=0;
+
+ return 0;
+}
+
+int moldyn_shutdown(t_moldyn *moldyn) {
+
+ moldyn_log_shutdown(moldyn);
+ rand_close(&(moldyn->random));
+ free(moldyn->atom);
+
+ return 0;
+}
+
int create_lattice(unsigned char type,int element,double mass,double lc,
int a,int b,int c,t_atom **atom) {
return 0;
}
-int thermal_init(t_moldyn *moldyn,t_random *random) {
+int thermal_init(t_moldyn *moldyn) {
/*
* - gaussian distribution of velocities
double v,sigma;
t_3dvec p_total,delta;
t_atom *atom;
+ t_random *random;
atom=moldyn->atom;
+ random=&(moldyn->random);
/* gaussian distribution of velocities */
v3_zero(&p_total);
int link_cell_init(t_moldyn *moldyn) {
t_linkcell *lc;
+ int i;
lc=&(moldyn->lc);
+ /* list log fd */
+ lc->listfd=open("/dev/null",O_WRONLY);
+
/* partitioning the md cell */
lc->nx=moldyn->dim.x/moldyn->cutoff;
lc->x=moldyn->dim.x/lc->nx;
lc->nz=moldyn->dim.z/moldyn->cutoff;
lc->z=moldyn->dim.z/lc->nz;
- lc->subcell=malloc(lc->nx*lc->ny*lc->nz*sizeof(t_list));
+ lc->cells=lc->nx*lc->ny*lc->nz;
+ lc->subcell=malloc(lc->cells*sizeof(t_list));
+
+ 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);
link_cell_update(moldyn);
lc=&(moldyn->lc);
nx=lc->nx;
ny=lc->ny;
- nx=lc->nz;
+ nz=lc->nz;
count1=1;
count2=27;
a=nx*ny;
for(i=0;i<lc->nx*lc->ny*lc->nz;i++)
list_shutdown(&(moldyn->lc.subcell[i]));
+ if(lc->listfd) close(lc->listfd);
+
return 0;
}
moldyn->tau_square=moldyn->tau*moldyn->tau;
moldyn->cutoff_square=moldyn->cutoff*moldyn->cutoff;
- /* create the neighbour list */
- link_cell_update(moldyn);
-
/* calculate initial forces */
moldyn->potential_force_function(moldyn);