# Brownian Motion & Diffusion Simulator - Random Walk, MSD, Stokes–Einstein, Fick

> Simulate Brownian motion: thousands of random walkers, Langevin dynamics, MSD slope fits, Lévy flights and subdiffusion, Stokes–Einstein D and Fick's law.

- URL: https://qilingtools.com/en/physics/random-walk
- Category: Physics Tools (https://qilingtools.com/en/physics)
- Tags: [Physics](https://qilingtools.com/en/tags/physics)
- Last updated: 2026-10-29
- Price: Free, no sign-up
- Privacy: Runs locally in the browser; files are never uploaded

Simulate up to thousands of walkers starting at the origin: a lattice random walk, Langevin Brownian motion with drag and thermal kicks, Lévy flights and a continuous-time random walk. You see their trails, a log–log mean squared displacement plot with a slope fit and the theory curve, and a histogram of displacements. A Stokes–Einstein calculator turns particle radius, viscosity and temperature into a diffusion coefficient and typical displacements, for pollen, bacteria, proteins, sugar and even gas molecules. A 1D diffusion-equation tab puts the numerical solution, a walker histogram and Fick's flux side by side.

## How to use

1. On the Walkers & MSD tab pick a motion model, set the damping γ, temperature k_BT or tail exponent α, and press Run
2. Read the log–log MSD: normal diffusion has slope 1, Langevin starts with slope 2, Lévy flights exceed 1 and subdiffusion stays below 1
3. On the Stokes–Einstein tab choose a particle and medium, set the temperature and read D, the displacement after 1 s or 1 h and the time to cross 1 mm
4. On the Diffusion equation tab choose an initial profile and boundaries, then drag the probe line x₀ to read the flux J and the net amount crossed

## Features

- Four models: lattice walk, Langevin Brownian motion, Lévy flight and CTRW, with up to 5000 walkers
- Log–log MSD with a fit over the last decade of time and the exact ballistic-to-diffusive curve
- Displacement histogram against a Gaussian of the same variance, with excess kurtosis
- Stokes–Einstein in water, glycerol or air (with Cunningham correction) plus kinetic-theory D for gases
- 1D diffusion equation, walker histogram and point-source solution on one chart, with reflecting or absorbing walls
- Fick's first-law flux curve and the net amount crossing a draggable probe point

## FAQ

### Why does the mean squared displacement grow linearly with time?

Successive steps are independent with zero mean, so the variance of the total displacement is the sum of the step variances and grows in proportion to the number of steps: ⟨r²⟩ = 2dDt in d dimensions. That is Einstein's 1905 explanation of Brownian motion and the signature of diffusion: distance grows only as √t, so going 10 times farther takes 100 times longer. On a log–log plot normal diffusion is a straight line of slope 1.

### Why is the Langevin slope 2 at short times?

A real particle has mass and velocity, and collisions only randomise the velocity after the momentum relaxation time τ = m/γ. For t ≪ τ the particle moves almost in a straight line, ⟨r²⟩ ≈ (k_BT/m)·d·t², slope 2 (ballistic). For t ≫ τ it becomes diffusive, ⟨r²⟩ = 2dDt. The full result is ⟨r²⟩ = 2dD[t − τ(1 − e^{−t/τ})], drawn as the dashed theory curve. For a particle of 1 µm radius in water τ is only about 0.2 µs, so under a microscope you only ever see the diffusive regime.

### When does the Stokes–Einstein equation apply?

D = k_BT/(6πηr) treats the particle as a rigid sphere moving slowly through a continuous viscous fluid. It works well for colloids, cells, viruses and proteins and roughly for small molecules like sucrose, but it underestimates D when the particle is about the size of the solvent molecules, such as water self-diffusion. Sub-micron particles in air need the Cunningham slip correction because their size approaches the mean free path of air (about 65 nm). Gas molecules diffusing among each other do not follow Stokes' law at all, so the tool uses kinetic theory, D = 3/(8nd²)·√(k_BT/πm).

### What is anomalous diffusion?

Diffusion is anomalous when ⟨r²⟩ ∝ t^β with β ≠ 1. In a Lévy flight step lengths follow a heavy tail P(ℓ) ∝ ℓ^{−1−α} with α < 2, so occasional huge jumps make the typical displacement grow as t^{1/α}: superdiffusion, used for animal foraging and turbulent transport. In a continuous-time random walk each jump waits a heavy-tailed time (α < 1), so particles get trapped for longer and longer and ⟨r²⟩ ∝ t^α: subdiffusion, seen for macromolecules in cytoplasm and in porous media.

### How is Fick's law related to random walks?

The density c(x, t) of many independent walkers obeys the diffusion equation ∂c/∂t = D ∂²c/∂x², which is Fick's second law. The particle current J = −D ∂c/∂x is Fick's first law: material flows from high to low concentration at a rate proportional to the gradient. The tool solves the equation with finite differences and moves tens of thousands of walkers with Gaussian steps; their histogram should match, and for a point source both agree with c = M/√(4πDt)·e^{−x²/4Dt}. For the probability side of random processes, see the Markov chain tool.

## Related tools

- [Unit Converter](https://qilingtools.com/en/math/unit): Free online unit converter: length, area, volume, weight, temperature, time, speed, data, pressure, energy and angle — one value converts every unit at once.
- [Vector Calculator](https://qilingtools.com/en/math/vector): Free online vector calculator for 2D and 3D: addition, scalar multiples, dot and cross products, magnitude, angle, unit vector and projections, with checks.
- [Significant Figures Calculator](https://qilingtools.com/en/math/significant-figures): Free online sig fig calculator: count significant figures digit by digit, round to N sig figs or decimals with six rounding modes, and compute by sig fig rules.
- [Tone Generator](https://qilingtools.com/en/audio/tone-generator): Free online tone generator: sine, square, sawtooth and triangle waves from 1 to 20,000 Hz, a note picker, sweeps, white/pink/brown noise and a WAV download.
- [Audio Spectrogram](https://qilingtools.com/en/audio/spectrogram): Free online spectrogram generator: see time, frequency and level from a Hann-windowed STFT, with FFT size, log axis, dB range and colour maps. Exports PNG.
- [Decibel Meter](https://qilingtools.com/en/audio/decibel): Free online decibel meter: measure noise with your mic in real time, A/C/Z weighting, fast/slow response, min/max/average/Leq, 60-second graph and calibration.
- [Physics Formula Calculator](https://qilingtools.com/en/physics/physics): Physics formulas solved with steps: SUVAT, projectiles, Newton’s laws, inclines, energy, Ohm’s law, resistors, RC, buoyancy, waves, lenses, gravity.
- [Fourier Series & FFT Visualizer](https://qilingtools.com/en/math/fourier): Fourier series coefficients and animated partial sums for square, sawtooth, triangle or any function (Gibbs), draw-your-own epicycles and FFT spectra.
