* 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.
printf("-a <value> \t slope of nuclear energy loss (default %f)\n",A_EL);
printf("-b <value> \t nuclear energy loss offset (default %f)\n",B_EL);
printf("-x <value> \t # x cells (default %d)\n",X);
- printf("-y <value> \t # x cells (default %d)\n",Y);
- printf("-z <value> \t # x cells (default %d)\n",Z);
+ printf("-y <value> \t # y cells (default %d)\n",Y);
+ printf("-z <value> \t # z cells (default %d)\n",Z);
/*
printf("-X <value> \t display x (default %d)\n",X/2-1);
printf("-Y <value> \t display y (default %d)\n",Y/2-1);
printf("-p <value> \t pressure offset (default %f)\n",B_AP);
printf("-A <value> \t slope of linear c distribution (default %f)\n",A_CD);
printf("-B <value> \t linear c distribution offset (default %f)\n",B_CD);
+ /*
printf("-C <value> \t initial c concentration (default %d)\n",CC);
+ */
+ printf("-D <value> \t diffusion rate from cryst to amorph cells (default %f)\n",D_R);
+ printf("-W <value> \t write every <value> steps to save file (default %d)\n",RESAVE);
+ puts("-C <file> \t convert file to gnuplot format");
puts("-L <file> \t load from file");
puts("-S <file> \t save to file");
puts("-R <file> \t read from random file");
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;
{
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,int t_c,double a,double b)
+int distrib_c(d3_lattice *d3_l,double d_r,double a,double b)
+{
+ 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;i<d3_l->max_x;i++)
+ {
+ for(j=0;j<d3_l->max_y;j++)
+ {
+ for(k=0;k<d3_l->max_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 z */
+ } /* for y */
+ } /* for x */
+
+ 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;
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;x<d3_l->max_x;x++)
+ {
+ for(y=0;y<d3_l->max_y;y++)
+ {
+ for(z=0;z<d3_l->max_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 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 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;
my_info.a_el=A_EL;
my_info.b_el=B_EL;
my_info.a_cd=A_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<argc;i++)
my_info.b_el=atof(argv[++i]);
break;
case 'x':
- max_x=atoi(argv[++i]);
+ d3_l.max_x=atoi(argv[++i]);
break;
case 'y':
- max_y=atoi(argv[++i]);
+ d3_l.max_y=atoi(argv[++i]);
break;
case 'z':
- max_z=atoi(argv[++i]);
+ d3_l.max_z=atoi(argv[++i]);
break;
/*
case 'X':
case 'B':
my_info.b_cd=atof(argv[++i]);
break;
+ /*
case 'C':
my_info.cc=atoi(argv[++i]);
break;
+ */
+ case 'W':
+ resave=atoi(argv[++i]);
+ break;
+ case 'C':
+ strcpy(l_file,argv[++i]);
+ if(i<argc-1) if(argv[i+1][0]!='-') strcpy(c_file,argv[++i]);
+ convert=1;
+ break;
+ case 'D':
+ my_info.d_r=atof(argv[++i]);
+ break;
case 'L':
strcpy(l_file,argv[++i]);
break;
} else usage();
}
- x=max_x/2-1;
- y=max_y/2-1;
- z=max_z/2-1;
-
+ x=d3_l.max_x/2-1;
+ y=d3_l.max_y/2-1;
+ z=d3_l.max_z/2-1;
+#ifdef NODFB
+ if(!strcmp(s_file,""))
+ {
+ puts("NODFB defined, run with -S option");
+ return -1;
+ }
+#endif
if(!strcmp(r_file,"")) rand_init(NULL);
else rand_init(r_file);
if(!strcmp(l_file,""))
{
- i=max_x*max_y*max_z;
- d3_lattice_init(&argc,argv,&d3_l,max_x,max_y,max_z);
+ i=d3_l.max_x*d3_l.max_y*d3_l.max_z;
+#ifdef USE_DFB_API
+ d3_lattice_init(&argc,argv,&d3_l);
+#endif
if((d3_l.status=(unsigned char *)malloc(i*sizeof(unsigned char)))==NULL)
{
puts("failed allocating status buffer");
} else
{
load_from_file(l_file,&d3_l,&my_info);
- d3_lattice_init(&argc,argv,&d3_l,d3_l.max_x,d3_l.max_y,d3_l.max_z);
+ if(convert)
+ {
+ if(!strcmp(c_file,"")) sprintf(c_file,"%s_gnuplot",l_file);
+ printf("converting file %s to %s\n",l_file,c_file);
+ convert_file(c_file,&d3_l);
+ puts("done");
+ return 1;
+ }
+#ifdef USE_DFB_API
+ else d3_lattice_init(&argc,argv,&d3_l);
+#endif
}
+#ifdef USE_DFB_API
d3_event_init(&d3_l);
+#endif
+#ifdef USE_DFB_API
strcpy(a_txt,"args:");
sprintf(s_txt,"steps: %d",my_info.steps);
sprintf(r_txt,"pressure range: %d",my_info.range);
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);
arg_v[1]=x_txt;
arg_v[2]=y_txt;
arg_v[3]=z_txt;
arg_v[21]=el2_txt;
arg_v[22]=cd_txt;
arg_v[23]=cd2_txt;
+ arg_v[24]=dr_txt;
+#endif
if(!strcmp(l_file,""))
{
x_c=get_rand(d3_l.max_x);
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.cc,my_info.a_cd,my_info.b_cd);
+ distrib_c(&d3_l,my_info.d_r,my_info.a_cd,my_info.b_cd);
process_cell(&d3_l,x_c,y_c,z_c,my_info.range,my_info.a_ap,my_info.b_ap,&(my_info.cc));
+#ifdef USE_DFB_API
if(i%refresh==0)
{
sprintf(x_txt,"x: %d",x+1);
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);
sprintf(cc_txt,"total c: %d",my_info.cc);
- d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
- // scan_event(&d3_l,&x,&y,&z,&quit,&escape);
+ d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
+ }
+#endif
+ if(i%resave==0 && strcmp(s_file,"") && resave!=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);
+#ifdef NODFB
+ printf("saved %s\n",s_file_tmp);
+#endif
}
i++;
}
}
- if(strcmp(s_file,"")) save_to_file(s_file,&d3_l,&my_info);
+ if(strcmp(s_file,""))
+ {
+ printf("saved %s\n",s_file);
+ save_to_file(s_file,&d3_l,&my_info);
+ }
+#ifdef USE_DFB_API
while((quit==0) && (escape==0) && (nowait==0))
{
sprintf(x_txt,"x: %d",x+1);
sprintf(conc_txt,"conc: %d",*(d3_l.extra+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y));
strcpy(steps_txt,"step: end!");
sprintf(cc_txt,"total c: %d",my_info.cc);
- d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
+ d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
+ d3_lattice_release(&d3_l);
+#endif
+
return 1;
}