Flow Lab

Syllabus / Module 9: Classical PDEs: Heat, Waves & Potentials

Lesson 9.2

The Heat (Diffusion) Equation

Derivation from energy conservation and Fourier's law; diffusion as averaging; maximum principle; steady states.

Written byClaude Sonnet

🌊
Why this matters for simulation: Viscosity diffuses momentum: the ν∇²u term in Navier–Stokes is a heat equation for velocity.

By the end of this lesson you can…

  • Derive $u_t = \alpha u_{xx}$ from energy conservation on a thin slab plus Fourier's law, and say what $\alpha = k/(\rho c)$ measures.
  • Read $u_{xx}$ as the neighbor average minus the centre, and use that to predict whether a point warms or cools.
  • Find steady states by hand (a straight line for fixed ends, the conserved mean for insulated ends) and state the maximum principle with its mechanism.
  • Show that a wavelike mode $\sin(k\pi x/L)$ decays at rate $\alpha(k\pi/L)^2$, so short wavelengths die first.
  • Write the explicit FTCS scheme, explain why $r = \alpha\Delta t/\Delta x^2 \le 1/2$ is exactly its maximum-principle and stability limit, and watch it fail above that.
  • Extend the equation to 2D and 3D and identify the viscous term of Navier-Stokes as a heat equation for momentum.
On this page
·
  1. Conservation plus a constitutive law
  2. uxxu_{xx}uxx​ as neighbor average minus centre
  3. Steady states
  4. The maximum principle
  5. Smoothing: short wavelengths die first
  6. Diffusion in 2D and 3D
  7. Viscosity is momentum diffusion
  8. Discretise it: FTCS and the one-half limit
  9. The lab
  10. Computing it
  11. Concept checks
  12. Problems
  13. Key Takeaways

Jos Stam’s fluid solver has a step you have not yet earned, diffuse, and Navier-Stokes hides the same operator in the term ν∇2u\nu\nabla^2\mathbf u. Both come from one equation, the first PDE in this module you can derive from a picture of a small slab of metal. The tools: the neighbor-average reading of the Laplacian from 2.11 The Laplacian & Vector Identities, the divergence theorem of 2.10 Green, Stokes & the Divergence Theorem, BVPs from 8.1 Two-Point Boundary Value Problems, and the stability of Euler steps from 4.5 Stability Regions & Stiffness. At the end sits the question that opens the next lesson: if every wiggle dies at its own rate, can we write the exact solution?

