printf("-p <value> \t pressure offset (default %f)\n",B_AP);
printf("-A <value> \t slope of linear c distribution (default %f)\n",A_CD);
printf("-B <value> \t linear c distribution offset (default %f)\n",B_CD);
+ /*
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);
puts("-L <file> \t load from file");
puts("-S <file> \t save to file");
puts("-R <file> \t read from random file");
if(get_rand(URAND_MAX)<=p)
{
MAKE_AMORPH(thiz);
- *t_c=*t_c+1-*conc;
- } else *t_c+=1;
+ // *t_c=*t_c+1-*conc;
+ } // else *t_c+=1;
} else
{
/* assume 1-p probability */
if(get_rand(URAND_MAX)>p)
{
MAKE_CRYST(thiz);
- *t_c=*t_c+1+*conc;
- } else *t_c+=1;
+ // *t_c=*t_c+1+*conc;
+ } // else *t_c+=1;
}
+
+ *t_c+=1;
return 1;
}
-int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
+int distrib_c(d3_lattice *d3_l,double d_r,double a,double b)
+{
+ u32 x,y,z;
+ int i,j,k,c;
+ int offset,off;
+ int carry;
+
+ /* 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);
+ *(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;i<d3_l->max_x;i++)
+ {
+ for(j=0;j<d3_l->max_y;j++)
+ {
+ for(k=0;k<d3_l->max_z;k++)
+ {
+ offset=i+j*d3_l->max_x+k*d3_l->max_x*d3_l->max_y;
+ /* case amorph */
+ 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;
+ /* case neighbour not amorph */
+ if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off)));
+ /* case neighbour amorph */
+ else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2;
+ if(carry!=0)
+ {
+ *(d3_l->extra+offset)+=carry;
+ *(d3_l->extra+off)-=carry;
+ }
+ }
+ }
+ 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;
+ /* case neighbour not amorph */
+ if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(d_r*(*(d3_l->extra+off)));
+ /* case neighbour amorph */
+ else carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2;
+ if(carry!=0)
+ {
+ *(d3_l->extra+offset)+=carry;
+ *(d3_l->extra+off)-=carry;
+ }
+ }
+ }
+ } else
+ /* case not amorph */
+ {
+ /* 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;
+ /* case neighbour not amorph */
+ if(!(*(d3_l->status+off)&AMORPH))
+ {
+ carry=(*(d3_l->extra+off)-*(d3_l->extra+offset))/2;
+ if(carry!=0)
+ {
+ *(d3_l->extra+offset)+=carry;
+ *(d3_l->extra+off)-=carry;
+ }
+ }
+ }
+ }
+ }
+ } /* for z */
+ } /* for y */
+ } /* for x */
+
+ 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;
char ap2_txt[MAX_TXT];
char cd2_txt[MAX_TXT];
char el2_txt[MAX_TXT];
+ char dr_txt[MAX_TXT];
char *arg_v[MAX_ARGV];
d3_lattice d3_l;
info my_info;
my_info.a_ap=A_AP;
my_info.b_ap=B_AP;
my_info.cc=CC;
+ my_info.d_r=D_R;
nowait=0;
quit=0;
escape=0;
case 'B':
my_info.b_cd=atof(argv[++i]);
break;
+ /*
case 'C':
my_info.cc=atoi(argv[++i]);
break;
+ */
+ case 'D':
+ my_info.d_r=atof(argv[++i]);
+ break;
case 'L':
strcpy(l_file,argv[++i]);
break;
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);
arg_v[1]=x_txt;
arg_v[2]=y_txt;
arg_v[3]=z_txt;
arg_v[21]=el2_txt;
arg_v[22]=cd_txt;
arg_v[23]=cd2_txt;
+ arg_v[24]=dr_txt;
if(!strcmp(l_file,""))
{
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.cc,my_info.a_cd,my_info.b_cd);
+ distrib_c(&d3_l,my_info.d_r,my_info.a_cd,my_info.b_cd);
process_cell(&d3_l,x_c,y_c,z_c,my_info.range,my_info.a_ap,my_info.b_ap,&(my_info.cc));
if(i%refresh==0)
{
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);
sprintf(cc_txt,"total c: %d",my_info.cc);
- d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
+ d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
// scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
i++;
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!");
sprintf(cc_txt,"total c: %d",my_info.cc);
- d3_lattice_draw(&d3_l,x,y,z,23,arg_v);
+ d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}