Flow Lab

Syllabus / Module 2: Multivariable & Vector Calculus

Lesson 2.6

Vector Fields, Flow Lines & Streamlines

Vector fields in 2D and 3D, integral curves, streamlines vs. pathlines vs. streaklines, and gradient fields.

Written byClaude Opus

🌊
Why this matters for simulation: Visualizing a flow is integrating particles through a velocity field — exactly the ODE solvers you already know.

By the end of this lesson you can…

  • Read and sketch a 2D vector field by hand, and plot 2D and 3D fields with arrows colored by speed.
  • Explain why the flow lines of a field F are exactly the solutions of the ODE system x′ = F(x), and find them by hand for simple fields.
  • Trace particles through a field with Euler and RK4, and derive why Euler spirals outward on a vortex.
  • Write down and superpose the elementary flows (uniform stream, source, sink, vortex, saddle) and locate stagnation points.
  • Test whether a field is a gradient field and recover its potential by integration.
  • Distinguish streamlines, pathlines and streaklines in an unsteady flow, and compute all three for a simple example.
On this page
·
  1. A vector at every point
  2. Plotting vector fields
  3. Worked example: sketching a field by hand
  4. Flow lines are solutions of ODEs
  5. Finding flow lines by hand
  6. Worked example: the rotation field
  7. Worked example: the stagnation-point flow
  8. Fields in 3D
  9. Tracing flow lines numerically
  10. Worked example: why Euler spirals outward on a vortex
  11. Elementary flows and superposition
  12. Worked example: the Rankine half-body
  13. Gradient fields and potentials
  14. Worked example: recovering a potential
  15. Streamlines, pathlines and streaklines
  16. Worked example: the flapping stream
  17. Key Takeaways

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 Ax⃗A\vec x. 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 x⃗ ′=F⃗(x⃗)\vec x\,' = \vec F(\vec x) 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.

▶ Video Vector fields, flow lines as ODE solutions, Euler vs RK4, elementary flows and gradient fieldscaptions only
Transcript
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. Flip the sign and you get a sink, a drain that swallows fluid.
  16. A point vortex swirls around a center, again with speed one over r. Its flow lines are circles.
  17. 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.
  18. 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.
  19. Right in front of the nose the stream and the source cancel exactly. That point, where the velocity is zero, is a stagnation point.
  20. 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.
  21. 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.
  22. 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.
  23. 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.
  24. 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:

F⃗(x,y)=(P(x,y),  Q(x,y))=P ı^+Q ȷ^.\vec F(x, y) = \big(P(x, y),\; Q(x, y)\big) = P\,\hat\imath + Q\,\hat\jmath .

The two component functions PP and QQ 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, F⃗(x,y,z)=(P,Q,R)\vec F(x,y,z) = (P, Q, R). Compare this with a scalar field like temperature T(x,y)T(x,y), 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 u⃗\vec u. In a steady flow it depends only on position, u⃗(x,y)\vec u(x, y). In an unsteady flow it also changes in time, u⃗(x,y,t)\vec u(x, y, t). Some other examples:

  • Rotation F⃗=(−y,x)\vec F = (-y, x): at (1,0)(1, 0) the arrow is (0,1)(0, 1), at (0,1)(0, 1) it is (−1,0)(-1, 0). Everything swirls counterclockwise, and the speed x2+y2\sqrt{x^2+y^2} 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 MM at the origin: g⃗(x⃗)=−GM x⃗/∥x⃗∥3\vec g(\vec x) = -GM\,\vec x/\|\vec x\|^3, a 3D field pointing inward with strength falling off like 1/r21/r^2.
  • The gradient of a scalar function, ∇f=(fx,fy)\nabla f = (f_x, f_y), from 2.3 Gradient & Directional Derivatives. Every scalar field hands you a vector field for free.
  • Pressure force per unit volume, −∇p-\nabla p, 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:

  1. Scale the arrows down. True lengths would overlap, so plotters multiply every arrow by a common factor. Only relative length is meaningful.
  2. Or normalize and color. When speeds vary wildly (near a source the speed blows up), draw unit-length arrows and encode the speed ∥F⃗∥\|\vec F\| as color. The sims in this lesson do this.
  3. 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 streamplot draws them.