▶ Video A slab of rod, heat flowing in and out, Fourier's law turning the balance into u_t = alpha u_xx; then neighbor averaging, the straight-line steady state, and short wavelengths dying firstcaptions only
Transcript
  1. Stam's fluid solver has a step called diffuse, and Navier-Stokes hides the same operator in the viscous term. Both come from one equation, which we can derive from a small slab of metal. Watch a hot bump slump toward a straight line.
  2. Take a slab of a thin rod, of width delta x. Its energy is rho c A delta x times the temperature, and it changes only as power crosses the faces: A q of x in, A q of x plus delta x out. Shrink the slab: rho c u t equals minus q x.
  3. We also need a constitutive law, physics we measure. Fourier's law says heat flows from hot to cold in proportion to the slope: q equals minus k u x. Substitute, and u t equals alpha u x x, with alpha equal to k over rho c.
  4. Alpha is a length squared per time: heat spreads a distance L in about L squared over alpha. Copper has alpha 1.16 times ten to the minus 4, water 1.43 times ten to the minus 7. A 1 centimetre copper block evens out in 0.86 seconds, water in 698: a ratio of 809.
  5. Taylor expand the neighbours and add: the neighbour average minus the centre is one half delta x squared u x x. So every point is pulled toward the average of its neighbours, at rate 2 alpha over delta x squared. A bump's tip cools, a dip warms, and a straight ramp stays put.
  6. Steady means u x x is zero: a straight line. Start the hot bump with the ends held at 0 and 1. The lab is within one thousandth of the line at step 3591, time 0.5746, and theory agrees: 0.2906 times e to the minus pi squared t reaches one thousandth at 0.5747.
  7. With insulated ends any constant is steady, so conservation chooses: the total energy cannot change, so the constant is the initial mean. A hot left half flattens to 0.5, within one thousandth at step 4087, time 0.654, and the mean stays 0.50000.
  8. The maximum principle: at an interior maximum u x x is at most zero, so the hot spot can only cool. From random noise at r equal 0.4, the maximum falls from 0.995 to 0.509 in 100 steps and the minimum stays 0.
  9. Try a ripple, e to the minus lambda t times sine of k pi x over L. It solves the equation when lambda is alpha times k pi over L, squared. The rate grows as the square of the wavenumber, so the k equals 8 ripple dies 64 times faster than the single hump.
  10. After 100 steps, time 0.016, the lab reads 0.854, 0.531, 0.0784 and 2.98 times ten to the minus 5 for k 1, 2, 4 and 8, against continuum values of 0.854, 0.532, 0.0799 and 4.08 times ten to the minus 5. Fine detail goes first, and running backwards would amplify noise without limit.
  11. On a grid, use forward Euler in time and a centred difference in space. With r equal to alpha delta t over delta x squared, the new value is 1 minus 2 r times the old one plus 2 r times the neighbour average. If r is at most one half, both weights are non-negative, so no step leaves the old range.
  12. Above one half the old value's weight is negative and the step overshoots. The sawtooth is multiplied each step by 1 minus 4 r: minus 0.6 at r equal 0.4, minus 1 at 0.5, and minus 1.2 at 0.55, growing 20 percent a step. The lab's noise reaches 3.33 times ten to the 6.
  13. In 2D and 3D, u t equals alpha times the Laplacian, with 4 neighbours, then 6. The old weight is 1 minus 4 r, so r is at most one quarter, and in 3D one sixth. In d dimensions delta t is at most delta x squared over 2 alpha d: halve the cell and you need 4 times the steps.
  14. In Navier-Stokes, one velocity component obeys u t equals nu times the Laplacian: viscosity is momentum diffusion. Between two plates the velocity relaxes to a straight line, Couette flow. For air nu is 1.47 times ten to the minus 5, the Prandtl number is about 0.68, and a viscous layer spreads 3.8 millimetres in a second. That is why Stam solves diffuse implicitly.
  15. To recap. Energy balance plus Fourier's law gives u t equals alpha u x x. Curvature drives change, the steady states are a line or the mean, ripples decay at alpha k pi over L squared, and FTCS is stable exactly when r is at most one half.
  16. Next, 9.3 solves the rod exactly: separate variables, expand in sines, and let each mode decay at its own rate. If every wiggle dies at its own rate, can we write the exact solution?

Conservation plus a constitutive law

Almost every PDE in this course is built from two ingredients. The first is a conservation law: the amount of some stuff in a region can change only because stuff crosses the boundary (or is made inside). The second is a constitutive law that says how fast stuff crosses, which is physics you measure and not mathematics you derive. Here the stuff is thermal energy.

Take a thin rod with cross-section AA, density ρ\rho, specific heat cc (joules to warm a kilogram by a kelvin) and temperature u(x,t)u(x,t). A slab between xx and x+Δxx + \Delta x holds thermal energy

E=ρ c A Δx  u(joules, if the temperature is measured from a reference).E = \rho\, c\, A\,\Delta x\; u \qquad\text{(joules, if the temperature is measured from a reference)}.

Let q(x,t)q(x,t) be the heat flux, the power crossing a unit area, in W/m2^2, positive toward +x+x. Power enters through the left face and leaves through the right, so

ρcA Δx  ut=A q(x)−A q(x+Δx).\rho c A\,\Delta x\;u_t = A\,q(x) - A\,q(x + \Delta x).

Divide by A ΔxA\,\Delta x and let the slab shrink: q(x)−q(x+Δx)q(x) - q(x + \Delta x) over Δx\Delta x becomes −qx-q_x, which gives ρc ut=−qx\rho c\,u_t = -q_x. This is the one-dimensional case of the general law ut+∇⋅F=Su_t + \nabla\cdot\mathbf F = S: the rate of change of density plus the divergence of its flux equals the sources. (2.7 Divergence: Sources & Sinks showed why a divergence is net outflow per volume.) A heater adds a source term on the right.

Now the constitutive law. Fourier’s law (an experimental fact, from memory not derived) says heat flows from hot to cold, in proportion to the steepness of the temperature profile:

