From c2cf344605eb715f5b6524b1a05317ff319f7dd7 Mon Sep 17 00:00:00 2001 From: hackbard Date: Wed, 14 May 2003 14:04:56 +0000 Subject: [PATCH] - --- nlsop.c | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- nlsop.h | 1 + 2 files changed, 172 insertions(+), 4 deletions(-) diff --git a/nlsop.c b/nlsop.c index 761be35..4eb6410 100644 --- a/nlsop.c +++ b/nlsop.c @@ -33,8 +33,8 @@ int usage(void) puts("usage:"); puts("-h \t\t help"); puts("-n \t\t no user interaction"); - printf("-a \t slope of nuclear energy loss (default %d)\n",A_EL); - printf("-b \t nuclear energy loss offset (default %d)\n",B_EL); + printf("-a \t slope of nuclear energy loss (default %f)\n",A_EL); + printf("-b \t nuclear energy loss offset (default %f)\n",B_EL); printf("-x \t # x cells (default %d)\n",X); printf("-y \t # x cells (default %d)\n",Y); printf("-z \t # x cells (default %d)\n",Z); @@ -99,12 +99,179 @@ int process_cell(3d_lattice *3d_l,u32 x,u32 y,u32 z,int r,double a,double b,int int distrib_c(3d_lattice *3d_l,int t_c,double a,double b) { - int i,j,total,area; + int i,j,k,total,area,sum; + int temp,left; + int *area_h; + u32 x,y,z; + area=d3_l->max_x*d3_l->max_y; + area_h=(int *)malloc(d3_l->max_z*sizeof(int)); + + total=0; + sum=0; for(i=0;imax_z;i++) { - + area_h[i]=0; + for(j=0;jstatus+(i*area)+j)&AMORPH)) + { + sum+=(i+1)*a+b; + area_h[i]+=1; + } + } + } + for(i=0;imax_z;i++) + { + temp=((i+1)*a+b)*t_c/(sum+area_h[i]); + if(temp>1) + { + for(j=0;jstatus+(i*area)+j)&AMORPH)) + { + *(d3_l->extra+(i*area)+j)=temp; + total+=temp; + } + } + } + left=(((i+1)*a+b)*t_c/sum)%area_h[i]; + while(left) + { + x=get_rand(d3_l->max_x); + y=get_rand(d3_l->max_y); + if(!(*(d3_l->status+(i*area)+x+y*d3_l->max_x)&AMORPH)) + { + *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1; + total+=1; + left-=1; + } + } + left=t_c-total; + while(left) + { + x=get_rand(d3_l->max_x); + y=get_rand(d3_l->max_y); + z=get_rand_lgp(d3_l->max_z,a,b); + if(!(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH)) + { + *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; + left-=1; + total+=1; + } } + return 1; +} + +int main(int argc,char **argv) +{ + u32 max_x,max_y,max_z,x,y,z,x_c,y_c,z_c; + int i,quit,escape,nowait; + double a_el,b_el,a_cd,b_cd,a_ap,b_ap; + int cc,steps,range,refresh; + char s_file[MAX_CHARS]; + char l_file[MAX_CHARS]; + char r_file[MAX_CHARS]; + d3_lattice d3_l; + + max_x=X; + max_y=Y; + max_z=Z; + x=X/2-1; + y=Y/2-1; + z=Z/2-1; + steps=STEPS; + range=RANGE; + refresh=REFRESH; + a_el=A_EL; + b_el=B_EL; + a_cd=A_CD; + b_cd=B_CD; + a_ap=A_AP; + b_ap=B_AP; + cc=CC; + nowait=0; + strcpy(s_file,""); + strcpy(l_file,""); + strcpy(r_file,""); + + for(i=1,i