Worked example: sketching a field by hand

Sketch F⃗(x,y)=(y,x)\vec F(x, y) = (y, x).

Evaluate at a few points, starting with the axes:

point(1,0)(1,0)(0,1)(0,1)(−1,0)(-1,0)(0,−1)(0,-1)(1,1)(1,1)(1,−1)(1,-1)
F⃗\vec F(0,1)(0,1)(1,0)(1,0)(0,−1)(0,-1)(−1,0)(-1,0)(1,1)(1,1)(−1,1)(-1,1)

Two observations organize the sketch. On the line y=xy = x, the arrow is (x,x)(x, x), pointing straight away from the origin along that line. On y=−xy = -x, the arrow is (−x,x)(-x, x), 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 Ax⃗A\vec x with A=[0110]A = \begin{bmatrix} 0 & 1 \\ 1 & 0\end{bmatrix}, whose eigenvectors (1,1)(1,1) and (1,−1)(1,-1) have eigenvalues +1+1 and −1-1.

A useful trick when sketching: find the curves where P=0P = 0 (arrows vertical) and where Q=0Q = 0 (arrows horizontal). Here P=yP = y vanishes on the xx-axis, so the arrows there are vertical, and Q=xQ = x vanishes on the yy-axis, so the arrows there are horizontal. Watch out for the swap: the xx-axis carries the vertical arrows. Points where both vanish are stagnation points, where the flow stands still. This field has exactly one, the origin.

✅ Concept check

For the field $\vec F(x,y) = (x - y,\; x + y)$, which way does the arrow at the point $(0, 2)$ point?

🐍 PythonPlotting a field: quiver vs streamplot
⌘/Ctrl + Enter

Flow lines are solutions of ODEs

Drop a massless particle into the field and let it go wherever the arrow beneath it points. If x⃗(t)\vec x(t) is its position, the rule “velocity equals the field here” reads