q=−k ux,q = -k\,u_x ,

with kk the thermal conductivity in W/(m K). The minus sign is the second law of thermodynamics in one character: with ux>0u_x \gt 0 the right side is hotter, so heat must flow left, q<0q \lt 0. Substituting,

ρc ut=(k ux)x=k uxx⟹ut=α uxx,α=kρc.\rho c\,u_t = (k\,u_x)_x = k\,u_{xx} \quad\Longrightarrow\quad \boxed{u_t = \alpha\,u_{xx}}, \qquad \alpha = \frac{k}{\rho c}.

The diffusivity α\alpha has units m2^2/s, and that is the whole story of its meaning: heat spreads a distance LL in a time of order L2/αL^2/\alpha. Rough values from memory: copper k=400k = 400, ρ=8960\rho = 8960, c=385c = 385 gives α=1.16×10−4\alpha = 1.16\times10^{-4} m2^2/s; water k=0.6k = 0.6, ρ=1000\rho = 1000, c=4186c = 4186 gives 1.43×10−71.43\times10^{-7}; air k=0.026k = 0.026, ρ=1.2\rho = 1.2, c=1005c = 1005 gives 2.16×10−52.16\times10^{-5}. A 11 cm copper block evens out in about L2/α=0.86L^2/\alpha = 0.86 s; a 11 cm layer of still water needs 698698 s, almost twelve minutes. The ratio of the two diffusivities is 809809.

The equation is linear, second order in space (a condition at each end) and first order in time (one initial profile).

uxxu_{xx} as neighbor average minus centre

What does uxxu_{xx} do to a point? Taylor-expand the neighbors, as in 2.4 Taylor Series in One and Several Variables:

u(x±Δx)=u±Δx ux+12Δx2uxx±…u(x\pm\Delta x) = u \pm \Delta x\,u_x + \tfrac12\Delta x^2 u_{xx} \pm \dots

Add the two and divide by two:

u(x+Δx)+u(x−Δx)2−u(x)=12 Δx2 uxx+O(Δx4).\frac{u(x+\Delta x) + u(x-\Delta x)}{2} - u(x) = \tfrac12\,\Delta x^2\,u_{xx} + O(\Delta x^4).

So the heat equation says, up to higher-order terms,

ut≈2αΔx2 (average of the neighbors−u).u_t \approx \frac{2\alpha}{\Delta x^2}\,\big(\text{average of the neighbors} - u\big).

Every point is pulled toward the average of its two neighbors, at a rate 2α/Δx22\alpha/\Delta x^2 that grows with finer detail. At the tip of a hot bump the neighbors are cooler than the centre, the bracket is negative, and the tip cools. In a cold dip the neighbors are warmer and the dip warms. On a straight ramp each point is the exact average of its neighbors, the bracket vanishes, and nothing changes there: the profile is a steady state even though heat is flowing through it. Curvature drives the change in temperature; slope drives the flow.

Steady states

If nothing changes, ut=0u_t = 0, and the heat equation reduces to the ODE uxx=0u_{xx} = 0, whose solutions are u=A+Bxu = A + Bx. The boundary conditions pick AA and BB.

  • Both ends fixed, u(0)=TLu(0) = T_L and u(L)=TRu(L) = T_R: us(x)=TL+(TR−TL) x/Lu_s(x) = T_L + (T_R - T_L)\,x/L. This is the BVP of 8.1 Two-Point Boundary Value Problems with the right-hand side set to zero. The flux q=−k(TR−TL)/Lq = -k(T_R - T_L)/L is constant: whatever enters at one end leaves at the other.
  • Both ends insulated, ux=0u_x = 0 (no flux): any constant solves the ODE, so the ODE does not choose one. Conservation does. Integrate the PDE over the rod: ddt∫0Lu dx=α [ux]0L=0\frac{d}{dt}\int_0^L u\,dx = \alpha\,[u_x]_0^L = 0. The total energy cannot change, so the constant must equal the initial mean temperature.
  • One end fixed, one insulated: the flux must vanish at the insulated end, so the profile is the constant TLT_L.

The maximum principle

Maximum principle. Let uu solve the heat equation for 0≤x≤L0 \le x \le L and 0≤t≤T0 \le t \le T. Then the largest value of uu over that rectangle is attained at t=0t = 0 or at an end x=0x = 0, x=Lx = L (and the same for the smallest value). With insulated ends the statement is the same with ends dropped: the range of uu never leaves the range of the initial data.

The mechanism: at an interior maximum uxx≤0u_{xx} \le 0, so ut=αuxx≤0u_t = \alpha u_{xx} \le 0 and the hot spot can only cool. (The gap, that uxxu_{xx} may equal zero there, is closed in a full proof by adding a small ϵt\epsilon t to make the inequality strict.) Heat left alone does not concentrate itself. For simulation this is a design rule: a step that produces a temperature outside the initial range, or a negative smoke density, has an error of the wrong kind.

Smoothing: short wavelengths die first

Try a ripple, u=e−λtsin⁡(kπx/L)u = e^{-\lambda t}\sin(k\pi x/L). Then ut=−λuu_t = -\lambda u and uxx=−(kπ/L)2uu_{xx} = -(k\pi/L)^2 u, so the equation holds exactly when

λk=α(kπL)2.\lambda_k = \alpha\left(\frac{k\pi}{L}\right)^2 .

The decay rate grows as the square of the wavenumber. The ripple with k=8k = 8 has eight half-waves in the rod and decays 6464 times faster than the single hump with k=1k = 1. Mechanism: a ripple of wavelength ℓ\ell has curvature of order 1/ℓ21/\ell^2 times its amplitude, so its crests are far above the average of their neighbors and its troughs far below, and the pull toward the average is correspondingly stronger. Fine detail has the steepest curvature and is erased first; broad features linger.

Hence the smoothing behavior of diffusion. Any initial profile is made of ripples, and after a time tt everything with λkt≫1\lambda_k t \gg 1 is gone. It also gives diffusion its arrow of time: running the equation backwards would multiply each ripple by e+λkte^{+\lambda_k t}, amplifying noise at the shortest scales without limit, so the backward problem is ill-posed.

The rod’s slowest mode sets the relaxation time. With both ends fixed, the straight-line steady state is approached like e−π2αt/L2e^{-\pi^2\alpha t/L^2}, so the ee-folding time is L2/(π2α)L^2/(\pi^2\alpha), a tenth of the crude L2/αL^2/\alpha.

Diffusion in 2D and 3D

Nothing in the slab argument needs the slab to be one-dimensional. For a small region VV with boundary SS, the energy balance is ddt∫Vρc u dV=−∮Sq⋅n dS\frac{d}{dt}\int_V\rho c\,u\,dV = -\oint_S\mathbf q\cdot\mathbf n\,dS, with Fourier’s law now q=−k∇u\mathbf q = -k\nabla u. The divergence theorem turns the surface integral into a volume integral, and because VV was arbitrary the integrands must match:

ut=α ∇⋅∇u=α Δu=α (uxx+uyy+uzz).u_t = \alpha\,\nabla\cdot\nabla u = \alpha\,\Delta u = \alpha\,(u_{xx} + u_{yy} + u_{zz}).

The neighbor-average reading carries over: on a grid Δu\Delta u is 4/h24/h^2 times (average of four neighbors minus centre) in 2D, 6/h26/h^2 times that for six neighbors in 3D. Steady states satisfy Δu=0\Delta u = 0, and the maximum principle holds in any dimension for the same reason: at an interior maximum Δu≤0\Delta u \le 0.

Viscosity is momentum diffusion

Return to 11.4 Viscosity & the Navier–Stokes Equations. Strip away advection and pressure, and one velocity component obeys

ut=ν Δu,ν=μ/ρ.u_t = \nu\,\Delta u, \qquad \nu = \mu/\rho .

That is the heat equation with ν\nu in the role of α\alpha. A fast layer of air hands momentum to a slower one as a hot rod hands heat to a cold one, because molecules wander between layers carrying their velocity. The kinematic viscosity of air, 1.47×10−51.47\times10^{-5} m2^2/s (from that lesson), is near its thermal diffusivity above: the ratio ν/α≈0.68\nu/\alpha \approx 0.68 is the Prandtl number of air (the name and its role are from memory). Everything above transfers: a viscous layer spreads a distance about νt\sqrt{\nu t} (3.83.8 mm after one second, a scale and not an exact value), the velocity between two plates relaxes to a straight line (Couette flow), and viscosity kills the smallest eddies first, the dissipation end of 11.9 Turbulence: An Introduction and the reason layers thicken in 11.8 Boundary Layers.

Discretise it: FTCS and the one-half limit

Put the equation on a grid xi=i Δxx_i = i\,\Delta x, with uinu_i^n the temperature at step nn, time step Δt\Delta t. Replace utu_t by the forward difference (Euler) and uxxu_{xx} by the centred second difference, the stencil you derived from Taylor series. This is FTCS (forward time, centred space), and with r=αΔt/Δx2r = \alpha\Delta t/\Delta x^2:

uin+1=uin+r (ui+1n−2uin+ui−1n)=(1−2r) uin+2r⋅ui+1n+ui−1n2.u_i^{n+1} = u_i^n + r\,(u_{i+1}^n - 2u_i^n + u_{i-1}^n) = (1 - 2r)\,u_i^n + 2r\cdot\frac{u_{i+1}^n + u_{i-1}^n}{2}.

The right-hand form is the neighbor-average picture made literal: a weighted average of the old value and the neighbors’ average, with weights 1−2r1 - 2r and 2r2r. Two consequences, one statement.

Discrete maximum principle. If r≤12r \le \tfrac12, both weights are non-negative and add to one, so the new value is a convex combination of old values and cannot leave their range. Each step respects the maximum principle, hence so does the run. At r=12r = \tfrac12 the scheme replaces each value by the exact neighbor average.

Instability above one-half. If r>12r \gt \tfrac12, the weight 1−2r1 - 2r is negative: a point that is above its neighbors is pushed below them, overshooting. The worst case is the sawtooth ui=(−1)iu_i = (-1)^i, which each step multiplies by 1−4r1 - 4r. At r=0.4r = 0.4 the factor is −0.6-0.6: it flips sign and shrinks. At r=0.5r = 0.5 it is exactly −1-1, flipping forever. At r=0.55r = 0.55 it is −1.2-1.2: every step grows it by 20%20\%. The ODE view of 4.5 Stability Regions & Stiffness gives the same limit. The grid’s ripples are eigenvectors of the method-of-lines system, with eigenvalues λ\lambda from 00 down to about −4α/Δx2-4\alpha/\Delta x^2; forward Euler needs Δt λ≥−2\Delta t\,\lambda \ge -2, which is 4r≤24r \le 2, so r≤12r \le \tfrac12.

In 2D the same argument has weight 1−4r1 - 4r on the old value and 4r4r on the average of four neighbors, so r≤14r \le \tfrac14; in 3D, r≤16r \le \tfrac16. In dd dimensions Δt≤Δx2/(2αd)\Delta t \le \Delta x^2/(2\alpha d): halve the cell size and you need four times as many steps, on four times as many cells in 2D.

The lab

◆ Interactive A 1D rod: paint the initial temperature, choose the ends, and watch explicit diffusion (and what happens above r = 1/2)

Loading simulation…

The rod has L=1L = 1, α=1\alpha = 1 (time in units of L2/αL^2/\alpha), 5050 intervals, and Δt=r Δx2\Delta t = r\,\Delta x^2. What to try, and what the sim prints:

  1. Steady state, ends fixed at 00 and 11. Start from the hot bump. The curve slumps toward the straight line, and the readout max⁡∣u−us∣\max|u - u_s| falls below 10−310^{-3} at step 35913591, t=0.5746t = 0.5746. Theory predicts it: the slowest mode of u−usu - u_s starts at amplitude 0.29060.2906 (projected from the initial profile), and 0.2906 e−π2t=10−30.2906\,e^{-\pi^2 t} = 10^{-3} gives t=0.5747t = 0.5747.
  2. Insulated ends. Choose the step preset (left half at 11, right half at 00) and insulate both ends. The mean readout stays 0.500000.50000 and the profile flattens to within 10−310^{-3} of 0.50.5 at step 40874087, t=0.654t = 0.654; the slowest mode is a cosine of initial amplitude 2/π2/\pi, and ln⁡(2000/π)/π2=0.654\ln(2000/\pi)/\pi^2 = 0.654.
  3. Smoothing. Fixed ends at 00, r=0.4r = 0.4, start from one smooth bump or eight ripples. After 100100 steps (t=0.016t = 0.016) the mode readouts give 0.8540.854 for k=1k = 1 (continuum e−(kπ)2te^{-(k\pi)^2t}: 0.8540.854), 0.5310.531 for k=2k = 2 (0.5320.532), 0.07840.0784 for k=4k = 4 (0.07990.0799) and 2.98×10−52.98\times10^{-5} for k=8k = 8 (4.08×10−54.08\times10^{-5}). The ripple, 12.512.5 grid points per wavelength, is the one the scheme gets least right.
  4. Maximum principle and the limit. Pick random noise (fixed ends at 00). At r=0.4r = 0.4 the running max falls from 0.9950.995 to 0.5090.509 in 100100 steps and the min stays 00, inside the starting range as promised. At r=0.5r = 0.5 the range is [0,0.537][0, 0.537]: inside, but the sawtooth part never decays (factor −1-1). At r=0.55r = 0.55 it is [−3.33×106,3.32×106][-3.33\times10^{6}, 3.32\times10^{6}], flagged as outside, with the factor 1−4r=−1.201 - 4r = -1.20 shown.

