💧 Fick's Laws of Diffusion — Concentration Gradients & Flux
Watch a concentration gradient flatten in real time as particles random-walk across a diffusion tube. Adjust the diffusion coefficient for gases, liquids, gels and solids, toggle flux-vector arrows, and see Fick's First and Second Laws predict exactly how a substance spreads.
How it Works
The top panel is a diffusion tube: hundreds of particles start crowded into a narrow band on the left and then perform an independent random walk, one small random jump per frame, bouncing elastically off the tube walls. No particle "knows" about the concentration gradient — each one just jitters randomly — yet collectively their positions trace out exactly the smooth, spreading concentration profile predicted by Fick's laws.
The bottom panel turns those particle positions into a concentration profile C(x) by counting how many particles fall into each narrow bin along the tube. The amber curve is the profile right now; the fainter blue curves are snapshots taken a few seconds earlier, so you can watch the initial step directly flatten and spread with time. Switching on flux arrows draws Fick's First Law, J = −D·dC/dx, directly on the graph: each arrow points from high to low concentration, with a length proportional to how steep the local gradient is.
Fick's Second Law: ∂C/∂t = D · (∂²C/∂x²)
Random-walk relation (1D): ⟨x²⟩ = 2Dt
Diffusion length: L ≈ √(D·t)
Frequently Asked Questions
What does Fick's First Law say?
Fick's First Law states that the diffusive flux J is proportional to the negative of the local concentration gradient: J = -D·(dC/dx). Particles move, on average, from regions of high concentration toward regions of low concentration, and the steeper the gradient, the larger the flux.
What does Fick's Second Law describe, and how does it follow from the first?
Fick's Second Law, ∂C/∂t = D·∂²C/∂x², describes how a concentration profile evolves over time. It follows from combining Fick's First Law with conservation of mass (a continuity equation): the local rate of concentration change equals minus the divergence of the flux, and substituting J = -D·dC/dx gives the diffusion equation.
What is the diffusion coefficient D, and what determines its value?
D is a proportionality constant with units of length² / time that measures how quickly a species spreads through a medium. It depends on the diffusing particle's size, the temperature, and the viscosity or structure of the surrounding medium — gases have the largest D, liquids much smaller, and solids smaller still.
Why does the diffusion length grow as the square root of time instead of linearly?
Diffusion is a random walk: each step is uncorrelated with the last, so displacements partially cancel out. The mean squared displacement grows linearly with time (⟨x²⟩ = 2Dt), and taking the square root to get a typical distance gives L ≈ √(Dt) — a hallmark signature that distinguishes diffusion from directed motion, which grows linearly with time.
What is a concentration gradient, and why does it drive diffusion?
A concentration gradient is the rate of change of concentration with position, dC/dx. It is not a physical force; instead, diffusion arises because random thermal motion is more likely to carry particles from a crowded region into a less crowded one than vice versa, simply because there are more particles available to leave the crowded side.
Why do particles keep moving randomly even after the concentration becomes uniform?
Diffusion is driven by thermal motion, which never stops as long as temperature is above absolute zero. Once the concentration is uniform, particles still jitter around randomly, but because there is no net gradient left, the number moving in each direction balances out and the net flux drops to zero — this is dynamic, not static, equilibrium.
How is Fick's Second Law derived from Fick's First Law?
Start with conservation of mass for a thin slice of the medium: the concentration inside the slice changes only because flux enters one face and leaves the other, so ∂C/∂t = -∂J/∂x. Substituting Fick's First Law, J = -D·∂C/∂x, gives ∂C/∂t = D·∂²C/∂x² — the diffusion equation, valid whenever D is constant in space.
What do the flux arrows in the simulation represent?
Each arrow shows the local diffusive flux at that point along the concentration profile: its direction points from higher to lower concentration (down the gradient), and its length is proportional to how steep the local gradient is, exactly as required by J = -D·dC/dx.
Why does the concentration profile flatten instead of moving sideways like a wave?
Diffusion has no built-in direction of travel — every particle moves independently and randomly. What look like a spreading and flattening curve is simply the accumulated statistics of many random walks: material moves down whatever local gradient exists, so peaks erode and valleys fill in until the profile is uniform, rather than the whole curve translating.
What real-world processes are governed by Fick's laws?
Fick's laws describe oxygen and carbon dioxide exchange in the lungs and across cell membranes, the spread of a perfume or gas leak through still air, drug release from a transdermal patch or tablet coating, dopant diffusion during semiconductor chip manufacturing, and salt or heat spreading through soil, water, or metal.
About this simulation
This simulator pairs a diffusion tube, where particles genuinely random-walk from a crowded starting band toward empty space, with a live concentration profile that turns those particle positions into the smooth curve Fick's laws predict. Faded snapshots let you watch a sharp step spread and flatten over time, and optional flux arrows draw J = −D·dC/dx directly on the graph so the abstract equation becomes something you can literally see happening.
🔬 What it shows
Two synchronized views of the same process: a diffusion tube where particles genuinely random-walk from a concentrated band toward empty space, and a concentration profile C(x) below it that traces out, bin by bin, exactly what those particles are doing — including faded snapshots of earlier profiles so you can watch the curve spread and flatten over time.
🎮 How to use
Pick a medium preset or drag the D slider to change how fast particles hop, use Reset for a clean step-profile start or Pulse source to inject a point source at the centre, switch on flux arrows to see J = −D·dC/dx drawn directly on the graph, and drag the probe slider to read the local flux anywhere along the tube.
💡 Did you know?
A photon takes only about 8 minutes to travel from the Sun's core to its surface in a straight line — but because it's endlessly absorbed and re-emitted in random directions along the way, the actual random-walk journey through the dense plasma takes tens of thousands of years, a dramatic real-world example of how slow diffusion can be compared to direct travel.
Frequently asked questions
Why do gases diffuse orders of magnitude faster than liquids or solids?
In a gas, molecules travel long distances between collisions because neighbors are far apart, so a random walk step is large and D is high. In a liquid, molecules are packed close together and constantly jostled by neighbors, shortening each step; in a crystalline solid, atoms are mostly locked in a lattice and can only hop rarely into vacancies, making D many orders of magnitude smaller still.
What happens when I click "Pulse source"?
A tight cluster of new particles is injected at the centre of the tube, on top of whatever is already there. Watching just that cluster spread into a widening, flattening bump over time is the classic experimental signature of a point-source diffusion — mathematically, its profile approaches a Gaussian curve that widens as √t.
How is the concentration profile actually computed in this simulation?
The tube is divided into narrow bins along its length, and every animation frame the simulator counts how many particles currently fall inside each bin. That count, lightly smoothed to reduce sampling noise, is the concentration C(x) plotted in the graph below the tube — a direct, particle-based (Monte Carlo) solution of the diffusion equation rather than an idealized formula.
What does the probe point measure, and can I move it?
The probe is the dashed vertical line and blue dot on the profile graph. It reports the local diffusive flux J at that exact position, computed from the concentration gradient immediately around it. Drag the probe-position slider to move it anywhere along the tube and watch the flux reading update live.
Why does diffusion slow down as the concentration becomes more uniform?
The flux is proportional to the gradient, not to the concentration itself. Early on, the gradient at the interface is steep and flux is large; as material spreads out, the gradient everywhere becomes shallower, so the flux — and the rate of further flattening — steadily decreases even though the diffusion coefficient D never changes.
How does temperature affect the diffusion coefficient in reality?
Higher temperature gives particles more kinetic energy, so they move faster between (or despite) collisions, which increases D. The relationship is often described by an Arrhenius-like expression, D = D₀·exp(−Ea/RT), meaning diffusion — like many rate processes — speeds up sharply as temperature rises, which is why solid-state diffusion becomes practical only at high temperatures.
Watch particles undergo a real random walk and spread from a concentrated band into a flattening concentration profile, with live flux arrows showing Fick's First Law in action across gas, liquid, gel and solid media.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install