Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Practical #3:
1
4 Dt
P ( x,t ) =
e
4 Dt
Hence, at each time instant t , the distances of the particles from their starting
points should lie on a distribution like the one above. This function can be
identified with a Gaussian curve which, in its canonical form, is normally written
as
( )
f x =
( x )2
2 2
2
where, as usual, represents the mean and the standard deviation. Now,
suppose that you were given sets of distance data (that is, distances from the
origin) collected at different times, such that the data distribution at each time is
approximately Gaussian, with some standard deviation that in general depends
on t . From inspection of the two equations above, what relation between and
t would you expect to see if the process is diffusive?
Question 3.2.2
Use the function you have defined in the previous section to simulate the motion
of 20 particles over 1000 time steps, using a step size delta of your choosing.
Plot the motion of all particles on the same axes using pyplot. (That is, plot the
motion of all particles on the x-y plane, with no explicit time axis.) From what you
know about diffusion (that is, the expected relation between and t in the
equations above), does what you observe appear to suggest a diffusive process?
3.3 Part II: The biased random walk
In this exercise you will modify the program that you have written above to
introduce a bias in the particles motion. The function header should look like
def BiasRandomWalk2D(timesteps,particles,delta,leftangle,rightangle,bias):
...
Notice that three new inputs have been introduced: leftangle, rightangle
and bias. The first two of these inputs should be floating-point numbers
between 0.0 and 2, and the last should be a floating-point number greater than
0.0. The first two inputs, leftangle and rightangle, define an angular slice
around the position of your particle. The last of these, bias, represents the
relative preference of a particle to hop in a direction defined by that slice, as
opposed to any other direction. This arrangement is best illustrated in a picture,
as in the figure below.
steps will betray a substantial upward bias. If, on the other hand, bias is equal
to 0.01, then if leftangle and rightangle are consistent with the figure
above, the particle will have almost no chance of jumping into the red region, and
will spend almost all of its time jumping downwards, left, or right. Over many
time steps, the effect of the left and right jumps are likely to cancel out (since the
geometry of the above figure suggests that the particle will be jumping left and
right about equally often), so the general motion of the particle will be directed
roughly downwards.
Question 3.3.1
Modify your RandomWalk2D script to take into account directional bias in the
manner described above. Your function header should be changed to
def BiasRandomWalk2D(timesteps,particles,delta,leftangle,rightangle,bias):
...
At each time step, your particles should move in a manner consistent with the
input bias selected by the user.
Question 3.3.2
Test out your BiasRandomWalk2D script with 20 particles over 1000 time steps,
with a delta of your choosing and one or two different angular slices with three
or four different choices of bias for each. Plot the results in each case. How do
these results differ from those you obtained in the unbiased case? Are these
differences roughly what you expect based on the inputs?