LABORATORY 2: RANDOM WALKS AND MONTE-CARLO SIMULATIONS
Mathematics:
A molecule moves as a result of collisions
with other molecules. Suppose an average time between two collisions equals tot = 1. Also suppose that a single collision displaces a
molecule by x = s in the direction of the x-axis 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 one-dimensional 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 xk(n)
denote a displacement of the k-th molecule after n
collisions. The diffusion (spread) of molecules can be characterized by two
mathematical quantities:
·
mean (average
displacement): = xk(n)
·
variance (average squared displacement):2 = ( xk(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 variance2 as functions of n for an
ensemble of N molecules and find the coefficient of diffusion D
·
plot
the mean and the variance2 as functions of N for the same number of n collisions and
compare with the theoretical values for and2
·
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 variance2 grows linearly in time. Evolution of the
mean and the variance2 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
Monte-Carlo simulations. A typical pattern for evolution of the mean and the variance2 is shown here for ten ensembles with
different values of N.
|
|
We
can compute the coefficient of diffusion D (the slope of the line2 versus time) and plot it as functions of
number of molecules N. The theory predicts that the Monte-Carlo
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: