X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop.c;h=d61d2aca2868b7a95b4941198adcabb7c996ffb3;hp=d646cdf9bc3af78a6c4de752edd12625c051ab45;hb=f271c1142da782420ef76f1f85750949094e4269;hpb=72a665941269353574e0fd9effb31c19cdac68e3 diff --git a/nlsop.c b/nlsop.c index d646cdf..d61d2ac 100644 --- a/nlsop.c +++ b/nlsop.c @@ -2,9 +2,10 @@ * nlsop.c * * this program tries helping to understand the amorphous depuration - * and recrystallization of SiCx while ion implanation. hopefully the program - * will simulate the stabilization of the selforganizing structure in the - * observed behaviour. + * and recrystallization of SiCx while ion implantation at temperatures + * below 400 degree celsius. + * hopefully the program will simulate the stabilization of the + * selforganizing lamella structure in the observed behaviour. * * refs: * - J. K. N. Lindner. Habilationsschrift, Universitaet Augsburg. @@ -33,14 +34,17 @@ int usage(void) puts("usage:"); puts("-h \t\t help"); puts("-n \t\t no user interaction"); + puts("-Z \t\t cryst -> amorph c diffusion in z direction"); 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); + printf("-y \t # y cells (default %d)\n",Y); + printf("-z \t # z cells (default %d)\n",Z); + /* printf("-X \t display x (default %d)\n",X/2-1); printf("-Y \t display y (default %d)\n",Y/2-1); printf("-Z \t display z (default %d)\n",Z/2-1); + */ printf("-s \t steps (default %d)\n",STEPS); printf("-d \t refresh display (default %d)\n",REFRESH); printf("-r \t amorphous influence range (default %d)\n",RANGE); @@ -48,7 +52,12 @@ int usage(void) printf("-p \t pressure offset (default %f)\n",B_AP); printf("-A \t slope of linear c distribution (default %f)\n",A_CD); printf("-B \t linear c distribution offset (default %f)\n",B_CD); + /* 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("-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"); @@ -56,15 +65,16 @@ int usage(void) return 1; } -int process_cell(3d_lattice *3d_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,int r,double a,double b,int *t_c) { unsigned char *thiz; int *conc; int i,j; + int off; double p; - thiz=3d_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; - conc=3d_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; + 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++) { @@ -72,34 +82,161 @@ int process_cell(3d_lattice *3d_l,u32 x,u32 y,u32 z,int r,double a,double b,int { if(!(i==0 && j==0)) { - if(*(d3_l->status+((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)&AMORPH) p+=a*URAND_MAX/(i*i+j*j); + 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); } } } - p*=*conc; + // printf("debug: p = %f\n",p); if(!(*thiz&AMORPH)) { - if(rand_get(URAND_MAX)<=p) - { - MAKE_AMORPH(thiz); - *t_c=*t_c+1-*conc; - } else *t_c+=1; + if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz); } else { /* assume 1-p probability */ - if(rand_get(URAND_MAX)>p) - { - MAKE_CRYST(thiz); - *t_c=*t_c+1+*conc; - } else *t_c+=1; + if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz); } + + *t_c+=1; + + return 1; +} + +int distrib_c(d3_lattice *d3_l,double d_r,double a,double b,char z_diff) +{ + u32 x,y,z; + int i,j,k,c; + int offset,off; + int carry; + + /* put one c ion somewhere in the lattice */ + x=get_rand(d3_l->max_x); + y=get_rand(d3_l->max_y); + z=get_rand_lgp(d3_l->max_z,a,b); + *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; + + /* diffusion in layer */ + for(i=0;imax_x;i++) + { + for(j=0;jmax_y;j++) + { + for(k=0;kmax_z;k++) + { + offset=i+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; + /* case amorph */ + if(*(d3_l->status+offset)&AMORPH) + { + /* look at neighbours and move c ions */ + for(c=-1;c<=1;c++) + { + if(c!=0) + { + off=((i+d3_l->max_x+c)%d3_l->max_x)+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; + carry=0; + /* case neighbour not amorph */ + if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off))); + /* case neighbour amorph */ + /* + * no diffusion between amorphous cells + * + else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; + */ + if(carry!=0) + { + *(d3_l->extra+offset)+=carry; + *(d3_l->extra+off)-=carry; + } + } + } + for(c=-1;c<=1;c++) + { + if(c!=0) + { + off=i+((j+c+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; + carry=0; + /* case neighbour not amorph */ + if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off))); + /* case neighbour amorph */ + /* + * + * no diffusion between amorphous cells + * + else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; + */ + if(carry!=0) + { + *(d3_l->extra+offset)+=carry; + *(d3_l->extra+off)-=carry; + } + } + } + } else + /* case not amorph */ + { + /* look at neighbours and move c ions */ + for(c=-1;c<=1;c++) + { + if(c!=0) + { + off=i+((j+c+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; + carry=0; + /* case neighbour not amorph */ + if(!(*(d3_l->status+off)&AMORPH)) + { + carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; + if(carry!=0) + { + *(d3_l->extra+offset)+=carry; + *(d3_l->extra+off)-=carry; + } + } + } + } + for(c=-1;c<=1;c++) + { + if(c!=0) + { + off=((i+c+d3_l->max_x)%d3_l->max_x)+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; + carry=0; + /* case neighbour not amorph */ + if(!(*(d3_l->status+off)&AMORPH)) + { + carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; + if(carry!=0) + { + *(d3_l->extra+offset)+=carry; + *(d3_l->extra+off)-=carry; + } + } + } + } + /* cryst -> amorph diffusion in z direction */ + if(z_diff) + { + for(c=1;c>=-1;c--) + { + off=i+j*d3_l->max_x+((k+c+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y; + carry=0; + if(*(d3_l->status+off)&AMORPH) carry=(int)(d_r*(*(d3_l->extra+offset))); + if(carry!=0) + { + *(d3_l->extra+offset)-=carry; + *(d3_l->extra+off)+=carry; + } + } + } /* if z_diff */ + } + } /* for z */ + } /* for y */ + } /* for x */ return 1; } -int distrib_c(3d_lattice *3d_l,int t_c,double a,double b) +int distrib_c_old(d3_lattice *d3_l,int t_c,double a,double b) { - int i,j,k,total,area,sum; + int i,j,k,total,area; + double sum; int temp,left; int *area_h; u32 x,y,z; @@ -108,7 +245,7 @@ int distrib_c(3d_lattice *3d_l,int t_c,double a,double b) area_h=(int *)malloc(d3_l->max_z*sizeof(int)); total=0; - sum=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; @@ -116,35 +253,29 @@ int distrib_c(3d_lattice *3d_l,int t_c,double a,double b) { if(!(*(d3_l->status+(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) + temp=(int)((i+1)*a+b)*t_c/(sum*area_h[i]); + for(j=0;jstatus+(i*area)+j)&AMORPH)) { - if(!(*(d3_l->status+(i*area)+j)&AMORPH)) - { - *(d3_l->extra+(i*area)+j)=temp; - total+=temp; - } + *(d3_l->extra+(i*area)+j)=temp; + total+=temp; } } - left=(((i+1)*a+b)*t_c/sum)%area_h[i]; + 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; + 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; @@ -153,18 +284,18 @@ int distrib_c(3d_lattice *3d_l,int t_c,double a,double b) 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)) + if(!(*(d3_l->status+x+y*d3_l->max_x+z*area)&AMORPH)) { - *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; + *(d3_l->extra+x+y*d3_l->max_x+z*area)+=1; left-=1; - total+=1; } } + free(area_h); return 1; } -int save_to_file(char *sf,3d_lattice *3d_l) +int save_to_file(char *sf,d3_lattice *d3_l,info *my_inf) { int sf_fd,c; @@ -173,18 +304,23 @@ int save_to_file(char *sf,3d_lattice *3d_l) puts("cannot open save file"); return -1; } - if(write(sf_fd,3d_l,sizeof(3d_lattice))max_x*d3_l->max_y*d3_l->max_z; - if(write(sf_fd,3d_l->status,c*sizeof(unsigned char)status,c*sizeof(unsigned char))extra,c*sizeof(int)extra,c*sizeof(int))max_x*d3_l->max_y*d3_l->max_z; if((d3_l->status=(unsigned char*)malloc(c*sizeof(unsigned char)))==NULL) { @@ -219,12 +360,12 @@ int load_from_file(char *lf,3d_lattice *3d_l) puts("cannot allocate concentration buffer"); return -1; } - if(read(lf_fd,3d_l->status,c*sizeof(unsigned char))status,c*sizeof(unsigned char))extra,c*sizeof(int))extra,c*sizeof(int))max_x;x++) + { + for(y=0;ymax_y;y++) + { + for(z=0;zmax_z;z++) + { + if(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH) dprintf(c_fd,"%d %d %d\n",x,y,z); + } + } + } + close(c_fd); + + return 1; +} + int main(int argc,char **argv) { - u32 max_x,max_y,max_z,x,y,z,x_c,y_c,z_c; + u32 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; + 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 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 status_txt[MAX_TXT]; + char conc_txt[MAX_TXT]; + char steps_txt[MAX_TXT]; + char cc_txt[MAX_TXT]; + char a_txt[MAX_TXT]; + char s_txt[MAX_TXT]; + char ap_txt[MAX_TXT]; + char el_txt[MAX_TXT]; + char cd_txt[MAX_TXT]; + char r_txt[MAX_TXT]; + char ap2_txt[MAX_TXT]; + char cd2_txt[MAX_TXT]; + char el2_txt[MAX_TXT]; + char dr_txt[MAX_TXT]; + char *arg_v[MAX_ARGV]; +#endif d3_lattice d3_l; + info my_info; - 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; + d3_l.max_x=X; + d3_l.max_y=Y; + d3_l.max_z=Z; + my_info.steps=STEPS; + my_info.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; + resave=RESAVE; + z_diff=0; + my_info.a_el=A_EL; + my_info.b_el=B_EL; + my_info.a_cd=A_CD; + my_info.b_cd=B_CD; + my_info.a_ap=A_AP; + my_info.b_ap=B_AP; + my_info.cc=CC; + my_info.d_r=D_R; nowait=0; + quit=0; + escape=0; strcpy(s_file,""); strcpy(l_file,""); + strcpy(c_file,""); + convert=0; strcpy(r_file,""); - for(i=1,i