1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem :surprise:

  1. Jul 1, 2004 #1
    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);
    od;

    \\ position of particules at time t+dt=t+1/20

    for i from 1 to 10
    do
    if
    r>1/(20*z) or r=1/(20*z)
    then
    z(t+dt)=z:
    end if;
    if
    r<1/(20*z)
    then
    z(t+dt)=z+z[pi]:
    end if;
    od:
    thankx verry much
     
  2. jcsd
  3. Jul 1, 2004 #2

    Gokul43201

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    I couldn't help myself...

    LUIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIII
    Inta SCOTEEEEEEEEEEEEEEEEEEEEEEEEEEEE
     
  4. Jul 1, 2004 #3

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Code (Text):

    \\ 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:
     
    These lines look strange to me:
    z(t+dt)=z:
    z(t+dt)=z+z[pi]:

    First, the := means assignment.
    So, you might have meant:
    z(t+dt) := z+z[pi]:

    Second, what kind of maple object is z(t+dt)?
    Do you mean to "update" the z[] array, e.g.
    z := z+z[pi]:
    ?
     
  5. Jul 7, 2004 #4
    so please correct me this program please
    Thanks
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Problem :surprise:
  1. A problem (Replies: 2)

  2. A problem (Replies: 1)

  3. A problem (Replies: 24)

  4. A problem (Replies: 15)

Loading...