Learning Objectives
By the end of this section, you will be able to:
- Explain why the Navier-Stokes equations are just Newton's second law applied to a chunk of fluid you can shrink to a point.
- Derive the continuity equation from conservation of mass using the Reynolds Transport Theorem.
- Construct the material derivative and explain its two pieces physically.
- Derive Cauchy's momentum equation from a force balance on an infinitesimal cube.
- Apply the Newtonian constitutive law to close the system and obtain the full Navier-Stokes equations.
- Implement the viscous diffusion term in both plain Python and PyTorch, and predict its output by hand.
The Big Picture: Newton's 2nd Law on a Tiny Box
Every equation in this section is one sentence: for any small chunk of fluid, the rate of change of momentum equals the net force on it. The work is just turning that one sentence into mathematics that survives shrinking the chunk to a single point.
Picture a swimming pool. Mentally draw a small cube anywhere inside it. The water in that cube has some momentum. A moment later that water has moved a little, swirled a little, and its momentum has changed. By how much? Newton's second law tells us exactly:
That equation is true for a baseball, a planet — and a cube of water. The problem is that "the cube of water" is being constantly reshuffled by neighbouring water flowing in and out. We need a clean way to talk about how a property of the fluid changes when the fluid is itself moving. That tool is the Reynolds Transport Theorem, and it is the trick that unlocks all of fluid dynamics.
Conserve mass — get the continuity equation.
Conserve momentum — get Cauchy's equation.
Close Cauchy with a Newtonian stress law — get Navier-Stokes.
Two Views of a Fluid: Lagrangian vs Eulerian
Before writing a single derivative, we need to agree on what we are differentiating with respect to. There are two natural choices, and they look at the same fluid from opposite vantage points.
🚣 Lagrangian view — ride along with a particle
Pick one fluid particle. Follow it. Track its position , velocity , temperature . This is what Newton's second law is literally about — "m a = F" for one particle.
Analogy: dye dropped into the pool; you watch the dye blob.
📷 Eulerian view — fix a window in space
Pick a fixed point in space. Track what is passing through it: , , . This is what experiments and numerical grids actually measure.
Analogy: a thermometer bolted to the lane line; you watch whatever water happens to be touching it.
Why both views matter
Newton's law lives in the Lagrangian world. Measurements and computer grids live in the Eulerian world. The bridge between them is the material derivative, which we'll build in Step 3. The Reynolds Transport Theorem is the same bridge applied to volume integrals.
Step 1 — Reynolds Transport Theorem
Let be the total amount of some property (mass, momentum, energy) inside a material volume — meaning a blob of fluid that we follow as it moves and deforms. The Reynolds Transport Theorem translates the rate of change of from the moving Lagrangian volume to a fixed Eulerian volume with the same instantaneous shape:
In words: total change inside the moving blob equals local change at every point of the (fixed-shape) box plus net flux of being carried across its boundary. The second term is a bookkeeping correction: stuff that flowed into our snapshot box wasn't actually "created" — it was just transported in by the velocity field.
Total in the moving blob. Newton's view.
How the field is changing point-by-point with the box held fixed.
Net amount of leaving through the box surface.
Where RTT comes from
It's a multivariable generalisation of the Leibniz rule for differentiating an integral with moving limits. The boundary moves with velocity , so the surface integral picks up the familiar "evaluate at the moving endpoint" correction — just spread out over a closed surface instead of two endpoints.
Step 2 — Conservation of Mass
We pick in RTT. Conservation of mass says: the total mass inside a material volume cannot change (no nuclear reactions, please).
Apply RTT to the left-hand side and use the divergence theorem on the flux term (turning the surface integral into a volume integral):
Since this holds for every control volume — and only the zero function integrates to zero on every region — the integrand itself must vanish. We get the continuity equation:
For an incompressible fluid is constant, and the continuity equation collapses to the famously elegant
— "the velocity field is divergence-free." Visually: whatever enters a tiny box, the same amount leaves. The visualizer below makes this physical.
Interactive: Flux Through a Control Volume
Try this: pick the Source field. Net outflow ≈ 2a · (box area). Now pick Vortex — net outflow is essentially zero no matter where you drag the box. That's ∇·v = 0 in action: the fluid is just spinning, not accumulating.
Step 3 — The Material Derivative
Newton's law wants the acceleration of a fluid particle — its Lagrangian acceleration. But the velocity field we work with is Eulerian: tells you what the velocity is at a fixed point. How are the two related?
Let be the trajectory of a particle. Its velocity is . Take the time derivative by the chain rule:
But . So
This is the material derivative. It packages "the rate of change a particle actually experiences" into one symbol . The two terms answer two different questions:
| Term | What it answers | Zero when… |
|---|---|---|
| ∂v/∂t (local) | How is the field changing right here over time? | the flow is steady — the field doesn't depend on t |
| (v·∇)v (convective) | How does v differ from one point to the next, weighted by where the particle is heading? | the particle moves perpendicular to all gradients, or the field is uniform |
Both terms can vanish independently
A garden hose with the spigot fully open produces a steady jet — the velocity at the nozzle doesn't change in time, so the local term is zero. But a fluid particle accelerates from rest in the pipe to high speed at the nozzle — the convective term is doing all the work.
Interactive: Local vs Convective Rate of Change
We replace with a scalar field for clarity. The same formula applies:
Step 4 — Momentum Balance (Cauchy's Equation)
Now we apply RTT with (momentum per unit volume) and equate the rate of change of momentum to the sum of forces. There are two kinds of forces on a fluid element:
- Body forces per unit volume — gravity, electromagnetic, etc. They act on every molecule of the cube.
- Surface forces per unit area — pressure pushing on each face, and viscous stresses tangential to each face. Both are captured in the stress tensor .
The momentum balance reads
Apply RTT to the left, the divergence theorem to the surface integral on the right, and use the continuity equation to simplify. The volume integrals must agree for every blob, so the integrands match. After the dust settles you get Cauchy's equation of motion:
Read it like Newton's law: "density × acceleration of the particle = body force + divergence of stress". We're done with calculus. Everything left is physics — what form does take?
Step 5 — The Stress Tensor
The stress tensor is a 3×3 matrix whose entry is the force per unit area in direction acting on a face whose outward normal points in direction . Diagonals push or pull perpendicular to the face (normal stress); off-diagonals shear it (tangential stress).
For a fluid at rest, only pressure acts, and it pushes inward equally in every direction:
For a fluid in motion we add a deviatoric piece that captures how molecules drag past their neighbours:
Cauchy's equation now becomes:
We have one equation and an unknown 3×3 tensor field . We need a constitutive law — an extra physical assumption that tells us how depends on the flow.
Step 6 — The Newtonian Closure
Newton's hypothesis (1687, restated rigorously by Stokes in 1845): viscous stress is linear in the rate of strain. For an incompressible Newtonian fluid:
The combination in parentheses is twice the symmetric part of the velocity gradient — the rate-of-strain tensor. The constant is the dynamic viscosity; honey has a big , air has a tiny one.
Taking the divergence (and using for incompressibility) gives the marvellous simplification:
That is the famous Laplacian-of-velocity viscous term. Physically: viscosity tries to diffuse velocity — sharp gradients get smeared out, just like heat diffusing through a metal rod.
Why linear is reasonable
Linearity is exact when the deformation is slow compared to molecular relaxation times — true for water, air, oil under normal conditions. Non-Newtonian fluids (ketchup, blood, polymer melts) need a fancier law, but the rest of the derivation is unchanged.
Step 7 — Assembling the Navier-Stokes Equations
Substitute the Newtonian closure into Cauchy's equation:
Four scalar equations (three components of momentum + continuity) in four scalar unknowns (). Let's name every piece one last time so the equation never looks foreign again:
| Piece | Physical meaning | Source |
|---|---|---|
| ρ ∂v/∂t | Mass × local acceleration (unsteady inertia) | Reynolds Transport Theorem |
| ρ (v·∇)v | Mass × convective acceleration — being swept through gradients | Material derivative chain rule |
| −∇p | Net pressure push (high → low) | Pressure part of σ |
| μ ∇²v | Viscous diffusion of momentum | Newtonian closure of τ |
| ρf | Body forces (gravity, etc.) | Newton's second law |
| ∇·v = 0 | Mass conservation for incompressible flow | Continuity equation |
The nonlinearity that breaks everything
is the only nonlinear term — and it is the source of turbulence, vortex shedding, weather chaos, and the open Millennium Prize problem. Without it the equations would collapse to a heat equation for velocity and we could solve them on paper.
Worked Example: 1D Viscous Diffusion of a Velocity Bump
We strip the full equation to its bones to isolate the viscous term. Take , , and the convective term all to zero. Only one component of velocity survives, depending on one coordinate between two parallel walls. Navier-Stokes collapses to:
— pure 1D diffusion of momentum, with no-slip walls at . This is the same equation as heat in a rod. Below we work it out by hand on a tiny grid, then verify with code.
📐 Click to expand: hand calculation on a 5-node grid
Use 5 grid points with spacing , and a time step , kinematic viscosity . The discrete second derivative at interior node is:
The explicit Euler update is then
For our numbers . Initial profile: a unit spike at the middle node . Walls pinned to zero. One step:
| j | u^0[j] | u^0[j+1] − 2u^0[j] + u^0[j−1] | u^1[j] = u^0[j] + 0.1 × … |
|---|---|---|---|
| 0 | 0 | — (wall, pinned to 0) | 0 |
| 1 | 0 | 1 − 0 + 0 = 1 | 0 + 0.1 × 1 = 0.1 |
| 2 | 1 | 0 − 2 + 0 = −2 | 1 + 0.1 × (−2) = 0.8 |
| 3 | 0 | 0 − 0 + 1 = 1 | 0 + 0.1 × 1 = 0.1 |
| 4 | 0 | — (wall, pinned to 0) | 0 |
After one step: . The spike lost from the middle and donated to each neighbour. That redistribution is literally what means in this problem.
Total "mass of velocity" is conserved at the interior level (0.1 + 0.8 + 0.1 = 1.0), but the walls drain it. As the profile flattens to zero everywhere — momentum has fully dissipated through the walls.
Interactive: Viscosity Smears Momentum
Python Implementation
The whole worked example is below as 20 lines of NumPy. The output of the toy run matches our table by hand exactly:
What you just simulated: the right-hand side of NS with everything but the viscous term zeroed out. Add back the pressure gradient and you get the classic Stokes problem; add back the convective term and you get the full nonlinearity — and the open Millennium Prize question of whether it can ever blow up in 3D.
PyTorch Tensor Implementation
Same physics, same arithmetic, swap NumPy for PyTorch. For 1D it's overkill — but the moment you move to 2D / 3D Navier-Stokes on a real grid the GPU speedup is enormous, and you also get autograd for free (handy for inverse-problem and ML-flavoured CFD).
Parity check
Both the NumPy and PyTorch versions print [0.0, 0.1, 0.8, 0.1, 0.0] after one step. That matches our hand calculation in the collapsible example above. Whenever you port a numerical routine across libraries, this kind of bit-for-bit equivalence is the test you want to keep around — it catches indexing bugs, off-by-one stencil shifts, and dtype mismatches.
Common Mistakes to Avoid
holds fixed; (and the material derivative ) follows the particle. A steady flow has but the particle can still accelerate.
It looks like a product of derivatives, but itself is the unknown — that's what makes NS unsolved analytically in 3D. Treating it as a small perturbation is the Stokes-flow approximation, valid only for very low Reynolds numbers.
Without no-slip the viscous term has nothing to push against and energy is never dissipated. Every numerical NS solver pins the wall velocity to the wall's velocity — usually zero for stationary walls.
For the FTCS viscous scheme, . Violate it and round-off blows up exponentially. Implicit schemes (Crank-Nicolson, backward Euler) have no such restriction but cost a linear solve per step.
It looks like friction, but it's really diffusion of momentum. Friction usually dissipates energy locally; viscosity transports momentum from fast layers to slow layers, then ultimately dumps it into the walls. The first sentence of every fluids paper that mishandles this is wrong.
Summary
We turned Newton's second law into the Navier-Stokes equations in seven steps:
- Picked an arbitrary blob of fluid and decided to use Reynolds Transport Theorem as the bridge between Lagrangian (follow-the-particle) and Eulerian (fixed grid) descriptions.
- Set and got the continuity equation , which becomes for incompressible flow.
- Built the material derivative from the chain rule — local rate plus convective rate.
- Set and balanced momentum against body + surface forces to get Cauchy's equation .
- Decomposed the stress tensor into pressure + deviatoric: .
- Closed the system with the Newtonian linear law , which for incompressible flow gives .
- Assembled everything into the Navier-Stokes equations and verified the viscous term numerically in both NumPy and PyTorch.
Coming Next: we'll spend a whole section on the continuity equation alone — what it implies geometrically, how compressibility breaks it, and why divergence-free vector fields are central to fluid simulation algorithms like projection methods.