dx⃗dt=F⃗(x⃗)⟺{x′(t)=P(x,y)y′(t)=Q(x,y).\frac{d\vec x}{dt} = \vec F(\vec x) \qquad\Longleftrightarrow\qquad \begin{cases} x'(t) = P(x, y) \\ y'(t) = Q(x, y). \end{cases}

A curve x⃗(t)\vec x(t) satisfying this is called an integral curve or flow line of F⃗\vec F. 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 F⃗\vec F 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 F⃗=0⃗\vec F = \vec 0 and the “flow line” is just a particle sitting still forever; nearby curves can approach them as t→±∞t \to \pm\infty 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 tt:

dydx=y′(t)x′(t)=Q(x,y)P(x,y).\frac{dy}{dx} = \frac{y'(t)}{x'(t)} = \frac{Q(x,y)}{P(x,y)} .

This is a single first-order ODE, often separable (3.3 Separable Equations).

Worked example: the rotation field

Find the flow lines of F⃗=(−y,x)\vec F = (-y, x).

The shape equation is dydx=x−y\dfrac{dy}{dx} = \dfrac{x}{-y}, i.e. y dy=−x dxy\,dy = -x\,dx. Integrating, 12y2=−12x2+C\tfrac12 y^2 = -\tfrac12 x^2 + C, so

x2+y2=r2.x^2 + y^2 = r^2 .

The flow lines are circles about the origin. For the timing, check that x=rcos⁡tx = r\cos t, y=rsin⁡ty = r\sin t works: x′=−rsin⁡t=−yx' = -r\sin t = -y and y′=rcos⁡t=xy' = r\cos t = x. ✓ Every particle goes once around its circle in time 2π2\pi, 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 F⃗=(x,−y)\vec F = (x, -y).

Here the system decouples: x′=xx' = x and y′=−yy' = -y give x=x0etx = x_0 e^{t}, y=y0e−ty = y_0 e^{-t}. Multiplying, xy=x0y0xy = x_0 y_0 is constant. The flow lines are the hyperbolas xy=Cxy = C, together with the four half-axes (C=0C = 0). Fluid comes in along the yy-axis and leaves along the xx-axis. Flip the picture so the xx-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 F⃗=(−y, x, c)\vec F = (-y,\, x,\, c), the first two components rotate exactly as before while z′=cz' = c climbs steadily. The flow lines are helices (rcos⁡t, rsin⁡t, z0+ct)\big(r\cos t,\ r\sin t,\ z_0 + ct\big), 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” u⃗=(Asin⁡z+Ccos⁡y, Bsin⁡x+Acos⁡z, Csin⁡y+Bcos⁡x)\vec u = (A\sin z + C\cos y,\ B\sin x + A\cos z,\ C\sin y + B\cos x) has chaotic flow lines, a first hint of 7.10 Chaos & the Lorenz System.

✏️ Pen & paperFlow lines by hand●○○

Find the flow lines of each field. Sketch a few and mark the direction of motion.

  1. F⃗=(x,2y)\vec F = (x, 2y)
  2. F⃗=(1,x)\vec F = (1, x)
  3. F⃗=(−y,x,1)\vec F = (-y, x, 1) through the point (1,0,0)(1, 0, 0), as a parametrized curve.
Show worked solution
  1. dydx=2yx\dfrac{dy}{dx} = \dfrac{2y}{x}, so dyy=2 dxx\dfrac{dy}{y} = \dfrac{2\,dx}{x} and ln⁡∣y∣=2ln⁡∣x∣+c\ln|y| = 2\ln|x| + c, giving y=Cx2y = Cx^2: a family of parabolas through the origin (plus the yy-axis, which corresponds to x=0x = 0). In time, x=x0etx = x_0e^t and y=y0e2ty = y_0 e^{2t}, so every particle moves away from the origin, which is an unstable node. The yy-component grows faster, so curves bend toward the vertical.
  2. dydx=x\dfrac{dy}{dx} = x, so y=12x2+Cy = \tfrac12 x^2 + C: identical upward parabolas shifted vertically. Since x′=1>0x' = 1 \gt 0, every particle moves to the right. There are no stagnation points because P=1P = 1 never vanishes.
  3. The first two equations are the rotation system, so x=cos⁡tx = \cos t, y=sin⁡ty = \sin t for the initial point (1,0)(1, 0); and z′=1z' = 1 with z(0)=0z(0) = 0 gives z=tz = t. The flow line is the helix x⃗(t)=(cos⁡t, sin⁡t, t)\vec x(t) = (\cos t,\ \sin t,\ t), rising 2π2\pi 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 hh is

x⃗n+1=x⃗n+h F⃗(x⃗n),\vec x_{n+1} = \vec x_n + h\,\vec F(\vec x_n),

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 F⃗=(−y,x)\vec F = (-y, x) from a point at radius rnr_n. The step hF⃗(x⃗n)h\vec F(\vec x_n) is perpendicular to x⃗n\vec x_n (the dot product (x,y)⋅(−y,x)=0(x, y)\cdot(-y, x) = 0) and has length h rnh\,r_n. By Pythagoras,

rn+12=rn2+(hrn)2=(1+h2) rn2⟹rn+1=1+h2  rn.r_{n+1}^2 = r_n^2 + (h r_n)^2 = (1 + h^2)\,r_n^2 \qquad\Longrightarrow\qquad r_{n+1} = \sqrt{1 + h^2}\;r_n .

The factor is always bigger than 1, so the radius grows geometrically: rn=(1+h2)n/2r0r_n = (1+h^2)^{n/2} r_0. After time T=nhT = nh, using ln⁡(1+h2)≈h2\ln(1+h^2) \approx h^2,

rnr0=(1+h2)T/(2h)≈ehT/2.\frac{r_n}{r_0} = (1+h^2)^{T/(2h)} \approx e^{hT/2}.

One revolution (T=2πT = 2\pi) with h=0.1h = 0.1 multiplies the radius by about 1.371.37: a 37% error, and particles spiral off to infinity. The error shrinks only linearly with hh, as you’d expect for a first-order method.

RK4 applied to this linear field multiplies the state by the polynomial R(z)=1+z+z22+z36+z424R(z) = 1 + z + \tfrac{z^2}{2} + \tfrac{z^3}{6} + \tfrac{z^4}{24} evaluated at z=ihz = ih (the eigenvalues of rotation are ±i\pm i; see 1.8 The Matrix Exponential: From Hops to Flows). Expanding,

∣R(ih)∣2=(1−h22+h424)2+(h−h36)2=1−h672+h8576.|R(ih)|^2 = \Big(1 - \tfrac{h^2}{2} + \tfrac{h^4}{24}\Big)^2 + \Big(h - \tfrac{h^3}{6}\Big)^2 = 1 - \frac{h^6}{72} + \frac{h^8}{576}.

For h=0.1h = 0.1 the radius changes by about one part in 10810^8 per step: RK4 spirals inward, but so slowly you will never see it in a visualization.

◆ Interactive Particle advection playground: superpose flows, seed particles, race Euler against RK4

Loading simulation…

Things to try:

  1. 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 (t≈6.3t \approx 6.3) and compare with (1+h2)π/h(1+h^2)^{\pi/h}. For h=0.2h = 0.2 that predicts 1.851.85.
  2. Halve hh. The Euler drift roughly halves (first order). Switch to Heun (RK2) and see the drift drop much faster.
  3. Choose Stream + source, seed a line upstream, and find the stagnation point in front of the “body”. Then add some vortex strength Γ\Gamma and watch the stagnation point slide off the axis.
  4. On the bathtub drain (sink plus vortex), particles spiral in and disappear into the core.
✅ Concept check

Forward Euler with $h = 0.1$ takes one step in the field $\vec F = (-y, x)$ starting from $(1, 0)$. What is the distance of the new point from the origin? (3 decimals)

Now implement both integrators yourself and measure the drift.

🧪 Coding exerciseExercise: RK4 particle tracing in a vortex
⌘/Ctrl + Enter
✏️ Pen & paperHow bad is Euler per revolution?●●○

A visualization advects tracers in the rotation field F⃗=(−y,x)\vec F = (-y, x) with forward Euler, using NN steps per revolution (so h=2π/Nh = 2\pi/N).

  1. Show that after one revolution the radius has grown by the factor (1+4π2/N2)N/2(1 + 4\pi^2/N^2)^{N/2}, and evaluate it for N=20N = 20 and N=100N = 100.
  2. Using ln⁡(1+ϵ)≈ϵ\ln(1+\epsilon)\approx\epsilon, show the growth factor is approximately e2π2/Ne^{2\pi^2/N}. How many steps per revolution keep the radius error under 1%?
  3. Heun’s method (RK2) applied to this field multiplies the radius by 1+h4/4\sqrt{1 + h^4/4} per step. How many steps per revolution does Heun need for the same 1% target?
Show worked solution
  1. Each step multiplies the radius by 1+h2\sqrt{1+h^2}, and there are NN steps, so the factor is (1+h2)N/2=(1+4π2/N2)N/2(1+h^2)^{N/2} = (1 + 4\pi^2/N^2)^{N/2}. For N=20N = 20: h2=0.0987h^2 = 0.0987, and 1.098710≈2.561.0987^{10} \approx 2.56, so the radius more than doubles in one turn. For N=100N = 100: h2=0.003948h^2 = 0.003948, and 1.00394850≈1.2181.003948^{50} \approx 1.218, still a 22% error.
  2. (1+h2)N/2=exp⁡ ⁣(N2ln⁡(1+h2))≈exp⁡ ⁣(N2h2)=exp⁡ ⁣(N2⋅4π2N2)=e2π2/N(1+h^2)^{N/2} = \exp\!\big(\tfrac N2 \ln(1 + h^2)\big) \approx \exp\!\big(\tfrac N2 h^2\big) = \exp\!\big(\tfrac N2\cdot\tfrac{4\pi^2}{N^2}\big) = e^{2\pi^2/N}. For under 1% we need 2π2/N<ln⁡1.01≈0.009952\pi^2/N \lt \ln 1.01 \approx 0.00995, so N>1984N \gt 1984: about two thousand Euler steps per turn.
  3. Per revolution the factor is (1+h4/4)N/2≈exp⁡(Nh4/8)=exp⁡ ⁣(N8⋅16π4N4)=exp⁡(2π4/N3)(1 + h^4/4)^{N/2} \approx \exp(N h^4/8) = \exp\!\big(\tfrac{N}{8}\cdot\tfrac{16\pi^4}{N^4}\big) = \exp(2\pi^4/N^3). We need 2π4/N3<0.009952\pi^4/N^3 \lt 0.00995, i.e. N3>19580N^3 \gt 19580, so N≥27N \geq 27. 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 x→x−x0x \to x - x_0 to move it. We write r2=x2+y2r^2 = x^2 + y^2 and θ\theta for the polar angle.

FlowVelocity u⃗\vec uFlow linesPotential φ\varphi
Uniform stream(U, 0)(U,\ 0)horizontal linesUxUx
Source (m>0m \gt 0) / sink (m<0m \lt 0)m2π(x, y)r2\dfrac{m}{2\pi}\dfrac{(x,\ y)}{r^2}rays from the originm2πln⁡r\dfrac{m}{2\pi}\ln r
Point vortexΓ2π(−y, x)r2\dfrac{\Gamma}{2\pi}\dfrac{(-y,\ x)}{r^2}circlesΓ2πθ\dfrac{\Gamma}{2\pi}\theta (multivalued!)
Saddle / stagnation flow(kx, −ky)(kx,\ -ky)hyperbolas xy=Cxy = Ck2(x2−y2)\tfrac k2(x^2 - y^2)
Solid-body rotationω(−y, x)\omega(-y,\ x)circlesnone

Why 1/r1/r for the source? Its speed is m2πr\dfrac{m}{2\pi r}, so the volume of fluid crossing a circle of radius rr per unit time is speed times circumference, m2πr⋅2πr=m\dfrac{m}{2\pi r}\cdot 2\pi r = m, the same for every circle. Fluid is created only at the origin and simply spreads out. The number mm is the source strength (area per time in 2D, i.e. volume per time per unit depth), and Γ\Gamma 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 (U,0)(U, 0) meets a source of strength mm at the origin. Where is the stagnation point?

On the xx-axis (y=0y = 0) the source velocity is m2π(x,0)x2=(m2πx, 0)\dfrac{m}{2\pi}\dfrac{(x, 0)}{x^2} = \Big(\dfrac{m}{2\pi x},\ 0\Big), so the total horizontal velocity is

u(x,0)=U+m2πx.u(x, 0) = U + \frac{m}{2\pi x}.

Setting u=0u = 0 gives xs=−m2πUx_s = -\dfrac{m}{2\pi U}, which is upstream of the source, where the source pushes left against the stream. Off the axis, v=m2πyr2≠0v = \dfrac{m}{2\pi}\dfrac{y}{r^2} \neq 0, 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 ±m2U\pm\dfrac{m}{2U} (far downstream all the source fluid, mm per unit time, travels at speed UU in a channel of total width m/Um/U). Replace that curve by a solid surface and the outer flow is the flow around a blunt nose. With U=1U = 1 and m=6m = 6, as in the sim’s preset, xs=−3/π≈−0.95x_s = -3/\pi \approx -0.95.

Gradient fields and potentials

A field F⃗\vec F is a gradient field (or conservative field) on a region if there is a scalar function φ\varphi, its potential, with

F⃗=∇φ=(∂φ∂x, ∂φ∂y).\vec F = \nabla\varphi = \Big(\frac{\partial\varphi}{\partial x},\ \frac{\partial\varphi}{\partial y}\Big).

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 F⃗=−∇V\vec F = -\nabla V with a minus sign, so that things roll downhill in potential energy. Fluid dynamicists write u⃗=+∇φ\vec u = +\nabla\varphi. 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, ∇φ\nabla\varphi is perpendicular to the level curves of φ\varphi and points uphill. So the flow lines of ∇φ\nabla \varphi are paths of steepest ascent, and gradient descent is Euler’s method on the field −∇φ-\nabla\varphi. A gradient flow can never return to where it started, because φ\varphi strictly increases along every non-stationary flow line: ddtφ(x⃗(t))=∇φ⋅x⃗ ′=∥∇φ∥2≥0\dfrac{d}{dt}\varphi(\vec x(t)) = \nabla\varphi\cdot\vec x\,' = \|\nabla\varphi\|^2 \geq 0. That’s why rotation can’t be a gradient field: its flow lines are closed circles.

A test. If F⃗=(P,Q)=∇φ\vec F = (P, Q) = \nabla\varphi with φ\varphi smooth, then P=φxP = \varphi_x and Q=φyQ = \varphi_y, and Clairaut’s theorem (φxy=φyx\varphi_{xy} = \varphi_{yx}) forces

∂P∂y=∂Q∂x.\frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x}.

