From e7c475bc213797241e1647561e8d6490b8cce358 Mon Sep 17 00:00:00 2001 From: hackbard Date: Fri, 18 Jul 2003 15:45:06 +0000 Subject: [PATCH] added a_cp faktor deleted old distrib funtion new distrib function (no backward compatibilityi) --- nlsop.c | 143 ++++++++++++++++++++++---------------------------------- nlsop.h | 5 +- 2 files changed, 58 insertions(+), 90 deletions(-) diff --git a/nlsop.c b/nlsop.c index 2d09306..c7d56e4 100644 --- a/nlsop.c +++ b/nlsop.c @@ -40,23 +40,17 @@ int usage(void) printf("-x \t # x cells (default %d)\n",X); printf("-y \t # y cells (default %d)\n",Y); printf("-z \t # z cells (default %d)\n",Z); - /* - printf("-X \t display x (default %d)\n",X/2-1); - printf("-Y \t display y (default %d)\n",Y/2-1); - printf("-Z \t display z (default %d)\n",Z/2-1); - */ printf("-s \t steps (default %d)\n",STEPS); printf("-d \t refresh display (default %d)\n",REFRESH); printf("-r \t amorphous influence range (default %d)\n",RANGE); printf("-f \t pressure = * 1/distance^2 (default %f)\n",A_AP); printf("-p \t pressure offset (default %f)\n",B_AP); + printf("-F \t proportionality constant between c conc and ability to get amorphous (default %f)\n",A_CP); printf("-A \t slope of linear c distribution (default %f)\n",A_CD); printf("-B \t linear c distribution offset (default %f)\n",B_CD); - /* - printf("-C \t initial c concentration (default %d)\n",CC); - */ printf("-D \t diffusion rate from cryst to amorph cells (default %f)\n",DR_AC); printf("-c \t diffusion rate in cryst cells (default %f)\n",DR_CC); + printf("-e \t do diffusion every steps (default %d)\n",DIFF_RATE); printf("-W \t write every steps to save file (default %d)\n",RESAVE); puts("-C \t convert file to gnuplot format"); puts("-L \t load from file"); @@ -90,7 +84,6 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info) } } p+=*conc*my_info->a_cp*URAND_MAX; - printf("debug: p = %f\n",p); if(!(*thiz&AMORPH)) { if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz); @@ -105,7 +98,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) /* double d_r,double a,double b,char z_diff) */ +int distrib_c(d3_lattice *d3_l,info *my_info) { u32 x,y,z; int i,j,k,c; @@ -115,10 +108,9 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch /* put one c ion somewhere in the lattice */ x=get_rand(d3_l->max_x); y=get_rand(d3_l->max_y); - z=get_rand_lgp(d3_l->max_z,a,b); + z=get_rand_lgp(d3_l->max_z,my_info->a_cd,my_info->b_cd); *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; - /* diffusion in layer */ for(i=0;imax_x;i++) { for(j=0;jmax_y;j++) @@ -126,24 +118,16 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch for(k=0;kmax_z;k++) { offset=i+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; - /* case amorph */ + /* case amorph - amorph <-> cryst diffusion */ if(*(d3_l->status+offset)&AMORPH) { - /* look at neighbours and move c ions */ for(c=-1;c<=1;c++) { if(c!=0) { off=((i+d3_l->max_x+c)%d3_l->max_x)+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; carry=0; - /* case neighbour not amorph */ - if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off))); - /* case neighbour amorph */ - /* - * no diffusion between amorphous cells - * - else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; - */ + if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); if(carry!=0) { *(d3_l->extra+offset)+=carry; @@ -157,15 +141,7 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch { off=i+((j+c+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; carry=0; - /* case neighbour not amorph */ - if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off))); - /* case neighbour amorph */ - /* - * - * no diffusion between amorphous cells - * - else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; - */ + if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); if(carry!=0) { *(d3_l->extra+offset)+=carry; @@ -173,17 +149,32 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch } } } + if(my_info->z_diff) + { + for(c=-1;c<=1;c++) + { + if(c!=0) + { + off=i+j*d3_l->max_x+((k+c+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y; + carry=0; + if(!*(d3_l->status+off)&AMORPH) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off))); + if(carry!=0) + { + *(d3_l->extra+off)-=carry; + *(d3_l->extra+offset)+=carry; + } + } + } + } } else - /* case not amorph */ + /* case not amorph - cryst <-> cryst diffusion */ { - /* look at neighbours and move c ions */ for(c=-1;c<=1;c++) { if(c!=0) { off=i+((j+c+d3_l->max_y)%d3_l->max_y)*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; carry=0; - /* case neighbour not amorph */ if(!(*(d3_l->status+off)&AMORPH)) { carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; @@ -201,7 +192,6 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch { off=((i+c+d3_l->max_x)%d3_l->max_x)+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y; carry=0; - /* case neighbour not amorph */ if(!(*(d3_l->status+off)&AMORPH)) { carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2; @@ -213,21 +203,6 @@ int distrib_c(d3_lattice *d3_l,info *my_info) /* double d_r,double a,double b,ch } } } - /* cryst -> amorph diffusion in z direction */ - if(z_diff) - { - for(c=1;c>=-1;c--) - { - off=i+j*d3_l->max_x+((k+c+d3_l->max_z)%d3_l->max_z)*d3_l->max_x*d3_l->max_y; - carry=0; - if(*(d3_l->status+off)&AMORPH) carry=(int)(d_r*(*(d3_l->extra+offset))); - if(carry!=0) - { - *(d3_l->extra+offset)-=carry; - *(d3_l->extra+off)+=carry; - } - } - } /* if z_diff */ } } /* for z */ } /* for y */ @@ -398,9 +373,9 @@ int main(int argc,char **argv) char el_txt[MAX_TXT]; char cd_txt[MAX_TXT]; char r_txt[MAX_TXT]; - char ap2_txt[MAX_TXT]; - char cd2_txt[MAX_TXT]; - char el2_txt[MAX_TXT]; + char cp_txt[MAX_TXT]; + char zdiff_txt[MAX_TXT]; + char diff_txt[MAX_TXT]; char dr_ac_txt[MAX_TXT]; char dr_cc_txt[MAX_TXT]; char mode_txt[MAX_TXT]; @@ -424,9 +399,11 @@ int main(int argc,char **argv) my_info.b_cd=B_CD; my_info.a_ap=A_AP; my_info.b_ap=B_AP; + my_info.a_cp=A_CP; my_info.cc=CC; my_info.dr_ac=DR_AC; my_info.dr_cc=DR_CC; + my_info.diff_rate=DIFF_RATE; nowait=0; quit=0; escape=0; @@ -466,18 +443,9 @@ int main(int argc,char **argv) case 'z': d3_l.max_z=atoi(argv[++i]); break; - /* - case 'X': - x=atoi(argv[++i]); - break; - case 'Y': - y=atoi(argv[++i]); - break; - */ case 'Z': my_info.z_diff=1; break; - /* */ case 's': my_info.steps=atoi(argv[++i]); break; @@ -493,17 +461,15 @@ int main(int argc,char **argv) case 'p': my_info.b_ap=atof(argv[++i]); break; + case 'F': + my_info.a_cp=atof(argv[++i]); + break; case 'A': my_info.a_cd=atof(argv[++i]); break; case 'B': my_info.b_cd=atof(argv[++i]); break; - /* - case 'C': - my_info.cc=atoi(argv[++i]); - break; - */ case 'W': resave=atoi(argv[++i]); break; @@ -518,6 +484,9 @@ int main(int argc,char **argv) case 'c': my_info.dr_cc=atof(argv[++i]); break; + case 'e': + my_info.diff_rate=atoi(argv[++i]); + break; case 'L': strcpy(l_file,argv[++i]); break; @@ -594,14 +563,14 @@ int main(int argc,char **argv) strcpy(a_txt,"args:"); sprintf(s_txt,"steps: %d",my_info.steps); sprintf(r_txt,"pressure range: %d",my_info.range); - sprintf(ap_txt,"pressure faktor: %.2f",my_info.a_ap); - sprintf(ap2_txt,"pressure offset: %.2f",my_info.b_ap); - sprintf(el_txt,"energy loss slope: %.2f",my_info.a_el); - 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_ac_txt,"a/c diffusion rate: %.2f",my_info.dr_ac); - sprintf(dr_cc_txt,"c/c diffusion rate: %.2f",my_info-dr_cc); + sprintf(ap_txt,"a_ap: %.2f b_ap: %.3f",my_info.a_ap,my_info.b_ap); + sprintf(el_txt,"a_el: %.2f b_el: %.3f",my_info.a_el,my_info.b_el); + sprintf(cd_txt,"a_cd: %.2f b_cd: %.3f",my_info.a_cd,my_info.b_cd); + sprintf(cp_txt,"a_cp: %.4f",my_info.a_cp); + sprintf(dr_ac_txt,"a/c diffusion rate: %.4f",my_info.dr_ac); + sprintf(dr_cc_txt,"c/c diffusion rate: %.4f",my_info.dr_cc); + sprintf(zdiff_txt,"diffusion in z direction: %c",my_info.z_diff?'y':'n'); + sprintf(diff_txt,"diffusion every %d steps",my_info.diff_rate); strcpy(mode_txt,"view: a/c mode"); arg_v[1]=xyz_txt; arg_v[2]=NULL; @@ -613,20 +582,20 @@ int main(int argc,char **argv) arg_v[8]=steps_txt; arg_v[9]=cc_txt; arg_v[10]=NULL; - arg_v[11]=NULL; - arg_v[12]=NULL; + arg_v[11]=diff_txt; + arg_v[12]=zdiff_txt; arg_v[13]=NULL; arg_v[14]=a_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; + arg_v[18]=el_txt; + arg_v[19]=cd_txt; + arg_v[20]=cp_txt; + arg_v[21]=dr_ac_txt; + arg_v[22]=dr_cc_txt; + arg_v[23]=NULL; + arg_v[24]=NULL; #endif if(!strcmp(l_file,"")) @@ -637,7 +606,7 @@ int main(int argc,char **argv) x_c=get_rand(d3_l.max_x); 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); + if(i%my_info.diff_rate==0) distrib_c(&d3_l,&my_info); process_cell(&d3_l,x_c,y_c,z_c,&my_info); #ifdef USE_DFB_API if(i%refresh==0) @@ -685,9 +654,7 @@ int main(int argc,char **argv) if(switchmode==1) mode=1; if(switchmode==2) mode=2; /* end of bahh! */ - 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)); strcpy(steps_txt,"step: end!"); diff --git a/nlsop.h b/nlsop.h index 3cd94e6..2f25a6a 100644 --- a/nlsop.h +++ b/nlsop.h @@ -12,7 +12,7 @@ typedef unsigned int u32; typedef struct __info { - int cc,steps,range; + int cc,steps,range,diff_rate; double a_el,b_el,a_cd,b_cd,a_ap,b_ap,a_cp,dr_ac,dr_cc; char z_diff; } info; @@ -38,9 +38,10 @@ typedef struct __info #define DR_AC .5 #define DR_CC .2 +#define DIFF_RATE 100 #define A_AP .1 -#define B_AP .01 +#define B_AP .0 #define A_CP .01 -- 2.39.2