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 */
30 int random_fd; /* /dev/urandom file descriptor */
36 printf("-a <value> \t slope of nuclear energy loss (default %d)\n",DEFAULT_SLOPE_NEL);
37 printf("-c <value> \t nuclear enery loss at depths 0 (default %d)\n",DEFAULT_START_NEL);
38 printf("-x <value> \t # x cells (default %d)\n",DEFAULT_X_SEG);
39 printf("-y <value> \t # y cells (default %d)\n",DEFAULT_Y_SEG);
40 printf("-z <value> \t # z cells (default %d)\n",DEFAULT_Z_SEG);
41 printf("-s <value> \t # steps to calculate (default %d)\n",DEFAULT_STEPS);
42 puts("-X <value> \t display area intercept point x (default # x celss / 2)");
43 puts("-Y <value> \t display area intercept point y (default # y cells / 2)");
44 puts("-Z <value> \t display area intercept point z (default # z cells / 2)");
45 printf("-d <value> \t refresh every <value> loops (default %d)\n",DEFAULT_DISPLAY_REF_RATE);
46 printf("-r <value> \t pressure range from amorphous SiCx (default %d)\n",DEFAULT_A_P_RANGE);
47 printf("-f <value> \t faktor for pressure from amorphous SiCx (default %f)\n",DEFAULT_A_P_FAKTOR);
48 printf("-p <value> \t p0 for probability of cell getting amorph (default %f)\n",DEFAULT_A_P_P0);
52 int make_amorph(u32 *cell)
58 int make_cryst(u32 *cell)
64 /* look at cell ... */
65 int process_cell(void *cell_p,u32 x,u32 y,u32 z,u32 x_max,u32 y_max,u32 z_max,int range,double faktor,double p0)
70 cell=(u32 *)(cell_p+x+y*(x_max-1)+z*(x_max-1)*(y_max-1));
71 pressure=p0*URAND_2BYTE_MAX;
72 for(i=-range;i<=range;i++)
74 for(j=-range;j<=range;j++)
76 for(k=-range;k<=range;k++)
78 if(!(i==0 && j==0 && k==0))
80 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) pressure+=faktor*URAND_2BYTE_MAX/(i*i+j*j+k*k);
87 /* wrong probability! just test by now ...*/
88 if(rand_get(URAND_2BYTE_MAX)>pressure) make_cryst(cell);
91 if(rand_get(URAND_2BYTE_MAX)<=pressure) make_amorph(cell);
96 int main(int argc,char **argv)
98 u32 x_cell,y_cell,z_cell; /* amount of segments */
99 u32 x,y,z; /* cells */
100 int i; /* for counting */
101 int slope_nel,start_nel; /* nuclear energy loss: slope, constant */
102 int a_p_range; /* p. range of amorphous sic */
103 double a_p_faktor,a_p_p0; /* p0 and faktor of amorphous sic */
104 int steps; /* # steps */
106 struct __display display;
107 u32 display_x,display_y,display_z; /* intercept point of diplayed areas */
108 u32 display_refresh_rate; /* refresh rate for display */
109 int quit=0; /* continue/quit status */
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=DEFAULT_A_P_P0;
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=atof(argv[++i]);
174 a_p_p0=atof(argv[++i]);
184 if((random_fd=open("/dev/urandom",O_RDONLY))<0)
186 puts("cannot open /dev/urandom\n");
190 /* calculate sum_z_cells 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);
198 printf("malloc will free %d bytes now ...\n",x_cell*y_cell*z_cell*sizeof(u32));
199 if((cell_p=malloc(x_cell*y_cell*z_cell*sizeof(u32)))==NULL)
201 puts("failed allocating memory for cells\n");
204 memset(cell_p,0,x_cell*y_cell*z_cell*sizeof(u32));
207 display_init(x_cell,y_cell,z_cell,&display,cell_p,&argc,argv);
214 z=rand_get_lgp(slope_nel,start_nel);
217 // distrib_c_conc(cell_p);
219 // process_cell((u32 *)(cell_p+x+y*(x_cell-1)+z*(x_cell-1)*(y_cell-1)));
220 process_cell(cell_p,x,y,z,x_cell,y_cell,z_cell,a_p_range,a_p_faktor,a_p_p0);
223 if((i%display_refresh_rate)==0)
224 display_draw(&display,display_x,display_y,display_z);
227 /* display again and listen for events */
228 display_draw(&display,display_x,display_y,display_z);
229 display_event_init(&display);
232 for(i=0;i<x_cell*y_cell*z_cell;++i)
234 if(*(u32 *)(cell_p+i))
235 printf("%d -> 0x%x\n",i,*(u32 *)(cell_p+i));
240 display_scan_event(&display,&display_x,&display_y,&display_z,&quit);
241 display_draw(&display,display_x,display_y,display_z);
244 display_release(&display);