If this fails anywhere, F⃗\vec F is not a gradient field. For rotation, ∂P/∂y=∂(−y)/∂y=−1\partial P/\partial y = \partial(-y)/\partial y = -1 but ∂Q/∂x=1\partial Q/\partial x = 1. Not a gradient. The difference Qx−PyQ_x - P_y is the 2D curl, which measures local spin; you’ll meet it in 2.8 Curl & Vorticity.

Worked example: recovering a potential

Is F⃗=(2xy+1, x2+3y2)\vec F = (2xy + 1,\ x^2 + 3y^2) a gradient field? If so, find φ\varphi.

Test: Py=2xP_y = 2x and Qx=2xQ_x = 2x. They match, so a potential should exist. Integrate PP with respect to xx, treating yy as a constant, which means the “constant” of integration can depend on yy:

φ=∫(2xy+1) dx=x2y+x+g(y).\varphi = \int (2xy + 1)\,dx = x^2 y + x + g(y).

Differentiate with respect to yy and match to QQ: φy=x2+g′(y)=x2+3y2\varphi_y = x^2 + g'(y) = x^2 + 3y^2, so g′(y)=3y2g'(y) = 3y^2 and g=y3+Cg = y^3 + C. Therefore

φ(x,y)=x2y+x+y3+C.\varphi(x, y) = x^2y + x + y^3 + C.

Check: φx=2xy+1\varphi_x = 2xy + 1 ✓, φy=x2+3y2\varphi_y = x^2 + 3y^2 ✓. This is the same procedure you’ll use for exact equations in 3.6 Exact Equations & Substitutions.

✅ Concept checkselect all that apply

Select every field that is a gradient field on the whole plane.

✏️ Pen & paperPotentials of superposed flows●●○
  1. Decide whether F⃗=(ycos⁡x+2x, sin⁡x−1)\vec F = (y\cos x + 2x,\ \sin x - 1) is a gradient field, and if so find a potential.
  2. Write the potential of the Rankine half-body flow (uniform stream UU plus source mm at the origin) and verify by differentiating that its gradient is the velocity field.
  3. Explain why adding the solid-body rotation ω(−y,x)\omega(-y, x) to any gradient field produces a field that is not a gradient field.
Show worked solution
  1. Py=cos⁡xP_y = \cos x and Qx=cos⁡xQ_x = \cos x, so yes. Integrate PP in xx: φ=ysin⁡x+x2+g(y)\varphi = y\sin x + x^2 + g(y). Then φy=sin⁡x+g′(y)=sin⁡x−1\varphi_y = \sin x + g'(y) = \sin x - 1 gives g=−yg = -y. So φ=ysin⁡x+x2−y+C\varphi = y\sin x + x^2 - y + C. Check: φx=ycos⁡x+2x\varphi_x = y\cos x + 2x ✓, φy=sin⁡x−1\varphi_y = \sin x - 1 ✓.
  2. Potentials add, so φ=Ux+m2πln⁡r=Ux+m4πln⁡(x2+y2)\varphi = Ux + \dfrac{m}{2\pi}\ln r = Ux + \dfrac{m}{4\pi}\ln(x^2+y^2). Then φx=U+m4π2xx2+y2=U+m2πxr2\varphi_x = U + \dfrac{m}{4\pi}\dfrac{2x}{x^2+y^2} = U + \dfrac{m}{2\pi}\dfrac{x}{r^2} and φy=m2πyr2\varphi_y = \dfrac{m}{2\pi}\dfrac{y}{r^2}, which is exactly the stream plus source.
  3. If ∇φ+ω(−y,x)=∇ψ\nabla\varphi + \omega(-y, x) = \nabla\psi for some ψ\psi, then ω(−y,x)=∇(ψ−φ)\omega(-y, x) = \nabla(\psi - \varphi) would be a gradient. But Qx−Py=ω−(−ω)=2ω≠0Q_x - P_y = \omega - (-\omega) = 2\omega \neq 0 for rotation, so that’s impossible. Equivalently, Qx−PyQ_x - P_y is additive and is zero for every gradient field, so the sum has Qx−Py=2ωQ_x - P_y = 2\omega.

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, u⃗(x⃗,t)\vec u(\vec x, t). Then the innocent phrase “the curve the flow follows” splits into three different curves.

