X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop.c;h=d61d2aca2868b7a95b4941198adcabb7c996ffb3;hp=4ff1d6e55f0cfbfa63109cb64dbd400818f536e2;hb=f271c1142da782420ef76f1f85750949094e4269;hpb=40dfea76e1d7217b798999a5ffdca318ee951b81 diff --git a/nlsop.c b/nlsop.c index 4ff1d6e..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,11 +34,12 @@ 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); @@ -50,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"); @@ -63,6 +70,7 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int unsigned char *thiz; int *conc; int i,j; + int off; double p; thiz=d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y; @@ -74,31 +82,158 @@ int process_cell(d3_lattice *d3_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); } } } + // printf("debug: p = %f\n",p); if(!(*thiz&AMORPH)) { - if(get_rand(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(get_rand(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(d3_lattice *d3_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; double sum; @@ -240,14 +375,45 @@ int load_from_file(char *lf,d3_lattice *d3_l,info *my_inf) return 1; } +int convert_file(char *cf,d3_lattice *d3_l) +{ + int x,y,z; + int c_fd; + + if((c_fd=open(cf,O_WRONLY|O_CREAT))<0) + { + puts("cannot open convert file"); + return -1; + } + dprintf(c_fd,"# created by nlsop (gnuplot format)\n"); + for(x=0;xmax_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; - int 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]; @@ -264,16 +430,20 @@ 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 *arg_v[MAX_ARGV]; +#endif d3_lattice d3_l; info my_info; - max_x=X; - max_y=Y; - max_z=Z; + 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; + resave=RESAVE; + z_diff=0; my_info.a_el=A_EL; my_info.b_el=B_EL; my_info.a_cd=A_CD; @@ -281,11 +451,14 @@ 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; nowait=0; quit=0; escape=0; strcpy(s_file,""); strcpy(l_file,""); + strcpy(c_file,""); + convert=0; strcpy(r_file,""); for(i=1;i