From: hackbard Date: Thu, 17 Jul 2003 15:11:55 +0000 (+0000) Subject: - X-Git-Tag: fpb~27 X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=126057c72d3dcf4cea9f5e46f36606289703bd17;p=physik%2Fnlsop.git - --- diff --git a/nlsop.c b/nlsop.c index e9d72ab..2d09306 100644 --- a/nlsop.c +++ b/nlsop.c @@ -55,17 +55,19 @@ int usage(void) /* printf("-C \t initial c concentration (default %d)\n",CC); */ - printf("-D \t diffusion rate from cryst to amorph cells (default %f)\n",D_R); + printf("-D \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC); + printf("-c \t diffusion rate in cryst cells (default %f)\n",DR_CC); printf("-W \t write every steps to save file (default %d)\n",RESAVE); puts("-C \t convert file to gnuplot format"); puts("-L \t load from file"); puts("-S \t save to file"); puts("-R \t read from random file"); + puts("-P \t specify implantatin profile file"); return 1; } -int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int *t_c) +int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info) { unsigned char *thiz; int *conc; @@ -75,18 +77,19 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int thiz=d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; conc=d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; - p=b*URAND_MAX; - for(i=-r;i<=r;i++) + p=my_info->b_ap*URAND_MAX; + for(i=-(my_info->range);i<=my_info->range;i++) { - for(j=-r;j<=r;j++) + for(j=-(my_info->range);j<=my_info->range;j++) { if(!(i==0 && j==0)) { off=((x+d3_l->max_x+i)%d3_l->max_x)+((y+d3_l->max_y+j)%d3_l->max_x)*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; - if(*(d3_l->status+off)&AMORPH) p+=a*(*(d3_l->extra+off))*URAND_MAX/(i*i+j*j); + if(*(d3_l->status+off)&AMORPH) p+=my_info->a_ap*(*(d3_l->extra+off))*URAND_MAX/(i*i+j*j); } } } + p+=*conc*my_info->a_cp*URAND_MAX; printf("debug: p = %f\n",p); if(!(*thiz&AMORPH)) { @@ -97,12 +100,12 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz); } - *t_c+=1; + my_info->cc+=1; return 1; } -int distrib_c(d3_lattice *d3_l,double d_r,double a,double b,char z_diff) +int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,char z_diff) */ { u32 x,y,z; int i,j,k,c; @@ -265,68 +268,6 @@ int calc_pressure(d3_lattice *d3_l,int range) return 1; } -int distrib_c_old(d3_lattice *d3_l,int t_c,double a,double b) -{ - int i,j,k,total,area; - double 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=b*d3_l->max_z+a*d3_l->max_z*(d3_l->max_z+1)/2; - for(i=0;imax_z;i++) - { - area_h[i]=0; - for(j=0;jstatus+(i*area)+j)&AMORPH)) - { - area_h[i]+=1; - } - } - temp=(int)((i+1)*a+b)*t_c/(sum*area_h[i]); - for(j=0;jstatus+(i*area)+j)&AMORPH)) - { - *(d3_l->extra+(i*area)+j)=temp; - total+=temp; - } - } - left=(int)(((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*area)&AMORPH)) - { - *(d3_l->extra+x+y*d3_l->max_x+z*area)+=1; - left-=1; - } - } - free(area_h); - - return 1; -} - int save_to_file(char *sf,d3_lattice *d3_l,info *my_inf) { int sf_fd,c; @@ -438,17 +379,15 @@ int main(int argc,char **argv) u32 x,y,z,x_c,y_c,z_c; int i,quit,escape,switchmode,nowait; int refresh,resave; - char z_diff; char s_file[MAX_CHARS]; char s_file_tmp[MAX_CHARS]; char l_file[MAX_CHARS]; char c_file[MAX_CHARS]; + char p_file[MAX_CHARS]; char convert; char r_file[MAX_CHARS]; #ifdef USE_DFB_API - char x_txt[MAX_TXT]; - char y_txt[MAX_TXT]; - char z_txt[MAX_TXT]; + char xyz_txt[MAX_TXT]; char status_txt[MAX_TXT]; char conc_txt[MAX_TXT]; char steps_txt[MAX_TXT]; @@ -462,7 +401,8 @@ int main(int argc,char **argv) char ap2_txt[MAX_TXT]; char cd2_txt[MAX_TXT]; char el2_txt[MAX_TXT]; - char dr_txt[MAX_TXT]; + char dr_ac_txt[MAX_TXT]; + char dr_cc_txt[MAX_TXT]; char mode_txt[MAX_TXT]; char *arg_v[MAX_ARGV]; #endif @@ -477,7 +417,7 @@ int main(int argc,char **argv) my_info.range=RANGE; refresh=REFRESH; resave=RESAVE; - z_diff=0; + my_info.z_diff=0; my_info.a_el=A_EL; my_info.b_el=B_EL; my_info.a_cd=A_CD; @@ -485,7 +425,8 @@ int main(int argc,char **argv) my_info.a_ap=A_AP; my_info.b_ap=B_AP; my_info.cc=CC; - my_info.d_r=D_R; + my_info.dr_ac=DR_AC; + my_info.dr_cc=DR_CC; nowait=0; quit=0; escape=0; @@ -493,6 +434,7 @@ int main(int argc,char **argv) strcpy(s_file,""); strcpy(l_file,""); strcpy(c_file,""); + strcpy(p_file,IMP_PROFILE); convert=0; strcpy(r_file,""); mode=0; @@ -533,7 +475,7 @@ int main(int argc,char **argv) break; */ case 'Z': - z_diff=1; + my_info.z_diff=1; break; /* */ case 's': @@ -571,7 +513,10 @@ int main(int argc,char **argv) convert=1; break; case 'D': - my_info.d_r=atof(argv[++i]); + my_info.dr_ac=atof(argv[++i]); + break; + case 'c': + my_info.dr_cc=atof(argv[++i]); break; case 'L': strcpy(l_file,argv[++i]); @@ -582,6 +527,9 @@ int main(int argc,char **argv) case 'R': strcpy(r_file,argv[++i]); break; + case 'P': + strcpy(p_file,argv[++i]); + break; default: usage(); return -1; @@ -652,32 +600,33 @@ int main(int argc,char **argv) sprintf(el2_txt,"energy loss offset: %.2f",my_info.b_el); sprintf(cd_txt,"c distrib slope: %.2f",my_info.a_cd); sprintf(cd2_txt,"c distrib offset: %.2f",my_info.b_cd); - sprintf(dr_txt,"diffusion rate: %.2f",my_info.d_r); + sprintf(dr_ac_txt,"a/c diffusion rate: %.2f",my_info.dr_ac); + sprintf(dr_cc_txt,"c/c diffusion rate: %.2f",my_info-dr_cc); strcpy(mode_txt,"view: a/c mode"); - arg_v[1]=x_txt; - arg_v[2]=y_txt; - arg_v[3]=z_txt; - arg_v[4]=NULL; - arg_v[5]=status_txt; - arg_v[6]=conc_txt; + arg_v[1]=xyz_txt; + arg_v[2]=NULL; + arg_v[3]=status_txt; + arg_v[4]=conc_txt; + arg_v[5]=NULL; + arg_v[6]=mode_txt; arg_v[7]=NULL; - arg_v[8]=mode_txt; - arg_v[9]=NULL; - arg_v[10]=steps_txt;; - arg_v[11]=cc_txt; + arg_v[8]=steps_txt; + arg_v[9]=cc_txt; + arg_v[10]=NULL; + arg_v[11]=NULL; arg_v[12]=NULL; arg_v[13]=NULL; arg_v[14]=a_txt; - arg_v[15]=NULL; - arg_v[16]=s_txt; - arg_v[17]=r_txt; - arg_v[18]=ap_txt; - arg_v[19]=ap2_txt; - arg_v[20]=el_txt; - arg_v[21]=el2_txt; - arg_v[22]=cd_txt; - arg_v[23]=cd2_txt; - arg_v[24]=dr_txt; + arg_v[15]=s_txt; + arg_v[16]=r_txt; + arg_v[17]=ap_txt; + arg_v[18]=ap2_txt; + arg_v[19]=el_txt; + arg_v[20]=el2_txt; + arg_v[21]=cd_txt; + arg_v[22]=cd2_txt; + arg_v[23]=dr_ac_txt; + arg_v[24]=dr_cc_txt; #endif if(!strcmp(l_file,"")) @@ -689,13 +638,11 @@ int main(int argc,char **argv) y_c=get_rand(d3_l.max_y); z_c=get_rand_lgp(d3_l.max_z,my_info.a_el,my_info.b_el); distrib_c(&d3_l,my_info.d_r,my_info.a_cd,my_info.b_cd,z_diff); - process_cell(&d3_l,x_c,y_c,z_c,my_info.range,my_info.a_ap,my_info.b_ap,&(my_info.cc)); + process_cell(&d3_l,x_c,y_c,z_c,&my_info); #ifdef USE_DFB_API if(i%refresh==0) { - sprintf(x_txt,"x: %d",x+1); - sprintf(y_txt,"y: %d",y+1); - sprintf(z_txt,"z: %d",z+1); + sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1); sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c'); sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)); sprintf(steps_txt,"step: %d",i); @@ -703,7 +650,7 @@ int main(int argc,char **argv) d3_lattice_draw(&d3_l,x,y,z,24,arg_v,mode); } #endif - if(i%resave==0 && strcmp(s_file,"") && resave!=0) + if(i%resave==0 && strcmp(s_file,"") && resave!=0 && i!=0) { sprintf(s_file_tmp,"%s_%d_of_%d",s_file,i,my_info.steps); save_to_file(s_file_tmp,&d3_l,&my_info); diff --git a/nlsop.h b/nlsop.h index 1b8e4ca..3cd94e6 100644 --- a/nlsop.h +++ b/nlsop.h @@ -13,7 +13,8 @@ typedef unsigned int u32; typedef struct __info { int cc,steps,range; - double a_el,b_el,a_cd,b_cd,a_ap,b_ap,d_r; + double a_el,b_el,a_cd,b_cd,a_ap,b_ap,a_cp,dr_ac,dr_cc; + char z_diff; } info; #define AMORPH 1 @@ -35,15 +36,20 @@ typedef struct __info #define CC 0 -#define D_R .5 +#define DR_AC .5 +#define DR_CC .2 #define A_AP .1 #define B_AP .01 +#define A_CP .01 + #define MAX_CHARS 64 #define MAX_TXT 32 #define MAX_ARGV 27 #define MAX_VPTR 50 +#define IMP_PROFILE "imp-profile.txt" + #endif /* NLSOP_H */