LABORATORY 2: RANDOM WALKS AND MONTECARLO SIMULATIONS
Mathematics:
A molecule moves as a result of collisions
with other molecules. Suppose an average time between two collisions equals to_{}t = 1. Also suppose that a single collision displaces a
molecule by _{}x = s in the direction of the xaxis or
in the opposite direction. If collisions are equally likely in both directions,
the probabilities of the molecule's shift to the right and to the left after an
individual collision are the same: p = q = ½. This is the
simplest model for a onedimensional random walk of molecules called the Brownian
motion. If x is a position of a molecule, then all possible
moves (trajectories) of x as a result of n
collisions with other molecules are shown on the picture called a binary
tree (shown for n = 6):
Consider
an ensemble of N molecules thrown in a single point, say x = 0. As
a result of molecular collisions, they start to spread or to diffuse. Let x_{k}^{(n)}
denote a displacement of the kth molecule after n
collisions. The diffusion (spread) of molecules can be characterized by two
mathematical quantities:
^{· }mean (average displacement): _{} = _{}_{}x_{k}^{(n)}^{}
^{ }
^{· }variance (average squared displacement):_{}^{2 }= _{}_{}( x_{k}^{(n) }  _{} )^{2}
^{ }
The
theory of diffusion works for large N and predicts that _{} = 0 and _{}^{2} = D n, where D is the
coefficient of diffusion.
Objectives:
·
visualize
individual trajectories of molecules in the ensemble of N molecules
·
plot
the mean_{} and the variance_{}^{2} as functions of n for an
ensemble of N molecules and find the coefficient of diffusion D
·
plot
the mean_{} and the variance_{}^{2} as functions of N for the same number of n collisions and
compare with the theoretical values for_{} and_{}^{2}
·
understand
limits of applicability of the theory of diffusion
A
typical pattern of N = 15 molecules for n = 200 collisions
is shown here:
Exploiting
the MATLAB script:
The
diffusion theory predicts that the mean _{} stays at zero
in time (with larger number of collisions n), while the variance_{}^{2} grows linearly in time. Evolution of the
mean_{} and the variance_{}^{2} in time depends on the number of
molecules N in a statistical ensemble, as well as on each
particular random data realization. Such numerical computations are called the
MonteCarlo simulations. A typical pattern for evolution of the mean_{} and the variance_{}^{2} is shown here for ten ensembles with
different values of N.


We
can compute the coefficient of diffusion D (the slope of the line_{}^{2} versus time) and plot it as functions of
number of molecules N. The theory predicts that the MonteCarlo
approximation of D should approach to the theoretical value of D with large N.

Steps in writing the MATLAB script:

Exploiting
the MATLAB script:
The
theory predicts that the standard deviation of an average molecule grows as a
parabola with respect to time: _{} = _{} Due to the symmetry,
molecules spread to the left and to the right equally likely. We can combine
the parabolic walk of an average molecule in time with individual random
trajectories of molecules in a given ensemble. A typical pattern for N =
20 and n = 1000 is shown here:
1.
Compute
the random matrix of total displacement similar to the first script
2.
Compute
the mean, variance, and the coefficient of diffusion similar to the second script.
3.
Plot
each row of the matrix of total displacements at the same graph by blue color.
4.
Compute
two vectors for positive and negative trajectories of an average molecule.
5.
Plot
the two vectors at the same graph by red color.
Exploiting
the MATLAB script: