Verifying Couette Flow Using Julia: From Navier–Stokes to Discretization Proof
Couette flow is one of the most elegant validation problems in computational fluid dynamics (CFD). It strips the Navier–Stokes equations down to their viscous core and gives us a linear velocity profile that can be derived analytically and verified numerically.
In this post, we:
Derive the governing equation from first principles
Prove the finite difference discretization of the second-order derivative
Implement the solver in Julia
Verify the numerical solution against the analytical result
1. Physical Setup: Plane Couette Flow
Two infinite parallel plates separated by distance $H$:
Bottom plate: stationary
Top plate: moving with velocity $U$
Flow is steady
Incompressible
No pressure gradient
One-dimensional velocity field
Velocity field:
$$\mathbf{u} = (u(y), 0, 0)$$
2. Reduction of Navier–Stokes
The incompressible Navier–Stokes equation is:
$$
\rho (\mathbf{u} \cdot \nabla)\mathbf{u}
$$
- \nabla p
\mu \nabla^2 \mathbf{u} $$
For steady, fully developed Couette flow:
Convective term = 0
Pressure gradient = 0
Only viscous diffusion remains
So we obtain:
$$\mu \frac{d^2 u}{dy^2} = 0$$
Since \(\mu \neq 0\):
$$\frac{d^2 u}{dy^2} = 0$$
This is a second-order ordinary differential equation.
3. Analytical Solution
Integrate once:
$$\frac{du}{dy} = C_1$$
Integrate again:
$$u(y) = C_1 y + C_2$$
Apply boundary conditions:
$$u(0) = 0$$
$$u(H) = U$$
Solving gives:
$$u(y) = \frac{U}{H} y$$
The velocity profile is linear.
4. Mathematical Proof of Finite Difference Discretization
We now discretize:
$$\frac{d^2 u}{dy^2}$$
using Taylor series expansion.
4.1 Taylor Expansion
Expand \(u(y + \Delta y)\):
$$ u_{i+1}
u_i + \Delta y u'_i + \frac{\Delta y^2}{2} u''_i + \frac{\Delta y^3}{6} u'''_i + O(\Delta y^4) $$
Expand \(u(y - \Delta y)\):
$$ u_{i-1}
u_i
\Delta y u'_i + \frac{\Delta y^2}{2} u''_i
\frac{\Delta y^3}{6} u'''_i + O(\Delta y^4) $$
4.2 Add the Two Expansions
$$ u_{i+1} + u_{i-1}
2u_i + \Delta y^2 u''_i + O(\Delta y^4) $$
Rearranging:
$$ u''_i
\frac{u_{i+1} - 2u_i + u_{i-1}}{\Delta y^2} + O(\Delta y^2) $$
4.3 Conclusion
The central difference formula:
$$\frac{d^2 u}{dy^2} \approx \frac{u_{i+1} - 2u_i + u_{i-1}}{\Delta y^2}$$
is:
Second-order accurate
Symmetric
Consistent with diffusion physics
5. Discrete System
Since:
$$\frac{d^2 u}{dy^2} = 0$$
We obtain:
$$u_{i+1} - 2u_i + u_{i-1} = 0$$
Or equivalently:
$$u_i = \frac{u_{i+1} + u_{i-1}}{2}$$
This forms a linear algebra system:
$$A u = b$$
with boundary conditions embedded.
6. Julia Implementation
using LinearAlgebra
using Plots
H = 1.0
U = 1.0
N = 50
dy = H/(N-1)
A = zeros(N, N)
b = zeros(N)
# Boundary conditions
A[1,1] = 1
b[1] = 0.0
A[N,N] = 1
b[N] = U
# Interior nodes
for i in 2:N-1
A[i,i-1] = 1
A[i,i] = -2
A[i,i+1] = 1
end
u = A\b
y = LinRange(0, H, N)
u_exact = U .* y ./ H
p = plot(u, y, label="Numerical", linewidth=3)
plot!(p, u_exact, y, linestyle=:dash, label="Analytical")
xlabel!("Velocity")
ylabel!("y")
title!("Couette Flow Verification")
display(p)
error = sqrt(sum((u .- u_exact).^2)/N)
println("L2 Error = ", error)