▶ Video Streamlines vs pathlines vs streaklines in an unsteady flowcaptions only
Transcript
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. 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.
  12. 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 tt and draw a curve tangent to the frozen field u⃗(⋅,t)\vec u(\cdot, t) everywhere. With a dummy parameter ss:

dx⃗ds=u⃗(x⃗,t)(t held fixed).\frac{d\vec x}{ds} = \vec u(\vec x, t) \quad (t \text{ held fixed}).

Pathline (a history). Tag one fluid particle released from x⃗0\vec x_0 at time t0t_0 and follow it:

dx⃗dt=u⃗(x⃗,t),x⃗(t0)=x⃗0.\frac{d\vec x}{dt} = \vec u(\vec x, t), \qquad \vec x(t_0) = \vec x_0 .

Streakline (a dye trace). Inject dye continuously at a fixed point x⃗0\vec x_0. At time tt, the streakline is the set of current positions of every particle that passed through x⃗0\vec x_0 at some earlier time τ≤t\tau \leq t. Writing X⃗(t; x⃗0,τ)\vec X(t;\,\vec x_0, \tau) for the position at time tt of the particle released from x⃗0\vec x_0 at time τ\tau,

streakline at time t={ X⃗(t; x⃗0,τ):τ≤t }.\text{streakline at time } t = \big\{\, \vec X(t;\,\vec x_0,\tau) : \tau \leq t \,\big\}.

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 u⃗=(U, Vcos⁡ωt)\vec u = (U,\ V\cos\omega t), find the streamline through the origin at time tt, the pathline of the particle released from the origin at time t0t_0, and the streakline from a dye injector at the origin.

