Vector Fields, Divergence and Curl, Seen with Particles

After reading this you will be able to read a vector field by eye, compute its divergence and curl at a point by hand, and predict from those two numbers whether tracer particles will spread, pile up, or spin.

What a vector field is

A vector field attaches an arrow to every point of the plane. Write it as a pair of functions, one for the horizontal component and one for the vertical component. Together they say: if a particle sits at the point (x, y), this is the velocity it feels.

\mathbf{F}(x, y) = \big(P(x, y),\ Q(x, y)\big)

Here P is the horizontal speed and Q is the vertical speed at the point (x, y). The classic example is the rotation field \mathbf{F} = (-y,\ x). At (1, 0) the velocity is (0, 1), straight up. At (0, 1) it is (-1, 0), straight left. Chain those arrows and a particle circles the origin counterclockwise forever.

The hook is that arrows alone hide the story. Draw a few hundred and your eye gets lost. Release a few thousand particles that ride the field and the character jumps out: they spiral, they stream outward, or they slide past one another. This visualizer draws both, so the arrows and the flow agree in front of you.

When this picture helps and when it misleads

Reach for a vector field whenever a rule assigns a direction and speed to every location: wind over a plane, water in a shallow tray, the gradient of a height map, the right-hand side of a two-variable differential equation. The tracer particles turn the abstract rule into motion you can watch.

Two limits are worth naming up front. First, these fields are steady, meaning they do not change with time. Real wind changes minute to minute; the toy field does not. Second, this is a two-dimensional slice. Real flows leak into a third dimension, and a slice can look like a source when fluid is actually just rising out of the plane.

A pretty spiral in the tracers does not prove the flow conserves anything. The rotation field spins and yet has zero divergence, so it neither creates nor destroys particles. A spiral sink spins and swallows. The eye cannot separate those two; only the numbers can.

The two numbers: divergence and curl

Every smooth field carries two local scalars. Divergence measures net outflow. Curl measures rotation. In two dimensions both are single numbers at each point.

\operatorname{div}\mathbf{F} = \frac{\partial P}{\partial x} + \frac{\partial Q}{\partial y}

Divergence adds how fast the horizontal speed grows as you move right to how fast the vertical speed grows as you move up. If both grow, arrows lengthen as they leave a point, so more flows out than in and divergence is positive. That is a source. Negative divergence is a sink. Zero means whatever flows in flows back out: incompressible.

\operatorname{curl}\mathbf{F} = \frac{\partial Q}{\partial x} - \frac{\partial P}{\partial y}

Curl compares how the vertical speed changes as you step right against how the horizontal speed changes as you step up. When the right side pushes up and the left side pushes down, a tiny paddle wheel dropped there spins. Counterclockwise spin is positive curl by convention.

These two quantities are independent. A field can have divergence without curl (a pure source), curl without divergence (pure rotation), both, or neither.

Worked example: the six default fields

Load the demo and you get the six classic fields at their defaults. Compute the divergence and curl of each at the center by hand. The partial derivatives are constant for these simple fields, so the value at the origin holds everywhere.

Differentiating each field by hand

  1. Source (x, y): \partial P/\partial x = 1, \partial Q/\partial y = 1, so divergence is 2. Cross terms are zero, so curl is 0.
  2. Sink (-x, -y): the same derivatives flip sign. Divergence is -2, curl is 0.
  3. Rotation (-y, x): \partial P/\partial x = 0 and \partial Q/\partial y = 0, so divergence is 0. For curl, \partial Q/\partial x = 1 and \partial P/\partial y = -1, giving 1 - (-1) = 2.
  4. Saddle (x, -y): divergence is 1 + (-1) = 0, curl is 0. Particles rush in along one axis and out along the other.
  5. Shear (y, 0): divergence is 0. Curl is 0 - 1 = -1. The flow slides layer past layer with no source, yet a paddle wheel still turns.
  6. Dipole: near the center the leading behavior is a source pushing against a sink, so the central divergence and curl both read near 0 while the far arrows loop from one pole to the other.

The shear field is the one that surprises people. Nothing spreads and nothing spins to the eye, but curl is -1 because the top moves right faster than the bottom. Drop a matchstick across the flow and it rotates clockwise.

Divergence and curl at the center for each default field
FieldFormulaDivergenceCurl
Source(x, y)20
Sink(-x, -y)-20
Rotation(-y, x)02
Saddle(x, -y)00
Shear(y, 0)0-1
Dipolenear center00

A general linear field is (a·x + b·y, c·x + d·y). Its divergence is a + d and its curl is c − b, both constant across the plane. Set a=1, d=1 for a source (div 2). Set b=−1, c=1 for rotation (curl 2). Set a=1, d=−1 for a saddle (div 0, curl 0).

Reading the tracer motion

Once you trust the two numbers, the particles confirm them. Positive divergence empties a region: particles thin out near the source and crowd nowhere. Negative divergence packs them toward the sink. Zero divergence keeps the local density steady, so a clump of tracers keeps its area even as it deforms.

Curl bends the paths. With positive curl the cloud rotates counterclockwise as it drifts. A field with curl 2 and divergence 0, the rotation field, spins the cloud without changing its area. A spiral sink shows curl and negative divergence together: the cloud rotates inward and shrinks.

A single particle starting at (1, 0) traces a circle of constant radius, because the rotation field has zero divergence: the radius never grows or shrinks.

To tell a rotation from a spiral, watch the radius of one particle, not the whole cloud. If its distance from the center holds steady, divergence is zero. If it creeps inward or outward, divergence is nonzero even when the spin looks the same.

Common mistakes

The first mistake is reading rotation as divergence. A swirling cloud looks like it is doing something dramatic, but the rotation field neither creates nor destroys particles. Check the central divergence readout: it is 0.

The second is expecting straight arrows to mean zero curl. The shear field (y, 0) has every arrow pointing horizontally, yet its curl is -1 because the speed changes across the flow. Shear rotates without turning.

The third is confusing crossing tracer paths with a bug. Field lines never cross, because the velocity at each point is a single vector. If two tracer trails appear to intersect on screen, they passed through that point at different times, or one is entering as the other leaves.

The fourth is trusting the center readout for the whole field. It is exact for linear fields, where the derivatives are constant, but for the dipole the divergence and curl vary from place to place. The value at the center is only one sample.

Related tools

If you liked watching particles ride a field, the Flow-Field Particles tool drives thousands of them with Perlin noise instead of a formula. To see a field of slopes rather than arrows and release solution curves, try the Slope Field Explorer. The Lorenz Attractor is a three-dimensional vector field whose flow never settles, and the Three-Body Choreographies show a field defined by gravity between moving stars.

For the linear-algebra side of what a 2 \times 2 matrix does to the plane, see the Linear Transformation Playground: the linear fields here are exactly those matrices read as velocities. To watch a field diffuse rather than flow, the Heat Equation Simulator spreads a hot spot the way divergence spreads density.

Frequently asked questions

Why does the rotation field have curl 2 and not 1?

Curl is \partial Q/\partial x - \partial P/\partial y. For (-y, x) that is 1 - (-1) = 2. The two terms add because both the change in vertical speed rightward and the change in horizontal speed upward push the same way around the loop. The paddle wheel turns at twice the angular speed of the flow itself.

Can a field have zero divergence and zero curl everywhere?

Yes. A constant field like (1, 0) has both zero: every particle drifts right at the same speed, nothing spreads, nothing spins. Such fields are both incompressible and irrotational, and they come from a harmonic potential.

What is the difference between the saddle and the shear?

The saddle (x, -y) has zero divergence and zero curl but stretches the cloud along one axis while squeezing it along the other. The shear (y, 0) also has zero divergence but curl -1, so it tilts the cloud into a parallelogram. Same area change (none), different rotation.

Do the particles ever stop?

Only at a fixed point, where the field is exactly (0, 0). For all six defaults that point is the origin. A particle placed precisely there never moves, but any tiny offset feels a nonzero velocity and drifts.

Why does the divergence readout sometimes wobble for the dipole?

The dipole is not linear, so its divergence and curl depend on position. Near the center the two poles nearly cancel and the value hovers near zero, but small changes in where the sample sits shift it. The linear fields give a rock-steady reading because their derivatives are constant.