From: hackbard Date: Wed, 20 Jul 2005 11:06:58 +0000 (+0000) Subject: reimplemented the ratio amount X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14374155cd4de4412e2b81c5bc0ab5349e35b46d;p=physik%2Fnlsop.git reimplemented the ratio amount --- diff --git a/nlsop_client.c b/nlsop_client.c index ad1c84f..770ecb9 100644 --- a/nlsop_client.c +++ b/nlsop_client.c @@ -67,6 +67,7 @@ info *gmy_info; int *gi; unsigned char dc; unsigned char shut_down; +double c_ratio; int get_data_and_calc(t_event *event,void *allineed); int nop(t_event *event,void *allineed); @@ -104,6 +105,47 @@ int sputter(d3_lattice *d3_l) return 1; } +int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l) +{ + double all,a,b,d; + int i,k; + int p_fd; + unsigned char buf[32]; + char *p; + unsigned char c; + + if((p_fd=open(pfile,O_RDONLY))<0) + { + puts("cannot open profile file"); + return -1; + } + k=1; + d=0; + all=0; + while(k) + { + for(i=0;i<32;i++) + { + k=read(p_fd,&c,1); + buf[i]=c; + if(c=='\n') break; + } + if(k) + { + p=strtok(buf," "); + a=atof(p)/10; /* nm */ + p=strtok(NULL," "); + b=atof(p); + if(a<=d3_l->max_z*CELL_LENGTH) d+=b; + all+=b; + } + } + *c_ratio=d/all; + close(p_fd); + + return 1; +} + int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,info *my_info,u32 nel_z) { unsigned char *thiz; @@ -163,11 +205,13 @@ int distrib_c(d3_lattice *d3_l,info *my_info,int step,u32 rj_m,u32 *rj_g) 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_reject(d3_l->max_z,rj_m,rj_g); - *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; - (my_info->cc)++; + if(c_ratio*stepcc) { + x=get_rand(d3_l->max_x); + y=get_rand(d3_l->max_y); + z=get_rand_reject(d3_l->max_z,rj_m,rj_g); + *(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1; + (my_info->cc)++; + } if(step%my_info->diff_rate==0) { @@ -452,6 +496,7 @@ int get_data_and_calc(t_event *event,void *allineed) { ne_max=0; ip_max=0; do_sputter=1; + c_ratio=0; net=gnet; gd3_l=&d3_l; @@ -575,6 +620,11 @@ int get_data_and_calc(t_event *event,void *allineed) { printf("warning: max_z (%d) too small, there may be amorphous volumes\n", d3_l.max_z); + /* maybe we need a ratio! */ + if(!do_sputter) { + get_c_ratio(&c_ratio,p_file,&my_info,&d3_l); + } + /* * start of simulation */