Streamline. At frozen time tt, the slope is dydx=Vcos⁡ωtU\dfrac{dy}{dx} = \dfrac{V\cos\omega t}{U}, a constant. So the streamline through the origin is the straight line

y=Vcos⁡ωtU x,y = \frac{V\cos\omega t}{U}\,x ,

which tilts back and forth as time passes.

Pathline. Integrate x′=Ux' = U and y′=Vcos⁡ωty' = V\cos\omega t from (0,0)(0, 0) at time t0t_0: x=U(t−t0)x = U(t - t_0) and y=Vω(sin⁡ωt−sin⁡ωt0)y = \dfrac{V}{\omega}\big(\sin\omega t - \sin\omega t_0\big). Eliminate t=t0+x/Ut = t_0 + x/U:

y=Vω[sin⁡(ωt0+ωxU)−sin⁡ωt0].y = \frac{V}{\omega}\Big[\sin\Big(\omega t_0 + \frac{\omega x}{U}\Big) - \sin\omega t_0\Big].

This is a sine wave of wavelength 2πU/ω2\pi U/\omega. Its shape is fixed once the particle is released.

Streakline. The particle released at time τ\tau is, at time tt, at x=U(t−τ)x = U(t - \tau) and y=Vω(sin⁡ωt−sin⁡ωτ)y = \dfrac{V}{\omega}(\sin\omega t - \sin\omega\tau). Eliminate τ=t−x/U\tau = t - x/U:

y=Vω[sin⁡ωt−sin⁡(ωt−ωxU)],x≥0.y = \frac{V}{\omega}\Big[\sin\omega t - \sin\Big(\omega t - \frac{\omega x}{U}\Big)\Big], \qquad x \geq 0 .

This is a wave travelling downstream at speed UU 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 Vω⋅ωUcos⁡ωt=Vcos⁡ωtU\dfrac{V}{\omega}\cdot\dfrac{\omega}{U}\cos\omega t = \dfrac{V\cos\omega t}{U}, which matches the streamline there, because fresh dye leaves along the current arrow. And as ω→0\omega \to 0 (steady flow), both curved formulas tend to y=Vx/Uy = Vx/U, the steady streamline.

◆ Interactive Dye injector in an unsteady flow: streamline, pathlines and streakline at once

Loading simulation…

