Open any fluid simulator and the most important array in it is the velocity field: one arrow per grid cell, saying which way the fluid moves there and how fast. In 1.1 Vectors, Linear Combinations & Span we met that array as “a big vector”, and in 1.8 The Matrix Exponential: From Hops to Flows we followed particles through the special case of a linear field . This lesson treats general vector fields as geometric objects. The punchline will feel familiar. To draw the smoke streaming around a wing, you drop particles into the field and integrate with the same Euler and RK4 steppers you wrote in your Simulations course. Visualizing a flow is solving an ODE system, thousands of times over.
Transcript
- Release a thread of smoke in a wind tunnel and it bends around the model, tracing out invisible curves. Those curves are what this lesson is about.
- A vector field attaches an arrow to every point of space. In two dimensions, F of x y has two components, P and Q, one for each direction.
- Take the field minus y, x. At the point one, zero, the arrow is zero, one: straight up. At zero, one, it is minus one, zero: pointing left.
- Do that everywhere and you get a picture of the whole field. We shrink the arrows so they don't collide, and color them by speed. This one swirls counterclockwise.
- Now drop a particle into the field and let it go wherever the arrow under it points. Its velocity is always the field at its current position.
- Written as an equation, that sentence is a system of ordinary differential equations: d x d t equals P, and d y d t equals Q. The curve the particle traces is a solution. We call it an integral curve, or a flow line.
- For this field we can solve it by hand. x prime is minus y and y prime is x, so x equals r cosine t and y equals r sine t. Every flow line is a circle.
- Fill the field with particles and the flow comes alive. Every particle follows its own flow line, and flow lines never cross, because at each point there is only one arrow to follow.
- Most fields cannot be solved by hand, so a computer takes steps. Forward Euler moves along the arrow for a time h. But on a circle, the arrow is tangent, so every step lands slightly outside.
- Pythagoras gives the damage exactly. The new radius is the old radius times the square root of one plus h squared. It is always bigger than one, so the error compounds every step.
- Run Euler for a while and the particle spirals outward, like a leak in the numerics. Fourth order Runge Kutta, with the same step size, stays glued to the circle.
- This is exactly the integrator you wrote in your simulations course. Drawing flow lines, moving smoke, and advecting a fluid are all the same job: solving x prime equals F of x for many particles at once.
- Fluid dynamicists build complicated flows from a handful of elementary ones. First, the uniform stream: the same arrow everywhere, like the free stream in a wind tunnel.
- A source pumps fluid out of a point. The speed falls off like one over r, so that the same amount of fluid crosses every circle around it.
- Flip the sign and you get a sink, a drain that swallows fluid.
- A point vortex swirls around a center, again with speed one over r. Its flow lines are circles.
- And the saddle, or stagnation point flow: fluid arrives along one axis and leaves along the other, the way air splits in front of a car.
- Because adding fields is linear, we can superpose them. A uniform stream plus a source gives the Rankine half-body: the source fluid is pushed downstream, carving out the shape of a blunt nose.
- Right in front of the nose the stream and the source cancel exactly. That point, where the velocity is zero, is a stagnation point.
- One family of fields deserves a name. If F is the gradient of a scalar function phi, it is called a gradient, or conservative, field, and phi is its potential.
- Here phi is the potential of a source, and its level curves are circles. The gradient arrows cross every level curve at a right angle, just as you saw in the gradient lesson.
- Now compare the vortex of minus y, x. Its arrows run along the circles instead of across them. Follow one around a loop and you would climb forever. No potential can do that, so rotation is not a gradient field.
- So: a vector field is an arrow at every point, and its flow lines are solutions of an ODE system that you can trace with RK4.
- But what happens when the field itself changes in time? Then smoke, particles and snapshots start telling three different stories. That's the next video.
A vector at every point
A vector field on a region of the plane is a function that assigns a vector to each point:
The two component functions and are ordinary scalar fields of the kind you met in 2.1 Functions of Several Variables & Partial Derivatives. In space, a field has three components, . Compare this with a scalar field like temperature , which puts a single number at each point. A vector field puts an arrow there.
The field you will meet most often in this course is a fluid’s velocity . In a steady flow it depends only on position, . In an unsteady flow it also changes in time, . Some other examples:
- Rotation : at the arrow is , at it is . Everything swirls counterclockwise, and the speed grows linearly with distance from the center. A spinning turntable has this velocity field, and so does the core of a tornado.
- Gravity of a mass at the origin: , a 3D field pointing inward with strength falling off like .
- The gradient of a scalar function, , from 2.3 Gradient & Directional Derivatives. Every scalar field hands you a vector field for free.
- Pressure force per unit volume, , which pushes fluid from high to low pressure.
Plotting vector fields
You can’t draw an arrow at every point, so a quiver plot samples the field on a grid and draws a scaled arrow at each sample. Three conventions make these plots readable:
- Scale the arrows down. True lengths would overlap, so plotters multiply every arrow by a common factor. Only relative length is meaningful.
- Or normalize and color. When speeds vary wildly (near a source the speed blows up), draw unit-length arrows and encode the speed as color. The sims in this lesson do this.
- Use streamlines for the big picture. Curves that follow the arrows (next section) show the structure of a flow far better than a forest of arrows. Matplotlib’s
streamplotdraws them.
Worked example: sketching a field by hand
Sketch .
Evaluate at a few points, starting with the axes:
| point | ||||||
|---|---|---|---|---|---|---|
Two observations organize the sketch. On the line , the arrow is , pointing straight away from the origin along that line. On , the arrow is , pointing straight toward the origin. Fluid arrives along one diagonal and leaves along the other. This is a saddle, and you saw its linear-algebra twin in 1.5 Eigenvectors & Eigenvalues: the field is with , whose eigenvectors and have eigenvalues and .
A useful trick when sketching: find the curves where (arrows vertical) and where (arrows horizontal). Here vanishes on the -axis, so the arrows there are vertical, and vanishes on the -axis, so the arrows there are horizontal. Watch out for the swap: the -axis carries the vertical arrows. Points where both vanish are stagnation points, where the flow stands still. This field has exactly one, the origin.
Flow lines are solutions of ODEs
Drop a massless particle into the field and let it go wherever the arrow beneath it points. If is its position, the rule “velocity equals the field here” reads
A curve satisfying this is called an integral curve or flow line of . At each of its points, the curve is tangent to the field, and its speed equals the length of the arrow. So every autonomous ODE system is a vector field, and every vector field is an autonomous ODE system. The phase portraits you will draw in 7.3 Phase Portraits & the Trace–Determinant Plane are exactly pictures of flow lines.
Flow lines don’t cross. If has continuous partial derivatives, the existence and uniqueness theorem (3.7 Existence & Uniqueness) guarantees exactly one solution through each point. Two flow lines through the same point would be two solutions with the same initial condition. The only places where flow lines can seem to meet are stagnation points, where and the “flow line” is just a particle sitting still forever; nearby curves can approach them as but never reach them in finite time.
Finding flow lines by hand
When we only care about the shape of the curve, not the timing, divide the two equations to eliminate :
This is a single first-order ODE, often separable (3.3 Separable Equations).
Worked example: the rotation field
Find the flow lines of .
The shape equation is , i.e. . Integrating, , so
The flow lines are circles about the origin. For the timing, check that , works: and . ✓ Every particle goes once around its circle in time , regardless of radius. That is solid-body rotation: the whole plane turns like a rigid disk.
Worked example: the stagnation-point flow
Find the flow lines of .
Here the system decouples: and give , . Multiplying, is constant. The flow lines are the hyperbolas , together with the four half-axes (). Fluid comes in along the -axis and leaves along the -axis. Flip the picture so the -axis is a wall and you have the flow toward the front of a car or a wing’s leading edge, which is why it’s called stagnation-point flow.
Fields in 3D
Nothing changes in three dimensions except the number of equations. For , the first two components rotate exactly as before while climbs steadily. The flow lines are helices , the shape of a tornado’s or a wingtip vortex’s swirling inflow. In 3D, flow lines can also wind around without repeating; the steady “ABC flow” has chaotic flow lines, a first hint of 7.10 Chaos & the Lorenz System.
Find the flow lines of each field. Sketch a few and mark the direction of motion.
- through the point , as a parametrized curve.
Show worked solution
- , so and , giving : a family of parabolas through the origin (plus the -axis, which corresponds to ). In time, and , so every particle moves away from the origin, which is an unstable node. The -component grows faster, so curves bend toward the vertical.
- , so : identical upward parabolas shifted vertically. Since , every particle moves to the right. There are no stagnation points because never vanishes.
- The first two equations are the rotation system, so , for the initial point ; and with gives . The flow line is the helix , rising per turn.
Tracing flow lines numerically
Most fields have no closed-form flow lines, so we integrate. This is where your Simulations course pays off. Forward Euler with step is
and RK4 combines four field samples per step. Here is a clean test that reveals the difference.
Worked example: why Euler spirals outward on a vortex
Apply Euler to the rotation field from a point at radius . The step is perpendicular to (the dot product ) and has length . By Pythagoras,
The factor is always bigger than 1, so the radius grows geometrically: . After time , using ,
One revolution () with multiplies the radius by about : a 37% error, and particles spiral off to infinity. The error shrinks only linearly with , as you’d expect for a first-order method.
RK4 applied to this linear field multiplies the state by the polynomial evaluated at (the eigenvalues of rotation are ; see 1.8 The Matrix Exponential: From Hops to Flows). Expanding,
For the radius changes by about one part in per step: RK4 spirals inward, but so slowly you will never see it in a visualization.
Things to try:
- On the solid-body vortex with pairs mode, watch the red Euler ring expand while the blue RK4 ring stays put. Read off “mean r / r₀” after one revolution () and compare with . For that predicts .
- Halve . The Euler drift roughly halves (first order). Switch to Heun (RK2) and see the drift drop much faster.
- Choose Stream + source, seed a line upstream, and find the stagnation point in front of the “body”. Then add some vortex strength and watch the stagnation point slide off the axis.
- On the bathtub drain (sink plus vortex), particles spiral in and disappear into the core.
Now implement both integrators yourself and measure the drift.
A visualization advects tracers in the rotation field with forward Euler, using steps per revolution (so ).
- Show that after one revolution the radius has grown by the factor , and evaluate it for and .
- Using , show the growth factor is approximately . How many steps per revolution keep the radius error under 1%?
- Heun’s method (RK2) applied to this field multiplies the radius by per step. How many steps per revolution does Heun need for the same 1% target?
Show worked solution
- Each step multiplies the radius by , and there are steps, so the factor is . For : , and , so the radius more than doubles in one turn. For : , and , still a 22% error.
- . For under 1% we need , so : about two thousand Euler steps per turn.
- Per revolution the factor is . We need , i.e. , so . Heun needs about 27 steps where Euler needs about 2000. That’s the payoff of a second-order method.
Elementary flows and superposition
Aerodynamicists build surprisingly realistic flows by adding up a few elementary ones. Each is placed at the origin here; shift to move it. We write and for the polar angle.
| Flow | Velocity | Flow lines | Potential |
|---|---|---|---|
| Uniform stream | horizontal lines | ||
| Source () / sink () | rays from the origin | ||
| Point vortex | circles | (multivalued!) | |
| Saddle / stagnation flow | hyperbolas | ||
| Solid-body rotation | circles | none |
Why for the source? Its speed is , so the volume of fluid crossing a circle of radius per unit time is speed times circumference, , the same for every circle. Fluid is created only at the origin and simply spreads out. The number is the source strength (area per time in 2D, i.e. volume per time per unit depth), and is the circulation of the vortex. Both get precise meanings in 2.7 Divergence: Sources & Sinks and 2.8 Curl & Vorticity. Notice the two different vortices: the point vortex is fastest near its center, like a bathtub drain, while solid-body rotation is fastest far away, like a turntable.
Velocities add, because the equations governing these ideal flows are linear. So any sum of elementary flows is another valid flow.
Worked example: the Rankine half-body
A uniform stream meets a source of strength at the origin. Where is the stagnation point?
On the -axis () the source velocity is , so the total horizontal velocity is
Setting gives , which is upstream of the source, where the source pushes left against the stream. Off the axis, , so this is the only stagnation point. The flow line through it splits into a curve that wraps around the source and extends downstream to the asymptotic half-width (far downstream all the source fluid, per unit time, travels at speed in a channel of total width ). Replace that curve by a solid surface and the outer flow is the flow around a blunt nose. With and , as in the sim’s preset, .
Gradient fields and potentials
A field is a gradient field (or conservative field) on a region if there is a scalar function , its potential, with
Every elementary flow except solid-body rotation is a gradient field, at least locally (the point vortex has a catch, explained below), which is why ideal aerodynamics is called potential flow. (Physicists usually write forces as with a minus sign, so that things roll downhill in potential energy. Fluid dynamicists write . Both are gradient fields; only the sign convention differs.)
Flow lines of a gradient field cross level curves at right angles. From 2.3 Gradient & Directional Derivatives, is perpendicular to the level curves of and points uphill. So the flow lines of are paths of steepest ascent, and gradient descent is Euler’s method on the field . A gradient flow can never return to where it started, because strictly increases along every non-stationary flow line: . That’s why rotation can’t be a gradient field: its flow lines are closed circles.
A test. If with smooth, then and , and Clairaut’s theorem () forces
If this fails anywhere, is not a gradient field. For rotation, but . Not a gradient. The difference is the 2D curl, which measures local spin; you’ll meet it in 2.8 Curl & Vorticity.
Worked example: recovering a potential
Is a gradient field? If so, find .
Test: and . They match, so a potential should exist. Integrate with respect to , treating as a constant, which means the “constant” of integration can depend on :
Differentiate with respect to and match to : , so and . Therefore
Check: ✓, ✓. This is the same procedure you’ll use for exact equations in 3.6 Exact Equations & Substitutions.
- Decide whether is a gradient field, and if so find a potential.
- Write the potential of the Rankine half-body flow (uniform stream plus source at the origin) and verify by differentiating that its gradient is the velocity field.
- Explain why adding the solid-body rotation to any gradient field produces a field that is not a gradient field.
Show worked solution
- and , so yes. Integrate in : . Then gives . So . Check: ✓, ✓.
- Potentials add, so . Then and , which is exactly the stream plus source.
- If for some , then would be a gradient. But for rotation, so that’s impossible. Equivalently, is additive and is zero for every gradient field, so the sum has .
Streamlines, pathlines and streaklines
Everything so far assumed a steady field. Real flows, like the wake behind a cylinder, a flapping wing, or gusty wind, change in time, . Then the innocent phrase “the curve the flow follows” splits into three different curves.
Transcript
- In a steady flow, smoke, particles and arrows all agree. When the flow changes in time, they stop agreeing, and you need three different words.
- Here is a simple unsteady flow: a stream moving right at speed U, with a sideways velocity V cosine omega t that flaps up and down. At any instant, every arrow is the same, but the arrows swing as time goes on.
- A streamline is a snapshot. Freeze the flow at one instant, then draw the curve that is tangent to the arrows everywhere. Here, at each frozen instant, the streamlines are straight lines, and they tilt as the flow flaps.
- A pathline is a history. Tag one fluid particle and follow it for a long time, like a long exposure photograph of a single glowing bead. This particle wiggles along a sine wave.
- Integrating x prime equals U and y prime equals V cosine omega t gives the pathline in closed form. It is a fixed sine shape, set by the moment the particle was released.
- A streakline is what you see in a wind tunnel. The injector releases dye continuously, and at this instant the streakline joins every particle that has ever passed through the injector. It looks like a flag waving in the breeze.
- Now put all three on the screen at the same instant. Cyan, the streamline. Amber, the pathline of the first particle released. Green, the streakline. Three different curves through the same flow.
- Notice two connections. The oldest dye particle is the first tagged particle, so the streakline ends exactly on the pathline. And right at the injector, the streakline leaves along the streamline, because fresh dye moves with the current arrow.
- Slow the flapping down to zero and the flow becomes steady. Then every arrow is the same forever, and all three curves fall onto one straight line.
- Experiments pick one picture each. A smoke wire gives streaklines. A long exposure of a tracer gives pathlines. Particle image velocimetry measures the velocity field at one instant, and its streamlines.
- And in your own simulator, all three are just particle tracing with RK4 in a time dependent field: one particle for a pathline, a stream of seeds for a streakline, and a frozen field for a streamline.
- Next lesson: we measure how much fluid a field pumps out of a point. That number is the divergence.
Streamline (a snapshot). Freeze time at and draw a curve tangent to the frozen field everywhere. With a dummy parameter :
Pathline (a history). Tag one fluid particle released from at time and follow it:
Streakline (a dye trace). Inject dye continuously at a fixed point . At time , the streakline is the set of current positions of every particle that passed through at some earlier time . Writing for the position at time of the particle released from at time ,
In a steady flow all three coincide: every particle follows the same frozen arrows, so the pathline is a streamline, and all the dye particles line up behind each other along it. In an unsteady flow they generally differ, and what you see in an experiment depends on how you look. Smoke wires and dye injectors show streaklines. A long-exposure photo of one tracer shows a pathline. Particle image velocimetry (PIV) measures the velocity field at an instant, from which you can draw streamlines.
Worked example: the flapping stream
For , find the streamline through the origin at time , the pathline of the particle released from the origin at time , and the streakline from a dye injector at the origin.
Streamline. At frozen time , the slope is , a constant. So the streamline through the origin is the straight line
which tilts back and forth as time passes.
Pathline. Integrate and from at time : and . Eliminate :
This is a sine wave of wavelength . Its shape is fixed once the particle is released.
Streakline. The particle released at time is, at time , at and . Eliminate :
This is a wave travelling downstream at speed while the whole curve heaves up and down, like a flag. It is a different curve from the pathline. Two consistency checks: the slope of the streakline at the injector is , which matches the streamline there, because fresh dye leaves along the current arrow. And as (steady flow), both curved formulas tend to , the steady streamline.
Pause the animation at a few instants and check the worked example against the picture. Then drag to zero and watch the three curves merge. The travelling-wave flow is a cartoon of a wake. Try there: the wave moves at exactly the flow speed, so each particle sees a constant velocity and its pathline is a straight line, even though the streamlines and streakline are wavy.
The last line confirms a fact from the video. The oldest dye particle is the tagged particle released at , so the streakline ends on the pathline.
A flow has velocity : it moves right at unit speed while its upward velocity ramps up linearly. A dye injector at the origin is switched on at .
- Find the streamline through the origin at time .
- Find the pathline of the particle released from the origin at , as a curve , and its position at .
- Find the streakline at as a curve , and give its range of .
- Sketch all three on one set of axes and check that the streakline meets the pathline and is tangent to the streamline where you expect.
Show worked solution
- At frozen time the field is everywhere, so and the streamline through the origin is .
- , with give and . Eliminating : . At the particle is at .
- The particle released at time has and . At , , so , for (dye released from to ).
- The streakline starts at the origin with slope , tangent to the streamline : fresh dye moves with the current velocity . It ends at , , which is the point on the pathline: the oldest dye particle is the one released at . The pathline curves upward (concave up) because each particle speeds up vertically over time, while the streakline is concave down. Three genuinely different curves.
Key Takeaways
- A vector field or assigns an arrow to every point. A fluid’s velocity (steady) or (unsteady) is the central example.
- Flow lines (integral curves) solve the autonomous ODE system . For their shape alone, solve . By uniqueness they never cross, except that they may approach stagnation points where .
- Numerically, particle tracing is just an ODE solve. Euler spirals outward on a vortex by the factor per step, so after time the radius has grown by about . RK4’s error is negligible by comparison.
- The elementary flows (uniform stream, source/sink, point vortex, saddle) superpose linearly. Stagnation points of a sum appear where the pieces cancel, such as for the Rankine half-body.
- A gradient field has flow lines perpendicular to the level curves of and never closes a loop. On a region without holes, is the test. Recover by integrating one component and matching the other.
- Streamlines are snapshots, pathlines are particle histories, and streaklines are dye traces from a fixed point. They coincide in steady flow and differ in unsteady flow. Smoke shows streaklines.
- Every flow visualization, and the advection step of every semi-Lagrangian fluid solver, is the particle tracing you practiced here.