implemented "collisions per ion" variable. new defaults. bugfixed z-diff.
authorhackbard <hackbard>
Wed, 24 Mar 2004 10:44:34 +0000 (10:44 +0000)
committerhackbard <hackbard>
Wed, 24 Mar 2004 10:44:34 +0000 (10:44 +0000)
nlsop.c
nlsop.h

diff --git a/nlsop.c b/nlsop.c
index 243cd92..9b9f803 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
 #define MAKE_AMORPH(N) *(N)|=AMORPH
 #define MAKE_CRYST(N) *(N)&=~AMORPH
 
-/* test globals - get removed or included in my_info struct later */
-int amorph_count;
-int cryst_count;
-unsigned char c_diff;
-
 int usage(void)
 {
  puts("usage:");
@@ -83,6 +78,7 @@ int usage(void)
  puts("-S <file> \t save to file");
  puts("-R <file> \t read from random file");
  puts("-P <file> \t specify implantation profile file");
+ printf("-H <value> \t collisions per ion in simulation window (default %d)\n",CPI);
  
  return 1;
 }
@@ -112,19 +108,11 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info)
  p+=*conc*my_info->a_cp*URAND_MAX;
  if(!(*thiz&AMORPH))
  {
-  if(get_rand(URAND_MAX)<=p)
-  {
-   MAKE_AMORPH(thiz);
-   amorph_count++;
-  }
+  if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz);
  } else
  {
   /* assume 1-p probability */
-  if(get_rand(URAND_MAX)>p)
-  {
-   MAKE_CRYST(thiz);
-   cryst_count++;
-  }
+  if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz);
  }
  
  return 1;
@@ -180,7 +168,7 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio)
       {
        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;
-       if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));                             
+       if(!(*(d3_l->status+off)&AMORPH)) carry=(int)(my_info->dr_ac*(*(d3_l->extra+off)));
        if(carry!=0)
        {
         *(d3_l->extra+offset)+=carry; 
@@ -190,27 +178,33 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,double c_ratio)
      }
      if(my_info->z_diff)
      {
-      for(c=-1;c<=1;c++)
+      if(k!=0)
       {
-       if(c!=0)
+       off=i+j*d3_l->max_x+(k-1)*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)
        {
-        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;
-        }
+        *(d3_l->extra+off)-=carry;
+        *(d3_l->extra+offset)+=carry;
+       }
+      }
+      if(k!=d3_l->max_z-1)
+      {
+       off=i+j*d3_l->max_x+(k+1)*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: cryst <-> cryst diffusion */
-
-    /* test ! */
-    if(c_diff) {
-    /* */
+    if(my_info->c_diff) {
+    /* if there is c diff, no diff in z-direction */
     {
      for(c=-1;c<=1;c++) 
      {
@@ -664,7 +658,7 @@ int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l)
 int main(int argc,char **argv)
 {
  u32 x,y,z,x_c,y_c,z_c;
- int i,quit,escape,switchmode,nowait,bmp;
+ int i,j,quit,escape,switchmode,nowait,bmp;
  int refresh,resave;
  int c_step;
  char s_file[MAX_CHARS];
@@ -711,7 +705,7 @@ int main(int argc,char **argv)
  refresh=REFRESH;
  resave=RESAVE;
  my_info.z_diff=0;
- c_diff=1;
my_info.c_diff=1;
  my_info.a_el=A_EL;
  my_info.b_el=B_EL;
  my_info.a_cd=A_CD;
@@ -723,6 +717,7 @@ int main(int argc,char **argv)
  my_info.dr_ac=DR_AC;
  my_info.dr_cc=DR_CC;
  my_info.diff_rate=DIFF_RATE;
+ my_info.cpi=CPI;
  nowait=0;
  quit=0;
  escape=0;
@@ -736,9 +731,6 @@ int main(int argc,char **argv)
  strcpy(r_file,"");
  mode=0;
 
- amorph_count=0;
- cryst_count=0;
-
  for(i=1;i<argc;i++)
  {
   if(argv[i][0]=='-')
@@ -770,7 +762,7 @@ int main(int argc,char **argv)
      my_info.z_diff=1;
      break;
     case 'i':
-     c_diff=0;
+     my_info.c_diff=0;
      my_info.dr_cc=0;
      break;
     case 's':
@@ -830,6 +822,9 @@ int main(int argc,char **argv)
      strcpy(l_file,argv[++i]);
      if(i<argc-1) if(argv[i+1][0]!='-') c_step=atoi(argv[++i]);
      break;
+    case 'H':
+     my_info.cpi=atoi(argv[++i]);
+     break;
     default:
      usage();
      return -1;
@@ -900,7 +895,7 @@ int main(int argc,char **argv)
  sprintf(cd_txt,"a_cd: %.3f  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);
- if(my_info.dr_cc!=0) sprintf(dr_cc_txt,"c/c diffusion rate: %.4f",my_info.dr_cc);
+ if(my_info.c_diff!=0) sprintf(dr_cc_txt,"c/c diffusion rate: %.4f",my_info.dr_cc);
  else sprintf(dr_cc_txt,"c/c diffusion rate: none");
  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);
@@ -942,19 +937,22 @@ int main(int argc,char **argv)
   i=(c_step?c_step:0);
   while((i<my_info.steps) && (quit==0) && (escape==0))
   {
-   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);
+   for(j=0;j<my_info.cpi;j++)
+   {
+    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);
+    process_cell(&d3_l,x_c,y_c,z_c,&my_info);
+   }
    distrib_c(&d3_l,&my_info,i,c_ratio);
-   process_cell(&d3_l,x_c,y_c,z_c,&my_info);
 #ifdef USE_DFB_API
    if(i%refresh==0)
    {
     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  a_count: %d",i,amorph_count);
-    sprintf(cc_txt,"total c: %d  c_count: %d",my_info.cc,cryst_count);
+    sprintf(steps_txt,"step: %d",i);
+    sprintf(cc_txt,"total c: %d",my_info.cc);
     d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,0);
    }
 #endif
diff --git a/nlsop.h b/nlsop.h
index 24778fa..bb3307f 100644 (file)
--- a/nlsop.h
+++ b/nlsop.h
@@ -12,9 +12,9 @@ typedef unsigned int u32;
 
 typedef struct __info
 {
- int cc,steps,range,diff_rate;
+ int cc,steps,range,diff_rate,cpi;
  double a_el,b_el,a_cd,b_cd,a_ap,b_ap,a_cp,dr_ac,dr_cc;
- char z_diff;
+ char z_diff,c_diff;
 } info;
 
 #define AMORPH 1
@@ -22,14 +22,14 @@ typedef struct __info
 #define A_EL 1.
 #define B_EL .0
 
-#define X 50
-#define Y 50
+#define X 64
+#define Y 64
 #define Z 100
 
-#define STEPS 100000
-#define RANGE 3
-#define REFRESH 20
-#define RESAVE 10000
+#define STEPS 30000000
+#define RANGE 5
+#define REFRESH 100000
+#define RESAVE 1000000
 
 #define A_CD 1.
 #define B_CD .0
@@ -40,10 +40,10 @@ typedef struct __info
 #define DR_CC .2
 #define DIFF_RATE 100
 
-#define A_AP .1
+#define A_AP .003
 #define B_AP .0
 
-#define A_CP .01
+#define A_CP .0001
 
 #define MAX_CHARS 128
 #define MAX_TXT 32
@@ -52,6 +52,8 @@ typedef struct __info
 #define IMP_PROFILE "imp-profile.txt"
 #define CELL_LENGTH 3 /* nm */
 
+#define CPI 20
+
 #define FFT_HEIGHT 64
 
 #endif /* NLSOP_H */