Random Diffusion in 2D
Authors: Guoyuan Liu, Dou Du, Taylor Baird and Giovanni Pizzi
Original notebook: diffusion_2d.ipynb
Goals
- Understand the random diffusion process, inspecting it in two dimensions
- Understand the connection between microscopic kinetics and macroscopic observables
- Learn how to extract diffusion coefficients from the simulation of an ensemble of particles
Background Theory
Tasks and exercises
-
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 .
-
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, is shown, where is the normal probability density function and denotes the distance from the starting point in the x direction.
-
How can the diffusion coefficient 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 of the random walk is controlling the macroscopic diffusion radius , and that a proportionality coefficient (diffusion coefficient) exists between the time step and (apart from other constant factors). By performing some data analysis on the results of the simulation (i.e., calculating from the coordinates of the particles of the ensemble as a function of time), we can obtain without the knowledge on the microscopic kinetics (i.e., the step size ). Thus, by performing a linear fit of as a function of time, as shown in bottom-right plot, we can extract as:
where is the time interval of one timestep.
Interactive visualization
Be patient, it might take a few seconds to load! Once loaded:
- select the simulation parameters
- press the “Simulate” button
- then use the play/pause/stop/loop buttons to visualize the simulation results
Legend
Interactive Figures
- The top-left plot is the main plot showing directly the Brownian diffusion of free particles in 2D.
- The green circle has radius related to the standard deviation of the distance of all particles from the starting point at : the value at time is given by , where is the number of particles and is the vector of the position of the th particle at time .
- The red circle has radius given by , where is the current step number (i.e., the time from the start of the simulation) and is the step size.
- Optionally, using the tick boxes below the plots, one can also show:
- the trajectory of one of the particles, displaying the position every 100 simulation steps
- a 2D density map of the expected probability distribution of finding particles in a given region in space
- The top-right plot shows the 1D histogram of the position particles along the x direction, integrating all particles along the y direction. The expected analytical Gaussian distribution is also displayed, where its standard deviation is obtained from its expected value (dependent on the step size and the current step index, like ).
- The bottom-right plot shows the dependency of as a function of the time step number . The data points are shown every 500 steps, with the current step displayed in green. The red dashed line is the result of linear regression on the data (“fit”).
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.