Assignment 1  

 

Using the computer language of your choice, write a simulation of random walks in one dimension, on a lattice of spacing delta x=1 and with discrete time steps, delta t=1. Each walker begins at the origin and at each time step it takes a step to the right or left with equal probability, so that  p_right=0.5, p_left=0.5.

 

Number of steps in each walk: 20

Number of walks: 10,000

 

You may structure your code as discussed in class, or come up with your own algorithm. Note, you will need a random number generator.

 

Make the following graphs using your simulation data:

 

A.  Mean square displacement vs. time, for time from t=0,1,2,3...20.  Fit a straight line to the curve (by eye is okay) and find the diffusion coefficient. Is it the same as predicted by theory?

 

B.  Spatial distribution of walks at time = 20, normalized so the area under the curve is 1. [Note: after an even number of steps, all walks end on even-numbered sites.]

 

C. For comparison, calculate the expected average spatial distribution at time T=20 and plot together with your simulation data.

You have two choices for how to calculate the spatial distribution....

     1. Write a program that calculates the distribution by evaluating eqn 9 from Ref 2 (above)

                         P_N(d)==1/(2^N)(N; (d+N)/2)

      or, 2. Write a program that calculates the distribution using the method shown below, which we will discuss in class (figure from Ref 2)

 

 

steps -5 -4 -3 -2 -1 0 1 2 3 4 5
0           1          
1         1/2 0 1/2        
2       1/4 0 2/4 0 1/4      
3     1/8 0 3/8 0 3/8 0 1/8    
4   1/(16) 0 4/(16) 0 6/(16) 0 4/(16) 0 1/(16)  
5 1/(32) 0 5/(32) 0 (10)/(32) 0 (10)/(32) 0 5/(32) 0 1/(32)

 

Please turn in your random walk simulation code, your code that calculates the expected distribution, and the graphs of your data.