implemented plot support for carbon concentration in amorphous, crystalline or both...
[physik/nlsop.git] / nlsop.c
diff --git a/nlsop.c b/nlsop.c
index 9b9f803..5d44239 100644 (file)
--- a/nlsop.c
+++ b/nlsop.c
@@ -328,6 +328,43 @@ int calc_max_extra(d3_lattice *d3_l)
  return max;
 }
 
+int write_ac_distr(d3_lattice *d3_l,int ac_distr)
+{
+ int fd,x,y,z;
+ int count=0,offset;
+ char file[16];
+
+ if(ac_distr==1) strcpy(file,"a.plot");
+ if(ac_distr==2) strcpy(file,"c.plot");
+ if(ac_distr==3) strcpy(file,"b.plot");
+
+ if((fd=open(file,O_WRONLY|O_CREAT))<0)
+ {
+  puts("cannot open plot file");
+  return -1;
+ }
+
+ for(z=0;z<d3_l->max_z;z++)
+ {
+  for(x=0;x<d3_l->max_x;x++)
+  {
+   for(y=0;y<d3_l->max_y;y++)
+   {
+    offset=x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y;
+    if(ac_distr==1)
+     if(*(d3_l->status+offset)&AMORPH) count+=*(d3_l->extra+offset);
+    if(ac_distr==2)
+     if(!(*(d3_l->status+offset)&AMORPH)) count+=*(d3_l->extra+offset);
+    if(ac_distr==3) count+=*(d3_l->extra+offset);
+   }
+  }
+  dprintf(fd,"%d %d\n",z,count);
+ }
+ close(fd);
+ return 1;
+}
+
 int write_bmp(d3_lattice *d3_l,int window,u32 x,u32 y,u32 z)
 {
  int fd,i,j,size=0,foo=0,end=0;
@@ -658,7 +695,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,j,quit,escape,switchmode,nowait,bmp;
+ int i,j,quit,escape,switchmode,nowait,bmp,ac_distr;
  int refresh,resave;
  int c_step;
  char s_file[MAX_CHARS];
@@ -1002,9 +1039,10 @@ int main(int argc,char **argv)
   if(switchmode==2) strcpy(mode_txt,"view: a pressure mode");
   d3_lattice_draw(&d3_l,x,y,z,25,arg_v,mode,max_extra);
   bmp=0;
-  scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp);
+  ac_distr=0;
+  scan_event(&d3_l,&x,&y,&z,&quit,&escape,&switchmode,&bmp,&ac_distr);
   if(bmp) write_bmp(&d3_l,bmp,x,y,z);
-
+  if(ac_distr) write_ac_distr(&d3_l,ac_distr);
  }
 
  d3_lattice_release(&d3_l);