/*
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("-D <value> \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC);
+ printf("-c <value> \t diffusion rate in cryst cells (default %f)\n",DR_CC);
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");
+ puts("-P <file> \t specify implantatin profile file");
return 1;
}
-int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int *t_c)
+int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info)
{
unsigned char *thiz;
int *conc;
thiz=d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
conc=d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
- p=b*URAND_MAX;
- for(i=-r;i<=r;i++)
+ p=my_info->b_ap*URAND_MAX;
+ for(i=-(my_info->range);i<=my_info->range;i++)
{
- for(j=-r;j<=r;j++)
+ for(j=-(my_info->range);j<=my_info->range;j++)
{
if(!(i==0 && j==0))
{
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);
+ if(*(d3_l->status+off)&AMORPH) p+=my_info->a_ap*(*(d3_l->extra+off))*URAND_MAX/(i*i+j*j);
}
}
}
+ p+=*conc*my_info->a_cp*URAND_MAX;
printf("debug: p = %f\n",p);
if(!(*thiz&AMORPH))
{
if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz);
}
- *t_c+=1;
+ my_info->cc+=1;
return 1;
}
-int distrib_c(d3_lattice *d3_l,double d_r,double a,double b,char z_diff)
+int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,char z_diff) */
{
u32 x,y,z;
int i,j,k,c;
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;
- int temp,left;
- int *area_h;
- u32 x,y,z;
-
- area=d3_l->max_x*d3_l->max_y;
- area_h=(int *)malloc(d3_l->max_z*sizeof(int));
-
- total=0;
- sum=b*d3_l->max_z+a*d3_l->max_z*(d3_l->max_z+1)/2;
- for(i=0;i<d3_l->max_z;i++)
- {
- area_h[i]=0;
- for(j=0;j<area;j++)
- {
- if(!(*(d3_l->status+(i*area)+j)&AMORPH))
- {
- area_h[i]+=1;
- }
- }
- temp=(int)((i+1)*a+b)*t_c/(sum*area_h[i]);
- for(j=0;j<area;j++)
- {
- if(!(*(d3_l->status+(i*area)+j)&AMORPH))
- {
- *(d3_l->extra+(i*area)+j)=temp;
- total+=temp;
- }
- }
- left=(int)(((i+1)*a+b)*t_c/sum)%area_h[i];
- while(left)
- {
- x=get_rand(d3_l->max_x);
- y=get_rand(d3_l->max_y);
- if(!(*(d3_l->status+(i*area)+x+y*d3_l->max_x)&AMORPH))
- {
- *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1;
- total+=1;
- left-=1;
- }
- }
- }
- left=t_c-total;
- while(left)
- {
- x=get_rand(d3_l->max_x);
- y=get_rand(d3_l->max_y);
- z=get_rand_lgp(d3_l->max_z,a,b);
- if(!(*(d3_l->status+x+y*d3_l->max_x+z*area)&AMORPH))
- {
- *(d3_l->extra+x+y*d3_l->max_x+z*area)+=1;
- left-=1;
- }
- }
- free(area_h);
-
- return 1;
-}
-
int save_to_file(char *sf,d3_lattice *d3_l,info *my_inf)
{
int sf_fd,c;
u32 x,y,z,x_c,y_c,z_c;
int i,quit,escape,switchmode,nowait;
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 p_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 xyz_txt[MAX_TXT];
char status_txt[MAX_TXT];
char conc_txt[MAX_TXT];
char steps_txt[MAX_TXT];
char ap2_txt[MAX_TXT];
char cd2_txt[MAX_TXT];
char el2_txt[MAX_TXT];
- char dr_txt[MAX_TXT];
+ char dr_ac_txt[MAX_TXT];
+ char dr_cc_txt[MAX_TXT];
char mode_txt[MAX_TXT];
char *arg_v[MAX_ARGV];
#endif
my_info.range=RANGE;
refresh=REFRESH;
resave=RESAVE;
- z_diff=0;
+ my_info.z_diff=0;
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;
+ my_info.dr_ac=DR_AC;
+ my_info.dr_cc=DR_CC;
nowait=0;
quit=0;
escape=0;
strcpy(s_file,"");
strcpy(l_file,"");
strcpy(c_file,"");
+ strcpy(p_file,IMP_PROFILE);
convert=0;
strcpy(r_file,"");
mode=0;
break;
*/
case 'Z':
- z_diff=1;
+ my_info.z_diff=1;
break;
/* */
case 's':
convert=1;
break;
case 'D':
- my_info.d_r=atof(argv[++i]);
+ my_info.dr_ac=atof(argv[++i]);
+ break;
+ case 'c':
+ my_info.dr_cc=atof(argv[++i]);
break;
case 'L':
strcpy(l_file,argv[++i]);
case 'R':
strcpy(r_file,argv[++i]);
break;
+ case 'P':
+ strcpy(p_file,argv[++i]);
+ break;
default:
usage();
return -1;
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);
+ sprintf(dr_ac_txt,"a/c diffusion rate: %.2f",my_info.dr_ac);
+ sprintf(dr_cc_txt,"c/c diffusion rate: %.2f",my_info-dr_cc);
strcpy(mode_txt,"view: a/c mode");
- arg_v[1]=x_txt;
- arg_v[2]=y_txt;
- arg_v[3]=z_txt;
- arg_v[4]=NULL;
- arg_v[5]=status_txt;
- arg_v[6]=conc_txt;
+ arg_v[1]=xyz_txt;
+ arg_v[2]=NULL;
+ arg_v[3]=status_txt;
+ arg_v[4]=conc_txt;
+ arg_v[5]=NULL;
+ arg_v[6]=mode_txt;
arg_v[7]=NULL;
- arg_v[8]=mode_txt;
- arg_v[9]=NULL;
- arg_v[10]=steps_txt;;
- arg_v[11]=cc_txt;
+ arg_v[8]=steps_txt;
+ arg_v[9]=cc_txt;
+ arg_v[10]=NULL;
+ arg_v[11]=NULL;
arg_v[12]=NULL;
arg_v[13]=NULL;
arg_v[14]=a_txt;
- arg_v[15]=NULL;
- arg_v[16]=s_txt;
- arg_v[17]=r_txt;
- arg_v[18]=ap_txt;
- arg_v[19]=ap2_txt;
- arg_v[20]=el_txt;
- arg_v[21]=el2_txt;
- arg_v[22]=cd_txt;
- arg_v[23]=cd2_txt;
- arg_v[24]=dr_txt;
+ arg_v[15]=s_txt;
+ arg_v[16]=r_txt;
+ arg_v[17]=ap_txt;
+ arg_v[18]=ap2_txt;
+ arg_v[19]=el_txt;
+ arg_v[20]=el2_txt;
+ arg_v[21]=cd_txt;
+ arg_v[22]=cd2_txt;
+ arg_v[23]=dr_ac_txt;
+ arg_v[24]=dr_cc_txt;
#endif
if(!strcmp(l_file,""))
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.d_r,my_info.a_cd,my_info.b_cd,z_diff);
- process_cell(&d3_l,x_c,y_c,z_c,my_info.range,my_info.a_ap,my_info.b_ap,&(my_info.cc));
+ process_cell(&d3_l,x_c,y_c,z_c,&my_info);
#ifdef USE_DFB_API
if(i%refresh==0)
{
- sprintf(x_txt,"x: %d",x+1);
- sprintf(y_txt,"y: %d",y+1);
- sprintf(z_txt,"z: %d",z+1);
+ sprintf(xyz_txt,"x: %d y: %d z: %d",x+1,y+1,z+1);
sprintf(status_txt,"status: %c",(*(d3_l.status+x+y*d3_l.max_x+z*d3_l.max_x*d3_l.max_y)&AMORPH)?'a':'c');
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);
d3_lattice_draw(&d3_l,x,y,z,24,arg_v,mode);
}
#endif
- if(i%resave==0 && strcmp(s_file,"") && resave!=0)
+ if(i%resave==0 && strcmp(s_file,"") && resave!=0 && i!=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);