From: hackbard Date: Wed, 29 Nov 2006 15:20:19 +0000 (+0000) Subject: security ci X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=56fe12b9eabe0cfa493e2f1b1d0d7d219ae8705b;p=physik%2Fposic.git security ci --- diff --git a/moldyn.c b/moldyn.c index 2f274c2..a978541 100644 --- a/moldyn.c +++ b/moldyn.c @@ -252,11 +252,12 @@ int add_atom(t_moldyn *moldyn,int element,double mass,u8 bnum,u8 attr, 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; } @@ -327,6 +328,12 @@ int scale_velocity(t_moldyn *moldyn) { /* * - 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;icount;i++) e+=0.5*atom[i].mass*v3_absolute_square(&(atom[i].v)); @@ -587,11 +594,13 @@ int moldyn_integrate(t_moldyn *moldyn) { 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); @@ -609,6 +618,10 @@ int moldyn_integrate(t_moldyn *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; @@ -700,7 +713,7 @@ int velocity_verlet(t_moldyn *moldyn) { 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); @@ -749,7 +762,6 @@ int potential_force_calc(t_moldyn *moldyn) { /* reset energy */ moldyn->energy=0.0; -printf("DEBUG: count = %d\n",count); for(i=0;idim.x/2)/lc->x, (atom[i].r.y+moldyn->dim.y/2)/lc->y, @@ -772,7 +783,6 @@ printf("DEBUG: processing atom %d\n",i); countn=lc->countn; dnlc=lc->dnlc; -printf("DEBUG: countn = %d - dnslc = %d\n",countn,dnlc); for(j=0;jattr&ATOM_ATTR_2BP)& (atom[i].attr&ATOM_ATTR_2BP)) -printf("DEBUG: calling func2b\n"); moldyn->func2b(moldyn, &(atom[i]), btom, @@ -898,7 +907,6 @@ int harmonic_oscillator(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { 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) { @@ -942,7 +950,7 @@ int lennard_jones(t_moldyn *moldyn,t_atom *ai,t_atom *aj,u8 bc) { 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; diff --git a/sic.c b/sic.c index 3924375..9cb2c55 100644 --- a/sic.c +++ b/sic.c @@ -83,6 +83,10 @@ int main(int argc,char **argv) { 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"); @@ -91,6 +95,9 @@ int main(int argc,char **argv) { /* 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"); @@ -98,8 +105,8 @@ int main(int argc,char **argv) { /* 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 diff --git a/visual/visual.c b/visual/visual.c index 03c20a1..d675c5d 100644 --- a/visual/visual.c +++ b/visual/visual.c @@ -94,7 +94,7 @@ int visual_atoms(t_visual *v,double time,t_atom *atom,int n) { 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");