Pause the animation at a few instants and check the worked example against the picture. Then drag ω\omega to zero and watch the three curves merge. The travelling-wave flow u⃗=(U,Vcos⁡(ωt−x))\vec u = (U, V\cos(\omega t - x)) is a cartoon of a wake. Try ω=1\omega = 1 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.

✅ Concept check

An engineer releases smoke continuously from a thin nozzle upstream of a model in a wind tunnel and photographs it. The flow behind the model is unsteady (vortices shed periodically). What does the photo show?

🐍 PythonComputing all three lines numerically with RK4
⌘/Ctrl + Enter

The last line confirms a fact from the video. The oldest dye particle is the tagged particle released at t=0t = 0, so the streakline ends on the pathline.

✏️ Pen & paperThree lines in a ramping flow●●●

A flow has velocity u⃗(x,y,t)=(1, t)\vec u(x, y, t) = (1,\ t): it moves right at unit speed while its upward velocity ramps up linearly. A dye injector at the origin is switched on at t=0t = 0.

  1. Find the streamline through the origin at time t=2t = 2.
  2. Find the pathline of the particle released from the origin at t=0t = 0, as a curve y(x)y(x), and its position at t=2t = 2.
  3. Find the streakline at t=2t = 2 as a curve y(x)y(x), and give its range of xx.
  4. 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
  1. At frozen time t=2t = 2 the field is (1,2)(1, 2) everywhere, so dy/dx=2dy/dx = 2 and the streamline through the origin is y=2xy = 2x.
  2. x′=1x' = 1, y′=ty' = t with x(0)=y(0)=0x(0) = y(0) = 0 give x=tx = t and y=t2/2y = t^2/2. Eliminating tt: y=x2/2y = x^2/2. At t=2t = 2 the particle is at (2,2)(2, 2).
  3. The particle released at time τ∈[0,2]\tau \in [0, 2] has x=t−τx = t - \tau and y=∫τts ds=12(t2−τ2)y = \int_\tau^t s\,ds = \tfrac12(t^2 - \tau^2). At t=2t = 2, τ=2−x\tau = 2 - x, so y=12(4−(2−x)2)=2x−12x2y = \tfrac12\big(4 - (2-x)^2\big) = 2x - \tfrac12 x^2, for 0≤x≤20 \leq x \leq 2 (dye released from τ=0\tau = 0 to τ=2\tau = 2).
  4. The streakline y=2x−x2/2y = 2x - x^2/2 starts at the origin with slope 2−x=22 - x = 2, tangent to the streamline y=2xy = 2x: fresh dye moves with the current velocity (1,2)(1, 2). It ends at x=2x = 2, y=4−2=2y = 4 - 2 = 2, which is the point (2,2)(2, 2) on the pathline: the oldest dye particle is the one released at t=0t = 0. The pathline y=x2/2y = x^2/2 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 F⃗=(P,Q)\vec F = (P, Q) or (P,Q,R)(P, Q, R) assigns an arrow to every point. A fluid’s velocity u⃗(x⃗)\vec u(\vec x) (steady) or u⃗(x⃗,t)\vec u(\vec x, t) (unsteady) is the central example.
  • Flow lines (integral curves) solve the autonomous ODE system x⃗ ′=F⃗(x⃗)\vec x\,' = \vec F(\vec x). For their shape alone, solve dy/dx=Q/Pdy/dx = Q/P. By uniqueness they never cross, except that they may approach stagnation points where F⃗=0⃗\vec F = \vec 0.
  • Numerically, particle tracing is just an ODE solve. Euler spirals outward on a vortex by the factor 1+h2\sqrt{1+h^2} per step, so after time TT the radius has grown by about ehT/2e^{hT/2}. 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 xs=−m/(2πU)x_s = -m/(2\pi U) for the Rankine half-body.
  • A gradient field F⃗=∇φ\vec F = \nabla\varphi has flow lines perpendicular to the level curves of φ\varphi and never closes a loop. On a region without holes, ∂P/∂y=∂Q/∂x\partial P/\partial y = \partial Q/\partial x is the test. Recover φ\varphi 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.
Finished this lesson?

Mark it complete to track your progress (saved in this browser). Reading every section does this for you.

Where this leads

These later lessons build directly on this one: