4 * this program tries helping to understand the amorphous depuration
5 * and recrystallization of SiCx while ion implanation. hopefully the program
6 * will simulate the stabilization of the selforganizing structure in the
10 * - J. K. N. Lindner. Habilationsschrift, Universitaet Augsburg.
11 * - Maik Haeberlen. Diplomarbeit, Universitaet Augsburg.
17 #include <sys/types.h>
21 /* important defines */
24 /* function prototypes */
28 /* global variables */
29 u32 *rand_buf,*rand_current;
31 int random_fd; /* /dev/urandom file descriptor */
37 printf("-a <value> \t slope of nuclear energy loss (default %d)\n",DEFAULT_SLOPE_NEL);
38 printf("-c <value> \t nuclear enery loss at depths 0 (default %d)\n",DEFAULT_START_NEL);
39 printf("-x <value> \t # x cells (default %d)\n",DEFAULT_X_SEG);
40 printf("-y <value> \t # y cells (default %d)\n",DEFAULT_Y_SEG);
41 printf("-z <value> \t # z cells (default %d)\n",DEFAULT_Z_SEG);
42 printf("-s <value> \t # steps to calculate (default %d)\n",DEFAULT_STEPS);
43 puts("-X <value> \t display area intercept point x (default # x celss / 2)");
44 puts("-Y <value> \t display area intercept point y (default # y cells / 2)");
45 puts("-Z <value> \t display area intercept point z (default # z cells / 2)");
46 printf("-d <value> \t refresh every <value> loops (default %d)\n",DEFAULT_DISPLAY_REF_RATE);
47 printf("-r <value> \t pressure range from amorphous SiCx (default %d)\n",DEFAULT_A_P_RANGE);
48 printf("-f <value> \t faktor for pressure from amorphous SiCx (default %f)\n",DEFAULT_A_P_FAKTOR);
49 printf("-p <value> \t p0 for probability of cell getting amorph (default %f)\n",DEFAULT_A_P_P0);
50 printf("-C <value> \t C start concentration (default %d)\n",DEFAULT_C_DIST_START_CONC);
51 printf("-S <value> \t slope of linear C distribution (default %d)\n",DEFAULT_C_DIST_SLOPE);
55 int make_amorph(cell *cell)
61 int make_cryst(cell *cell)
63 cell->status&=~AMORPH;
67 int distrib_c_conc(cell *cell_p,int c_c0,int c_slope,u32 c_conc,u32 x_max,u32 y_max,u32 z_max)
70 u32 area,c_area,total,count;
75 sum_c_z=c_c0*z_max+c_slope*gr;
80 c_area=(c_conc*(c_c0+(i+1)*c_slope))/sum_c_z;
83 if(!(cell_p+j+i*area)->status&AMORPH) count++;
87 if(!(cell_p+j+i*area)->status&AMORPH)
89 (cell_p+j+i*area)->conc=c_area/count;
98 if(!(cell_p+x+y*x_max+i*area)->status&AMORPH)
100 (cell_p+x+y*x_max+i*area)->conc+=1;
107 while(i<c_conc-total)
111 z=rand_get_lgp(c_slope,c_c0,z_max);
112 if(!(cell_p+x+y*x_max+z*area)->status&AMORPH)
114 (cell_p+x+y*x_max+z*area)->conc+=1;
121 /* look at cell ... */
122 int process_cell(cell *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,double faktor,double p0,u32 *c_conc)
128 this_cell=cell_p+x+y*x_max+z*x_max*y_max;
129 pressure=p0*URAND_2BYTE_MAX;
131 for(i=-range;i<=range;i++)
133 for(j=-range;j<=range;j++)
135 for(k=-range;k<=range;k++)
137 if(!(i==0 && j==0 && k==0))
139 // if((cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->status&AMORPH) pressure+=(cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->conc*faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k);
140 if((cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*x_max+((z+k+z_max)%z_max)*x_max*y_max)->status&AMORPH) pressure+=faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k);
145 pressure*=this_cell->conc;
146 if(this_cell->status&AMORPH)
148 /* wrong probability! just test by now ...*/
149 if(rand_get(URAND_2BYTE_MAX)>pressure)
151 make_cryst(this_cell);
152 *c_conc=*c_conc+1+this_cell->conc;
156 if(rand_get(URAND_2BYTE_MAX)<=pressure)
158 make_amorph(this_cell);
159 *c_conc=*c_conc+1-this_cell->conc;
165 int main(int argc,char **argv)
167 u32 x_cell,y_cell,z_cell; /* amount of segments */
168 u32 x,y,z; /* cells */
169 int i; /* for counting */
170 int slope_nel,start_nel; /* nuclear energy loss: slope, constant */
171 int a_p_range; /* p. range of amorphous sic */
172 double a_p_faktor,a_p_p0; /* p0 and faktor of amorphous sic */
173 int c_dist_c0,c_dist_slope; /* c start concentration and linear slope of c distribution */
175 int steps; /* # steps */
177 struct __display display;
178 u32 display_x,display_y,display_z; /* intercept point of diplayed areas */
179 u32 display_refresh_rate; /* refresh rate for display */
180 int quit=0; /* continue/quit status */
182 printfd("debug: sizeof my u32 variable: %d\n",sizeof(u32));
183 printfd("debug: sizeof my cell struct: %d\n",sizeof(cell));
186 x_cell=DEFAULT_X_SEG;
187 y_cell=DEFAULT_Y_SEG;
188 z_cell=DEFAULT_Z_SEG;
189 slope_nel=DEFAULT_SLOPE_NEL;
190 start_nel=DEFAULT_START_NEL;
191 a_p_range=DEFAULT_A_P_RANGE;
192 a_p_faktor=DEFAULT_A_P_FAKTOR;
193 a_p_p0=DEFAULT_A_P_P0;
194 c_dist_c0=DEFAULT_C_DIST_START_CONC;
195 c_dist_slope=DEFAULT_C_DIST_SLOPE;
201 display_refresh_rate=DEFAULT_DISPLAY_REF_RATE;
203 /* parse command args */
215 slope_nel=atoi(argv[++i]);
218 start_nel=atoi(argv[++i]);
221 x_cell=atoi(argv[++i]);
224 y_cell=atoi(argv[++i]);
227 z_cell=atoi(argv[++i]);
230 steps=atoi(argv[++i]);
233 display_x=atoi(argv[++i]);
236 display_y=atoi(argv[++i]);
239 display_z=atoi(argv[++i]);
242 display_refresh_rate=atoi(argv[++i]);
245 a_p_range=atoi(argv[++i]);
248 a_p_faktor=atof(argv[++i]);
251 a_p_p0=atof(argv[++i]);
254 c_conc=atoi(argv[++i]);
257 c_dist_c0=atoi(argv[++i]);
260 c_dist_slope=atoi(argv[++i]);
270 if((random_fd=open("/dev/urandom",O_RDONLY))<0)
272 puts("cannot open /dev/urandom\n");
276 /* calculate gr one time! */
278 for(i=1;i<=z_cell;i++) gr+=i;
279 printfd("debug: gr = %d\n",gr);
281 /* allocate random number buffer */
282 printf("malloc will free %d bytes now ...\n",RAND_BUF_SIZE);
283 if((rand_buf=(u32 *)malloc(RAND_BUF_SIZE))==NULL)
285 puts("failed allocating memory for random numbers");
288 rand_current=rand_buf+RAND_BUF_SIZE;
291 printf("malloc will free %d bytes now ...\n",x_cell*y_cell*z_cell*sizeof(cell));
292 if((cell_p=(cell *)malloc(x_cell*y_cell*z_cell*sizeof(cell)))==NULL)
294 puts("failed allocating memory for cells");
297 memset(cell_p,0,x_cell*y_cell*z_cell*sizeof(cell));
300 printfd("debug: init display now ...\n");
301 display_init(x_cell,y_cell,z_cell,&display,cell_p,&argc,argv);
304 printfd("debug: starting main routine ...\n");
309 z=rand_get_lgp(slope_nel,start_nel,z_cell);
310 printfd("x = %u, y = %u, z = %u\n",x,y,z);
313 distrib_c_conc(cell_p,c_dist_c0,c_dist_slope,c_conc,x_cell,y_cell,z_cell);
315 // process_cell(cell_p+x+y*x_cell+z*x_cell*y_cell);
316 process_cell(cell_p,x,y,z,x_cell,y_cell,z_cell,a_p_range,a_p_faktor,a_p_p0,&c_conc);
319 if((i%display_refresh_rate)==0)
320 display_draw(&display,display_x,display_y,display_z);
322 printfd("debug: main routine finished!\n");
324 /* display again and listen for events */
325 display_draw(&display,display_x,display_y,display_z);
326 display_event_init(&display);
330 display_scan_event(&display,&display_x,&display_y,&display_z,&quit);
331 display_draw(&display,display_x,display_y,display_z);
334 display_release(&display);