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 */
31 int random_fd; /* /dev/urandom file descriptor */
37 puts("-a <value> \t slope of nuclear energy loss (default 1)");
38 puts("-c <value> \t nuclear enery loss at depths 0 (default 0)");
39 puts("-x <value> \t # x cells (default 50)");
40 puts("-y <value> \t # y cells (default 50)");
41 puts("-z <value> \t # z cells (default 100)");
42 puts("-s <value> \t # steps to calculate (default 5000)");
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 puts("-d <value> \t refresh every <value> loops (default 100)");
47 puts("-r <value> \t pressure range from amorphous SiCx (default 2)");
48 puts("-f <value> \t (unused) faktor for pressure from amorphous SiCx (default 1)");
49 puts("-p <value> \t p0 for propability of cell getting amorph (default sum_range_rate / 4)");
53 int make_amorph(u32 *cell)
59 int make_cryst(u32 *cell)
65 /* look at cell ... */
66 int process_cell(void *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,int faktor,int p0)
71 cell=(u32 *)(cell_p+x+y*(x_max-1)+z*(x_max-1)*(y_max-1));
73 for(i=-range;i<=range;i++)
75 for(j=-range;j<=range;j++)
77 for(k=-range;k<=range;k++)
79 if(!(i==0 && j==0 && k==0))
81 if(*(u32 *)(cell_p+((x+x_max+i)%x_max)+((y+j+y_max)%y_max)*(x_max-1)+((z+k+z_max)%z_max)*(x_max-1)*(y_max-1))&AMORPH) count+=(3*range*range-i*i-j*j-k*k);
86 // count+=faktor*1.0/(i*i+j*j+k*k);
89 /* wrong propability! just test by now ...*/
90 if(rand_get(sum_range_rate)>count) make_cryst(cell);
93 if(rand_get(sum_range_rate)<=count) make_amorph(cell);
98 int main(int argc,char **argv)
100 u32 x_cell,y_cell,z_cell; /* amount of segments */
101 u32 x,y,z; /* cells */
102 int i,j,k; /* for counting */
103 int slope_nel,start_nel; /* nuclear energy loss: slope, constant */
104 int a_p_range,a_p_faktor,a_p_p0; /* p. range, p0 and faktor of amorphous sic */
105 int steps; /* # steps */
107 struct __display display;
108 u32 display_x,display_y,display_z; /* intercept point of diplayed areas */
109 u32 display_refresh_rate; /* refresh rate for display */
112 x_cell=DEFAULT_X_SEG;
113 y_cell=DEFAULT_Y_SEG;
114 z_cell=DEFAULT_Z_SEG;
115 slope_nel=DEFAULT_SLOPE_NEL;
116 start_nel=DEFAULT_START_NEL;
117 a_p_range=DEFAULT_A_P_RANGE;
118 a_p_faktor=DEFAULT_A_P_FAKTOR;
119 a_p_p0=NOT_SPECIFIED;
124 display_refresh_rate=DEFAULT_DISPLAY_REF_RATE;
126 /* parse command args */
138 slope_nel=atoi(argv[++i]);
141 start_nel=atoi(argv[++i]);
144 x_cell=atoi(argv[++i]);
147 y_cell=atoi(argv[++i]);
150 z_cell=atoi(argv[++i]);
153 steps=atoi(argv[++i]);
156 display_x=atoi(argv[++i]);
159 display_y=atoi(argv[++i]);
162 display_z=atoi(argv[++i]);
165 display_refresh_rate=atoi(argv[++i]);
168 a_p_range=atoi(argv[++i]);
171 a_p_faktor=atoi(argv[++i]);
174 a_p_p0=atoi(argv[++i]);
184 if((random_fd=open("/dev/urandom",O_RDONLY))<0)
186 puts("cannot open /dev/urandom\n");
190 /* calculate sum_z_cells, sum_range_rate one time! */
192 for(i=1;i<=z_cell;i++) sum_z_cells+=(start_nel+i*slope_nel);
193 printfd("debug: sum z cells -> %u\n",sum_z_cells);
195 for(i=-a_p_range;i<=a_p_range;i++)
197 for(j=-a_p_range;j<=a_p_range;j++)
199 for(k=-a_p_range;k<=a_p_range;k++)
201 if(!(i==0 && j==0 && k==0))
202 sum_range_rate+=((3*a_p_range*a_p_range)-i*i-j*j-k*k);
206 printfd("debug: sum range rate -> %u\n",sum_range_rate);
208 if(a_p_p0==NOT_SPECIFIED) a_p_p0=sum_range_rate/4;
209 sum_range_rate+=a_p_p0;
215 printf("malloc will free %d bytes now ...\n",x_cell*y_cell*z_cell*sizeof(u32));
216 if((cell_p=malloc(x_cell*y_cell*z_cell*sizeof(u32)))==NULL)
218 puts("failed allocating memory for cells\n");
221 memset(cell_p,0,x_cell*y_cell*z_cell*sizeof(u32));
224 display_init(x_cell,y_cell,z_cell,&display,cell_p,&argc,argv);
231 z=rand_get_lgp(slope_nel,start_nel);
234 // distrib_c_conc(cell_p);
236 // process_cell((u32 *)(cell_p+x+y*(x_cell-1)+z*(x_cell-1)*(y_cell-1)));
237 process_cell(cell_p,x,y,z,x_cell,y_cell,z_cell,a_p_range,a_p_faktor,a_p_p0);
240 if((i%display_refresh_rate)==0)
241 display_draw(&display,display_x,display_y,display_z);
244 /* display again and quit when button hit */
245 display_draw(&display,display_x,display_y,display_z);
246 puts("hit button to quit ...");
249 display_release(&display);