Feynman
Jul1-04, 04:10 AM
Hi every body,
i've a simple question in the programation for a certain methode called Monte Carlo method for Smoluchowski equation:
i programe this method in maple but the problem is that the positions of particules z[l]is not changing ( it most be changed ): can any one tell me where is the problem?
this is the method:
//calculate natural random numbers
test:=proc(N)
local a,i,L;
L:=[];
a:=rand(1..N):
for i from 1 to N do L:=[op(L),a()] od;
L;
end:
\\z is the position of particules
z:=test(10);
pi:=test(10);
\\ calculate uniform random numbers U[0,1]
r:=stats[random, uniform](10):for i from 1 to 10
do
printf("r[%d]=%f\n",i,r[i]);
od;
\\ position of particules at time t+dt=t+1/20
for i from 1 to 10
do
if
r[i]>1/(20*z[i]) or r[i]=1/(20*z[i])
then
z(t+dt)[i]=z[i]:
end if;
if
r[i]<1/(20*z[i])
then
z(t+dt)[i]=z[i]+z[pi[i]]:
end if;
od:
thankx verry much
i've a simple question in the programation for a certain methode called Monte Carlo method for Smoluchowski equation:
i programe this method in maple but the problem is that the positions of particules z[l]is not changing ( it most be changed ): can any one tell me where is the problem?
this is the method:
//calculate natural random numbers
test:=proc(N)
local a,i,L;
L:=[];
a:=rand(1..N):
for i from 1 to N do L:=[op(L),a()] od;
L;
end:
\\z is the position of particules
z:=test(10);
pi:=test(10);
\\ calculate uniform random numbers U[0,1]
r:=stats[random, uniform](10):for i from 1 to 10
do
printf("r[%d]=%f\n",i,r[i]);
od;
\\ position of particules at time t+dt=t+1/20
for i from 1 to 10
do
if
r[i]>1/(20*z[i]) or r[i]=1/(20*z[i])
then
z(t+dt)[i]=z[i]:
end if;
if
r[i]<1/(20*z[i])
then
z(t+dt)[i]=z[i]+z[pi[i]]:
end if;
od:
thankx verry much