# Simulating diffusion for particles undergoing Brownian motion

I am trying to do a computer simulation as part of a research project of the diffusion of a few particles undergoing brownian motion along a two-dimensional canvas. I am having some holes in my understanding of diffusion dynamics, which makes me blocked on this task.

I understand that there exists the relationship $$\tau = \frac{L^2}{4D},$$ where $$D$$ is a diffusion coefficient, $$\tau$$ is a time change and $$L$$ is the distance traveled.

Then I suppose that in two-dimensions this scales like $$L_r = \sqrt{L_x^2 + L_y^2}$$, where $$(L_x, L_y) = (2\sqrt{\tau D}, 2\sqrt{\tau D}) \implies L_r = \sqrt{8 \tau D}$$

I am able at each step to generate a random walk of the particles by sampling discretely from $$-1$$ to $$1$$ using a normal distribution, append this value over the $$x$$ coordinate of a particle and repeat the sampling for the $$y$$ coordinate, but how and where does diffusion come to play into this? More specifically, what is the role of the diffusion coefficient and how can I implement it in my particle diffusion simulation?

• So to be clear, you're modeling diffusion not by solving a diffusion PDE (e.g., $\partial_tu=\partial_x(D\partial_xu)$), but by simulating individual particle walks? Commented Sep 24, 2022 at 3:16
• Do you sample discretely from $\{-1,1\}$ from a (symmetric) Binomial distribution ? Or from $(-\infty,+\infty)$ from a normal distribution ? In any case let's call this sample $\varepsilon$. It has mean zero and variance one. You should do that, both, in $x$-direction and in $y$-direction: $\varepsilon_x,\varepsilon_y$. To bring in your physical parameters increment every direction by $\sqrt{2\tau D}L$ times the respective $\varepsilon$. That's it. Commented Sep 24, 2022 at 6:12
• @KurtG. Awesome, thanks, I did not think of just multiplying by the $\sqrt{2 \tau D} L$, but can you elaborate on what is $L$ in this scenario? So for instance, given a particle's position $(x_i, y_i)$ at $i^{\text{th}}$ iteration, would $L$ be the distance between $x_i$ and $x_{i-1}$, and same for $y_i, y_{i-1}$ respectively? Commented Sep 24, 2022 at 19:27
• @KyleKanos Yes that is correct, simulate diffusion (Brownian motion) for a few particles, given a diffusion coefficient $D$. Commented Sep 24, 2022 at 19:56