Fixed ends are held by the scheme; the insulated ends use a ghost node with u−1=u1u_{-1} = u_1, which enforces zero slope: u0n+1=u0n+2r(u1n−u0n)u_0^{n+1} = u_0^n + 2r(u_1^n - u_0^n).

Computing it

🐍 PythonLab: grid decay against the continuum exponential, and the 1/2 limit on noise
⌘/Ctrl + Enter

The first loop reproduces item 3 of the lab and the second item 4.

🧪 Coding exerciseExercise: discretise the rod, find the steady line, test the maximum principle
⌘/Ctrl + Enter

Concept checks

✅ Concept check

At one instant a point in a rod is $50$ and its two neighbors (one grid spacing away) are $54$ and $58$. Which statement is right?

✅ Concept check

Both ends fixed at $0$. How many times faster does the ripple $\sin(8\pi x/L)$ decay than the single hump $\sin(\pi x/L)$?

✅ Concept check

A copper bar ($\alpha = 1.16\times10^{-4}$ m$^2$/s, from memory) is modelled with $\Delta x = 1$ mm. What is the largest explicit time step, in milliseconds, with $r \le 1/2$?

✅ Concept check

An FTCS run starts with all temperatures between $0$ and $1$ and then shows $-0.2$ somewhere. What does that tell you?

Problems

✏️ Pen & paperA steady rod●○○

A copper rod (k=400k = 400 W/(m K), from memory) of length L=0.5L = 0.5 m has its ends held at 20∘20^\circC (x=0x = 0) and 100∘100^\circC (x=Lx = L). Find the steady profile, the temperature at x=0.25x = 0.25 m, and the heat flux.

Show worked solution

Steady means uxx=0u_{xx} = 0, so u=20+80x/0.5=20+160xu = 20 + 80x/0.5 = 20 + 160x. At x=0.25x = 0.25: u=60∘u = 60^\circC, the midpoint average. The flux is q=−kux=−400⋅160=−64 000q = -k u_x = -400\cdot160 = -64\,000 W/m2^2: negative, so heat flows toward x=0x = 0, from hot to cold, at 6464 kW per square metre of cross-section. The same flux crosses every cross-section, since qx=0q_x = 0.

✏️ Pen & paperOne step by hand, and the overshoot●●○

A rod has the nodal values [0,0,1,0,0][0, 0, 1, 0, 0] with both ends held at 00. Take one FTCS step for (a) r=0.25r = 0.25, (b) r=0.5r = 0.5, (c) r=0.6r = 0.6. Explain (c) with the weights 1−2r1 - 2r and 2r2r.

Show worked solution

Interior nodes 1,2,31, 2, 3 have values 0,1,00, 1, 0 and neighbors (0,1)(0, 1), (0,0)(0, 0), (1,0)(1, 0).

(a) r=0.25r = 0.25: node 11: 0+0.25(1−0+0)=0.250 + 0.25(1 - 0 + 0) = 0.25; node 22: 1+0.25(0−2+0)=0.51 + 0.25(0 - 2 + 0) = 0.5; node 33: 0.250.25. Result [0,0.25,0.5,0.25,0][0, 0.25, 0.5, 0.25, 0].

