projects
/
physik
/
nlsop.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added ignore file
[physik/nlsop.git]
/
nlsop.c
diff --git
a/nlsop.c
b/nlsop.c
index
030db9f
..
1d2e6d6
100644
(file)
--- a/
nlsop.c
+++ b/
nlsop.c
@@
-79,7
+79,7
@@
int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
p*=*conc;
if(!(*thiz&AMORPH))
{
p*=*conc;
if(!(*thiz&AMORPH))
{
- if(
rand_get
(URAND_MAX)<=p)
+ if(
get_rand
(URAND_MAX)<=p)
{
MAKE_AMORPH(thiz);
*t_c=*t_c+1-*conc;
{
MAKE_AMORPH(thiz);
*t_c=*t_c+1-*conc;
@@
-87,7
+87,7
@@
int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
} else
{
/* assume 1-p probability */
} else
{
/* assume 1-p probability */
- if(
rand_get
(URAND_MAX)>p)
+ if(
get_rand
(URAND_MAX)>p)
{
MAKE_CRYST(thiz);
*t_c=*t_c+1+*conc;
{
MAKE_CRYST(thiz);
*t_c=*t_c+1+*conc;
@@
-99,7
+99,8
@@
int process_cell(d3_lattice *d3_l,u32 x,u32 y,u32 z,int r,double a,double b,int
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
{
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
{
- int i,j,k,total,area,sum;
+ int i,j,k,total,area;
+ double sum;
int temp,left;
int *area_h;
u32 x,y,z;
int temp,left;
int *area_h;
u32 x,y,z;
@@
-108,7
+109,7
@@
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
area_h=(int *)malloc(d3_l->max_z*sizeof(int));
total=0;
area_h=(int *)malloc(d3_l->max_z*sizeof(int));
total=0;
- sum=
0
;
+ sum=
b*d3_l->max_z+a*d3_l->max_z*(d3_l->max_z+1)/2
;
for(i=0;i<d3_l->max_z;i++)
{
area_h[i]=0;
for(i=0;i<d3_l->max_z;i++)
{
area_h[i]=0;
@@
-116,15
+117,11
@@
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
{
if(!(*(d3_l->status+(i*area)+j)&AMORPH))
{
{
if(!(*(d3_l->status+(i*area)+j)&AMORPH))
{
- sum+=(i+1)*a+b;
area_h[i]+=1;
}
}
area_h[i]+=1;
}
}
- }
- for(i=0;i<d3_l->max_z;i++)
- {
- temp=((i+1)*a+b)*t_c/(sum+area_h[i]);
- if(temp>1)
+ temp=(int)((i+1)*a+b)*t_c/(sum*area_h[i]);
+ if(temp)
{
for(j=0;j<area;j++)
{
{
for(j=0;j<area;j++)
{
@@
-138,13
+135,14
@@
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
left=(int)(((i+1)*a+b)*t_c/sum)%area_h[i];
while(left)
{
left=(int)(((i+1)*a+b)*t_c/sum)%area_h[i];
while(left)
{
- x=get_rand(d3_l->max_x);
- y=get_rand(d3_l->max_y);
- if(!(*(d3_l->status+(i*area)+x+y*d3_l->max_x)&AMORPH))
- {
- *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1;
- total+=1;
- left-=1;
+ x=get_rand(d3_l->max_x);
+ y=get_rand(d3_l->max_y);
+ if(!(*(d3_l->status+(i*area)+j)&AMORPH))
+ {
+ *(d3_l->extra+(i*area)+x+y*d3_l->max_x)+=1;
+ total+=1;
+ left-=1;
+ }
}
}
left=t_c-total;
}
}
left=t_c-total;
@@
-157,9
+155,9
@@
int distrib_c(d3_lattice *d3_l,int t_c,double a,double b)
{
*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1;
left-=1;
{
*(d3_l->extra+x+y*d3_l->max_x+z*d3_l->max_x*d3_l->max_y)+=1;
left-=1;
- total+=1;
}
}
}
}
+ free(area_h);
return 1;
}
return 1;
}
@@
-250,7
+248,7
@@
int main(int argc,char **argv)
char conc_txt[MAX_TXT];
char steps_txt[MAX_TXT];
char cc_txt[MAX_TXT];
char conc_txt[MAX_TXT];
char steps_txt[MAX_TXT];
char cc_txt[MAX_TXT];
- char *
*arg_v
;
+ char *
arg_v[MAX_ARGV]
;
d3_lattice d3_l;
max_x=X;
d3_lattice d3_l;
max_x=X;
@@
-270,6
+268,8
@@
int main(int argc,char **argv)
b_ap=B_AP;
cc=CC;
nowait=0;
b_ap=B_AP;
cc=CC;
nowait=0;
+ quit=0;
+ escape=0;
strcpy(s_file,"");
strcpy(l_file,"");
strcpy(r_file,"");
strcpy(s_file,"");
strcpy(l_file,"");
strcpy(r_file,"");
@@
-379,18
+379,19
@@
int main(int argc,char **argv)
if(!strcmp(l_file,""))
{
if(!strcmp(l_file,""))
{
+ i=0;
while((i<steps) && (quit==0) && (escape==0))
{
while((i<steps) && (quit==0) && (escape==0))
{
- x_c=
rand_get
(d3_l.max_x);
- y_c=
rand_get
(d3_l.max_y);
- z_c=
rand_get
_lgp(d3_l.max_z,a_el,b_el);
+ 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,a_el,b_el);
distrib_c(&d3_l,cc,a_cd,b_cd);
process_cell(&d3_l,x_c,y_c,z_c,range,a_ap,b_ap,&cc);
if(i%refresh==0)
{
distrib_c(&d3_l,cc,a_cd,b_cd);
process_cell(&d3_l,x_c,y_c,z_c,range,a_ap,b_ap,&cc);
if(i%refresh==0)
{
- sprintf(x_txt,"x: %d",x);
- sprintf(y_txt,"y: %d",y);
- sprintf(z_txt,"z: %d",z);
+ sprintf(x_txt,"x: %d",x
+1
);
+ sprintf(y_txt,"y: %d",y
+1
);
+ sprintf(z_txt,"z: %d",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",i);
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",i);
@@
-408,10
+409,12
@@
int main(int argc,char **argv)
d3_lattice_draw(&d3_l,x,y,z,10,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
d3_lattice_draw(&d3_l,x,y,z,10,arg_v);
scan_event(&d3_l,&x,&y,&z,&quit,&escape);
}
-
++i
;
+
i++
;
}
}
}
}
+ if(strcmp(s_file,"")) save_to_file(s_file,&d3_l);
+
while((quit==0) && (escape==0) && (nowait==0))
{
sprintf(x_txt,"x: %d",x);
while((quit==0) && (escape==0) && (nowait==0))
{
sprintf(x_txt,"x: %d",x);