X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop.c;h=07313e43f3e3a39f593ed769b012df62c9a18ebd;hp=0104695126c699b150adb0db0d3d2951dcd56ff9;hb=30343b61fc28bccc04af479729a1529fa824a85a;hpb=de3ae9b29a64eaf297b44665022665962eba4a14 diff --git a/nlsop.c b/nlsop.c index 0104695..07313e4 100644 --- a/nlsop.c +++ b/nlsop.c @@ -78,7 +78,9 @@ int usage(void) puts("-S \t save to file"); puts("-R \t read from random file"); puts("-P \t specify implantation profile file"); + puts("-N \t specify nuclear energy loss profile file"); printf("-H \t collisions per ion in simulation window (default %d)\n",CPI); + puts("-m \t specify c->a carbon saturation"); return 1; } @@ -118,7 +120,7 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info) return 1; } -int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio) +int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio,u32 rj_m,u32 *rj_g) { u32 x,y,z; int i,j,k,c; @@ -131,8 +133,9 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio) x=get_rand(d3_l->max_x); y=get_rand(d3_l->max_y); // printf("nd: %d %d\n",x,y); - z=get_rand_lgp(d3_l->max_z,my_info->a_cd,my_info->b_cd); - // printf("ld: %d\n",z); + // z=get_rand_lgp(d3_l->max_z,my_info->a_cd,my_info->b_cd); + z=get_rand_reject(d3_l->max_z,rj_m,rj_g); + // printf("%d\n",z); *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; (my_info->cc)++; } @@ -148,7 +151,7 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio) { offset=i+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; /* case amorph: amorph <- cryst diffusion */ - if(*(d3_l->status+offset)&AMORPH) + if(*(d3_l->status+offset)&AMORPH && *(d3_l->extra+offset)c_sat) { for(c=-1;c<=1;c++) { @@ -333,7 +336,7 @@ int calc_max_extra(d3_lattice *d3_l) int write_ac_distr(d3_lattice *d3_l,int ac_distr) { int fd,x,y,z; - int count=0,offset; + int count,offset; char file[16]; if(ac_distr==1) strcpy(file,"a.plot"); @@ -348,6 +351,7 @@ int write_ac_distr(d3_lattice *d3_l,int ac_distr) for(z=0;zmax_z;z++) { + count=0; for(x=0;xmax_x;x++) { for(y=0;ymax_y;y++) @@ -694,17 +698,26 @@ int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l) return 1; } -int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { +u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { double a,b; int i,j,k; int fd; char buf[32],*p; + unsigned char *flag; + u32 max; + max=0; if((fd=open(file,O_RDONLY))<0) { puts("cannot open file to calculate rejection graph"); return -1; } + if((flag=(unsigned char *)malloc(d3_l->max_z))==NULL) + { + puts("cannot malloc flag memory for rejection graph"); + return -1; + } + memset(flag,0,d3_l->max_z); memset(graph,0,d3_l->max_z*sizeof(u32)); /* get fixpoints */ k=1; @@ -722,12 +735,32 @@ int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { p=strtok(NULL," "); b=atof(p); if(a>d3_l->max_z*CELL_LENGTH) k=0; - else graph[(int)(a/CELL_LENGTH)]=(int)(URAND_MAX*b); + else + { + graph[(int)(a/CELL_LENGTH)]=(int)(URAND_MAX*b); + flag[(int)(a/CELL_LENGTH)]=1; + } } } - /* do interpolation here! */ + /* do (linear) interpolation here! */ + i=0; + a=0; + while(imax_z) + { + /* graph[0] is 0! */ + j=i; + i++; + while(flag[i]==0&&imax_z) i++; + for(k=j+1;kmax) max=graph[i]; + } - return 1; + free(flag); + + // printf("debug: (interpolated c profile)\n"); + // for(i=0;imax_z;i++) printf("%d %d\n",i,graph[i]); + + return max; } int main(int argc,char **argv) @@ -741,6 +774,7 @@ int main(int argc,char **argv) char l_file[MAX_CHARS]; char c_file[MAX_CHARS]; char p_file[MAX_CHARS]; + char n_e_file[MAX_CHARS]; char convert; char r_file[MAX_CHARS]; #ifdef USE_DFB_API @@ -771,6 +805,9 @@ int main(int argc,char **argv) #ifdef USE_DFB_API int max_extra; #endif + u32 *c_profile; + u32 *n_e_loss; + u32 ne_max,ip_max; d3_l.max_x=X; d3_l.max_y=Y; @@ -793,6 +830,7 @@ int main(int argc,char **argv) my_info.dr_cc=DR_CC; my_info.diff_rate=DIFF_RATE; my_info.cpi=CPI; + my_info.c_sat=C_SAT; nowait=0; quit=0; escape=0; @@ -802,9 +840,12 @@ int main(int argc,char **argv) strcpy(l_file,""); strcpy(c_file,""); strcpy(p_file,IMP_PROFILE); + strcpy(n_e_file,NEL_PROFILE); convert=0; strcpy(r_file,""); mode=0; + ne_max=0; + ip_max=0; for(i=1;i