(b) r=0.5r = 0.5: [0,0.5,0,0.5,0][0, 0.5, 0, 0.5, 0]. The centre is (1−1)⋅1+1⋅0=0(1 - 1)\cdot1 + 1\cdot0 = 0: replaced by the neighbor average.

(c) r=0.6r = 0.6: [0,0.6,−0.2,0.6,0][0, 0.6, -0.2, 0.6, 0]. The centre is (1−1.2)⋅1+1.2⋅0=−0.2(1 - 1.2)\cdot1 + 1.2\cdot0 = -0.2. The weight on the old value is 1−2r=−0.2<01 - 2r = -0.2 \lt 0, so the former hot spot is pushed below its neighbors, and below the initial minimum 00: a violation of the maximum principle after one step. Repeating this flips the sign every step and the magnitude grows by 1−4r=−1.41 - 4r = -1.4 for the worst mode.

✏️ Pen & paperConservation and the 2D limit●●○

(a) Show that for insulated ends ∫0Lu dx\int_0^L u\,dx is constant. (b) Derive the largest stable rr for FTCS in 2D on a square grid and the largest Δt\Delta t for air momentum, ν=1.47×10−5\nu = 1.47\times10^{-5} m2^2/s, on a 11 mm grid.

Show worked solution

(a) ddt∫0Lu dx=∫0Lαuxx dx=α [ux(L)−ux(0)]=0\frac{d}{dt}\int_0^L u\,dx = \int_0^L\alpha u_{xx}\,dx = \alpha\,[u_x(L) - u_x(0)] = 0 for insulated ends, so the integral equals its initial value.

(b) In 2D, ui,jn+1=(1−4r)ui,jn+4r⋅(average of four neighbors)u_{i,j}^{n+1} = (1 - 4r)u_{i,j}^n + 4r\cdot(\text{average of four neighbors}), with r=αΔt/h2r = \alpha\Delta t/h^2. The weights are non-negative and sum to one iff r≤1/4r \le 1/4. Then Δt≤h2/(4ν)=10−6/(5.88×10−5)=0.0170\Delta t \le h^2/(4\nu) = 10^{-6}/(5.88\times10^{-5}) = 0.0170 s. This matches the νΔt/h2≤1/4\nu\Delta t/h^2 \le 1/4 limit quoted in the Stable Fluids lesson.

Key Takeaways

  • Energy conservation on a slab gives ρc ut=−qx\rho c\,u_t = -q_x; Fourier’s law q=−kuxq = -k u_x closes it into ut=αuxxu_t = \alpha u_{xx} with α=k/(ρc)\alpha = k/(\rho c), a length squared per time.
  • uxxu_{xx} is 2/Δx22/\Delta x^2 times (neighbor average minus centre): temperature changes where the profile is curved, and a straight ramp is steady even though heat flows through it.
  • Steady states solve uxx=0u_{xx} = 0: a straight line for fixed ends, the conserved mean for insulated ends.
  • The maximum principle (a hot spot cannot grow, no new extremes) comes from uxx≤0u_{xx} \le 0 at a maximum.
  • A ripple sin⁡(kπx/L)\sin(k\pi x/L) decays at rate α(kπ/L)2\alpha(k\pi/L)^2: 6464 times faster for k=8k = 8 than k=1k = 1. Fine detail is smoothed first, and the backward problem is ill-posed.
  • FTCS is uin+1=(1−2r)ui+2r⋅(neighbor average)u_i^{n+1} = (1 - 2r)u_i + 2r\cdot\text{(neighbor average)}; it keeps the maximum principle and is stable exactly when r≤1/2r \le 1/2 (1/4 in 2D, 1/6 in 3D). At r=0.55r = 0.55 the lab’s noise reaches 3×1063\times10^6 in 100100 steps.
  • In multiple dimensions ut=αΔuu_t = \alpha\Delta u; the viscous term νΔu\nu\Delta\mathbf u in Navier-Stokes is the same equation for momentum, which is why Stam solves diffusion implicitly.
  • Next, 9.3 solves the rod exactly: separate u=X(x)T(t)u = X(x)T(t), expand the initial profile in sines, and let each mode decay at its own rate α(kπ/L)2\alpha(k\pi/L)^2.
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: