moldyn->atom=ptr;
atom=moldyn->atom;
- atom->r=*r;
- atom->v=*v;
- atom->element=element;
- atom->bnum=bnum;
- atom->attr=attr;
+ atom[count-1].r=*r;
+ atom[count-1].v=*v;
+ atom[count-1].element=element;
+ atom[count-1].mass=mass;
+ atom[count-1].bnum=bnum;
+ atom[count-1].attr=attr;
return 0;
}
/*
* - velocity scaling (E = 3/2 N k T), E: kinetic energy
*/
+
+ if(moldyn->t==0.0) {
+ printf("[moldyn] no velocity scaling for T = 0 K\n");
+ return -1;
+ }
+
e=0.0;
for(i=0;i<moldyn->count;i++)
e+=0.5*atom[i].mass*v3_absolute_square(&(atom[i].v));
unsigned int e,m,s,v;
t_3dvec p;
t_moldyn_schedule *schedule;
+ t_atom *atom;
int fd;
char fb[128];
schedule=&(moldyn->schedule);
+ atom=moldyn->atom;
/* initialize linked cell method */
link_cell_init(moldyn);
/* calculate initial forces */
potential_force_calc(moldyn);
+ /* accuracy check */
+ ds=0.5*moldyn->tau_square*v3_norm(&(atom[0].f))/atom[0].mass;
+ if(ds>moldyn->lc.
+
/* zero absolute time */
moldyn->time=0.0;
v3_add(&(atom[i].r),&(atom[i].r),&delta);
v3_scale(&delta,&(atom[i].f),0.5*tau_square/atom[i].mass);
v3_add(&(atom[i].r),&(atom[i].r),&delta);
- v3_per_bound(&(atom[i].r),&(moldyn->dim));
+ check_per_bound(moldyn,&(atom[i].r));
/* velocities */
v3_scale(&delta,&(atom[i].f),0.5*tau/atom[i].mass);
/* reset energy */
moldyn->energy=0.0;
-printf("DEBUG: count = %d\n",count);
for(i=0;i<count;i++) {
/* reset force */
/* 2 body pair potential/force */
if(atom[i].attr&(ATOM_ATTR_2BP|ATOM_ATTR_3BP)) {
-printf("DEBUG: processing atom %d\n",i);
link_cell_neighbour_index(moldyn,
(atom[i].r.x+moldyn->dim.x/2)/lc->x,
(atom[i].r.y+moldyn->dim.y/2)/lc->y,
countn=lc->countn;
dnlc=lc->dnlc;
-printf("DEBUG: countn = %d - dnslc = %d\n",countn,dnlc);
for(j=0;j<countn;j++) {
this=&(neighbour[j]);
if((btom->attr&ATOM_ATTR_2BP)&
(atom[i].attr&ATOM_ATTR_2BP))
-printf("DEBUG: calling func2b\n");
moldyn->func2b(moldyn,
&(atom[i]),
btom,
v3_sub(&distance,&(ai->r),&(aj->r));
- v3_per_bound(&distance,&(moldyn->dim));
if(bc) check_per_bound(moldyn,&distance);
d=v3_norm(&distance);
if(d<=moldyn->cutoff) {
d=+h1-h2;
d*=eps;
v3_scale(&force,&distance,d);
- v3_add(&(ai->f),&(aj->f),&force);
+ v3_add(&(ai->f),&(ai->f),&force);
}
return 0;
add_atom(&md,SI,M_SI,0,ATOM_ATTR_2BP,&r,&v);
r.x=-r.x;
add_atom(&md,SI,M_SI,0,ATOM_ATTR_2BP,&r,&v);
+ printf("[sic] check: there are %d atoms\n",md.count);
+ printf("[sic] check: atoms x pos: %.15f %.15f\n",md.atom[0].r.x,md.atom[1].r.x);
+ printf("[sic] check: atoms x vel: %.15f %.15f\n",md.atom[0].v.x,md.atom[1].v.x);
+ printf("[sic] check: atoms mass: %.35f %.35f\n",md.atom[0].mass,md.atom[1].mass);
/* set temperature */
printf("[sic] setting temperature\n");
/* initial thermal fluctuations of particles */
printf("[sic] thermal init\n");
thermal_init(&md);
+ printf("[sic] check: there are %d atoms\n",md.count);
+ printf("[sic] check: atoms x pos: %.15f %.15f\n",md.atom[0].r.x,md.atom[1].r.x);
+ printf("[sic] check: atoms x vel: %.15f %.15f\n",md.atom[0].v.x,md.atom[1].v.x);
/* create the simulation schedule */
printf("[sic] adding schedule\n");
/* activate logging */
printf("[sic] activate logging\n");
- moldyn_set_log(&md,LOG_TOTAL_ENERGY,"saves/test-energy",100);
- moldyn_set_log(&md,VISUAL_STEP,"saves/test-visual",100);
+ moldyn_set_log(&md,LOG_TOTAL_ENERGY,"saves/test-energy",1);
+ moldyn_set_log(&md,VISUAL_STEP,"saves/test-visual",1);
/*
* let's do the actual md algorithm now
dprintf(v->fd,"rotate y 10\n");
dprintf(v->fd,"set ambient 20\n");
dprintf(v->fd,"set specular on\n");
- dprintf(v->fd,"label\n");
+ //dprintf(v->fd,"label\n");
sprintf(file,"%s-%.15f.ppm",v->fb,time);
dprintf(v->fd,"write ppm %s\n",file);
dprintf(v->fd,"zap\n");