← Back to index

Random Diffusion in 2D

Authors: Guoyuan Liu, Dou Du, Taylor Baird and Giovanni Pizzi

Original notebook: diffusion_2d.ipynb


Goals

Background Theory

More in the background theory

Tasks and exercises

  1. Using the default parameters, click the “Simulate” button. Then, play the simulation. Compare the global behavior and the path of an individual point, what do you observe? (The individual path of one of the particles can be displayed clicking on the “Show trajectory” check box on the bottom left.)

    Solution

    The individual path is completely random and running again the path is completely different at every execution. The global behavior, however, shows a uniform spherical pattern, with a diffusion radius rstdr_{std}.

  2. What statistical distribution should the diffusion pattern obey? See if the red analytical curve drawn in the top-right plot (projecting the motion in 1D, on the x axis) agrees with your expectations.

    Solution

    The macroscopic behaviour of a collection of particles moving according to a random walk will obey a normal distribution. Note that in the top-right plot, G(x)G(x) is shown, where G(x)G(x) is the normal probability density function and xx denotes the distance from the starting point in the x direction.

  3. How can the diffusion coefficient DD be obtained from the global (macroscopic) pattern observed?

    Solution

    Combining equation (1) and (5) from the theory section, we can see how the microscopic step size ll of the random walk is controlling the macroscopic diffusion radius rstdr_{std}, and that a proportionality coefficient (diffusion coefficient) DD exists between the time step and rstd2r_{std}^2 (apart from other constant factors). By performing some data analysis on the results of the simulation (i.e., calculating rstd2(t)r_{std}^2(t) from the coordinates of the particles of the ensemble as a function of time), we can obtain rstdr_{std} without the knowledge on the microscopic kinetics (i.e., the step size ll). Thus, by performing a linear fit of rstd2r_{std}^2 as a function of time, as shown in bottom-right plot, we can extract DD as:

    D=slope2nΔtD = \frac{\text{slope}}{2 n \Delta t}

    where Δt\Delta t is the time interval of one timestep.

Interactive visualization

Be patient, it might take a few seconds to load! Once loaded:

Random diffusion of an ensemble of particles in 2D

Legend

Interactive Figures

Controls

The panel in the lower left corner controls all 3 plots. The top three sliders set, respectively, the number of points, the step size and the total number of steps for the diffusion simulation. Choose the value as you wish and then click “Run” to run the simulation in the background. To visualize the results, use the play button next to it. Note that all 3 plots are synced with the time step.

The bottom three widgets control the visualization. The time step slider allows to quickly jump to a specific step of the simulation.