added -W, -C
authorhackbard <hackbard>
Mon, 9 Jun 2003 19:47:33 +0000 (19:47 +0000)
committerhackbard <hackbard>
Mon, 9 Jun 2003 19:47:33 +0000 (19:47 +0000)
TODO
nlsop.c
nlsop.h

diff --git a/TODO b/TODO
index a251e3b..e0417fd 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,14 +2,10 @@ nlsop TODO
 ----------
 
 IMPORTANT:
-- ueberpruefe b_ap=0 verhalten
-- ueberpruefe code generell !!
 - durchdenke/checke diffusion
 
-- p(cryst->amorph)~druckspannung~c(C) in amorphen gebiet
 - start mit anfangsbedingungen (beschreibung aus file)
 - dfb optional (cluster mode)
-- -C: convert binary savrfile to gnuplot file
 - opengl visualisierung
 
 parameter:
diff --git a/nlsop.c b/nlsop.c
index c4fc825..81f408d 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
@@ -2,9 +2,10 @@
  * nlsop.c 
  *
  * this program tries helping to understand the amorphous depuration
- * and recrystallization of SiCx while ion implanation. hopefully the program 
- * will simulate the stabilization of the selforganizing structure in the
- * observed behaviour.
+ * and recrystallization of SiCx while ion implantation at temperatures
+ * below 400 degree celsius.
+ * hopefully the program will simulate the stabilization of the
+ * selforganizing lamella structure in the observed behaviour.
  *
  * refs: 
  *  - J. K. N. Lindner. Habilationsschrift, Universitaet Augsburg.
@@ -36,8 +37,8 @@ int usage(void)
  printf("-a <value> \t slope of nuclear energy loss (default %f)\n",A_EL);
  printf("-b <value> \t nuclear energy loss offset (default %f)\n",B_EL);
  printf("-x <value> \t # x cells (default %d)\n",X);
- printf("-y <value> \t # x cells (default %d)\n",Y);
- printf("-z <value> \t # x cells (default %d)\n",Z);
+ printf("-y <value> \t # y cells (default %d)\n",Y);
+ printf("-z <value> \t # z cells (default %d)\n",Z);
  /*
  printf("-X <value> \t display x (default %d)\n",X/2-1);
  printf("-Y <value> \t display y (default %d)\n",Y/2-1);
@@ -54,6 +55,8 @@ int usage(void)
  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("-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");
@@ -66,6 +69,7 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
  unsigned char *thiz;
  int *conc;
  int i,j;
+ int off;
  double p;
 
  thiz=d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
@@ -77,25 +81,19 @@ int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
   {
    if(!(i==0 && j==0))
    {
-    if(*(d3_l->status+((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)&AMORPH) p+=a*URAND_MAX/(i*i+j*j);
+    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);
    } 
   }
  }
+ // printf("debug: p = %f\n",p);
  if(!(*thiz&AMORPH))
  {
-  if(get_rand(URAND_MAX)<=p)
-  {
-   MAKE_AMORPH(thiz);
-   // *t_c=*t_c+1-*conc;
-  } // else *t_c+=1;
+  if(get_rand(URAND_MAX)<=p) MAKE_AMORPH(thiz);
  } else
  {
   /* assume 1-p probability */
-  if(get_rand(URAND_MAX)>p)
-  {
-   MAKE_CRYST(thiz);
-   // *t_c=*t_c+1+*conc;
-  } // else *t_c+=1;
+  if(get_rand(URAND_MAX)>p) MAKE_CRYST(thiz);
  }
  
  *t_c+=1;
@@ -133,10 +131,15 @@ int distrib_c(d3_lattice *d3_l,double d_r,double a,double b)
       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(carry!=0)
        {
         *(d3_l->extra+offset)+=carry;
@@ -149,10 +152,16 @@ int distrib_c(d3_lattice *d3_l,double d_r,double a,double b)
       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=(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(carry!=0)
        {
         *(d3_l->extra+offset)+=carry; 
@@ -169,6 +178,7 @@ int distrib_c(d3_lattice *d3_l,double d_r,double a,double b)
       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))
        {
@@ -331,13 +341,42 @@ int load_from_file(char *lf,d3_lattice *d3_l,info *my_inf)
  return 1;
 }
 
+int convert_file(char *cf,d3_lattice *d3_l)
+{
+ int x,y,z;
+ int c_fd;
+
+ if((c_fd=open(cf,O_WRONLY|O_CREAT))<0)
+ {
+  puts("cannot open convert file");
+  return -1;
+ }
+ dprintf(c_fd,"# created by nlsop (gnuplot format)\n");
+ for(x=0;x<d3_l->max_x;x++)
+ {
+  for(y=0;y<d3_l->max_y;y++)
+  {
+   for(z=0;z<d3_l->max_z;z++)
+   {
+    if(*(d3_l->status+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)&AMORPH) dprintf(c_fd,"%d %d %d\n",x,y,z);
+   }
+  }
+ }
+ close(c_fd);
+
+ return 1;
+}
+
 int main(int argc,char **argv)
 {
  u32 max_x,max_y,max_z,x,y,z,x_c,y_c,z_c;
  int i,quit,escape,nowait;
- int refresh;
+ int refresh,resave;
  char s_file[MAX_CHARS];
+ char s_file_tmp[MAX_CHARS];
  char l_file[MAX_CHARS];
+ char c_file[MAX_CHARS];
+ char convert;
  char r_file[MAX_CHARS];
  char x_txt[MAX_TXT];
  char y_txt[MAX_TXT];
@@ -366,6 +405,7 @@ int main(int argc,char **argv)
  my_info.steps=STEPS;
  my_info.range=RANGE;
  refresh=REFRESH;
+ resave=RESAVE;
  my_info.a_el=A_EL;
  my_info.b_el=B_EL;
  my_info.a_cd=A_CD;
@@ -379,6 +419,8 @@ int main(int argc,char **argv)
  escape=0;
  strcpy(s_file,"");
  strcpy(l_file,"");
+ strcpy(c_file,"");
+ convert=0;
  strcpy(r_file,"");
 
  for(i=1;i<argc;i++)
@@ -445,6 +487,14 @@ int main(int argc,char **argv)
      my_info.cc=atoi(argv[++i]);
      break;
     */
+    case 'W':
+     resave=atoi(argv[++i]);
+     break;
+    case 'C':
+     strcpy(l_file,argv[++i]);
+     if(i<argc-1) if(argv[i+1][0]!='-') strcpy(c_file,argv[++i]);
+     convert=1;
+     break;
     case 'D':
      my_info.d_r=atof(argv[++i]);
      break;
@@ -492,9 +542,16 @@ int main(int argc,char **argv)
  } else
  {
   load_from_file(l_file,&d3_l,&my_info);
-  d3_lattice_init(&argc,argv,&d3_l,d3_l.max_x,d3_l.max_y,d3_l.max_z);
+  if(convert) 
+  {   
+   if(!strcmp(c_file,"")) sprintf(c_file,"%s_gnuplot",l_file);
+   printf("converting file %s to %s\n",l_file,c_file);
+   convert_file(c_file,&d3_l);
+   puts("done");
+   return 1;
+  } else d3_lattice_init(&argc,argv,&d3_l,d3_l.max_x,d3_l.max_y,d3_l.max_z);
  }
-
  d3_event_init(&d3_l);
 
  strcpy(a_txt,"args:");
@@ -554,6 +611,11 @@ int main(int argc,char **argv)
     d3_lattice_draw(&d3_l,x,y,z,24,arg_v);
     // scan_event(&d3_l,&x,&y,&z,&quit,&escape);
    }
+   if(i%resave==0 && strcmp(s_file,"") && resave!=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);
+   }
    i++;
   }
  }
diff --git a/nlsop.h b/nlsop.h
index 35989b3..979d425 100644 (file)
--- a/nlsop.h
+++ b/nlsop.h
@@ -28,6 +28,7 @@ typedef struct __info
 #define STEPS 100000
 #define RANGE 3
 #define REFRESH 20
+#define RESAVE 10000
 
 #define A_CD 1.
 #define B_CD .0
@@ -37,7 +38,7 @@ typedef struct __info
 #define D_R .5
 
 #define A_AP .1
-#define B_AP .2
+#define B_AP .01
 
 #define MAX_CHARS 64
 #define MAX_TXT 32