Flow Lab

Syllabus / Module 10: Numerical Methods for PDEs

Lesson 10.2

Explicit Methods for the Heat Equation

FTCS (forward-time centered-space), method of lines, the stability limit Δt ≤ Δx²/(2α), and watching instability explode.

Written byClaude Sonnet

🌊
Why this matters for simulation: Why Stam calls naive explicit diffusion 'unstable' — and why he switches to an implicit solve.

By the end of this lesson you can…

  • Write FTCS as the method of lines plus forward Euler, on the ODE system $\dot{\mathbf u} = A\mathbf u$.
  • Derive the stability limit $\Delta t \le \Delta x^2/(2\alpha)$ by placing the eigenvalues $-\tfrac{4\alpha}{h^2}\sin^2\tfrac{k\pi h}{2}$ of the semi-discrete matrix inside the forward-Euler stability region.
  • Compute the amplification factor $1 - 4r\sin^2\tfrac{k\pi h}{2}$ of every grid mode, and predict from it which mode blows up, how fast, and from what starting size.
  • Extend the analysis to 2D, where eigenvalues add and the limit tightens to $r \le 1/4$, and say why 3D gives $1/6$.
  • Separate stability from accuracy: read the leading truncation error $\tfrac{h^2}{12}(6r - 1)u_{xxxx}$, and see which modes a stable run still gets wrong.
  • Count the cost of refinement: halving $h$ multiplies the steps by $4$ and the total work by $8$ in 1D and $16$ in 2D.
On this page
·
  1. Method of lines: discretise space first
  2. Where the limit comes from: eigenvalues in the stability region
  3. The amplification factor of every mode
  4. 2D: eigenvalues add
  5. Stable is not the same as accurate
  6. What refinement costs
  7. The lab
  8. Computing it
  9. Concept checks
  10. Problems
  11. Key Takeaways

In 9.2 The Heat (Diffusion) Equation we ran FTCS on a rod and saw it explode when r=αΔt/Δx2r = \alpha\Delta t/\Delta x^2 passed one half, with a short argument about a sawtooth. In 10.1 Finite Differences: Discretizing Derivatives we turned the second-derivative stencil into a matrix and found its eigenvalues. This lesson joins the two. The limit is forward Euler from 4.5 Stability Regions & Stiffness applied to a system whose eigenvalues we know exactly. That view gives the limit in 2D and 3D, shows which mode fails and how fast, explains why a stable run can still be wrong, and sets the price of resolution: the reason Stam’s solver abandons explicit diffusion.

▶ Video Space discretised into a matrix, its eigenvalues against the Euler stability interval, the sawtooth mode growing above the limit, the 2D limit of one quarter, and the cost of refining the gridcaptions only
Transcript
  1. In the heat lesson, explicit stepping exploded above r equals one half. Here is why. Replace only u x x by the three-point stencil: one ODE per node, u dot equals A u, the method of lines. Add forward Euler and, row by row, you get FTCS.
  2. Forward Euler multiplies a mode by 1 plus lambda delta t, so it is stable when that has absolute value at most 1: a disk of radius 1 centred at minus 1, or the interval from minus 2 to 0 for real eigenvalues. The system decouples along eigenvectors, so every lambda k delta t must lie in the region.
  3. Take n equals 7. The eigenvalues run from minus 9.743 to minus 246.26, so Euler needs delta t at most 2 over 246.26, which is 0.008122: r at most 0.5198. The smooth mode alone would allow 0.205. On 49 nodes the spectrum spans a ratio of 1013: stiffness.
  4. Every grid mode is multiplied each step by G k equals 1 minus 4 r sine squared of k pi h over 2. The smooth mode, k equals 1, has G near 1: a slow decay, as it should. The sawtooth alternates sign from node to node and has G near 1 minus 4 r. Stable means absolute G at most 1 for every k.
  5. For 49 nodes the top mode's factor is minus 0.5984 at r equals 0.4, minus 0.9980 at 0.5, minus 1.0380 at 0.51 and minus 1.1978 at 0.55. At one quarter it crosses zero and flips sign each step, still decaying. Just past one half it crosses minus 1 and grows.
  6. Run 1D at r equals 0.51. A seed of 10 to the minus 8 rides along with the bump. The maximum bottoms out near 0.1495 at step 500, then climbs: 40.07 at step 700, 2.87 times 10 to the 6 at step 1000, blown up at step 1096. Fine for hundreds of steps, then it fails in tens.
  7. In 2D the eigenvalues add. The most negative is about minus 8 alpha over h squared, twice the 1D value. The checkerboard has G near 1 minus 8 r, so r at most one quarter, exactly 0.2510 for M equals 24. Each dimension adds 4 alpha over h squared: one sixth in 3D.
  8. At r equals 0.245 the plate decays smoothly. At 0.255 it decays until about step 500, then a checkerboard takes over: 6.5 times 10 to the 3 at step 1000, blown up at step 1307. Its factor is minus 1.0320, against minus 0.9523. A code tuned in 1D at 0.4 gives minus 2.19.
  9. Stable is not accurate. Euler in time contributes delta t over 2, the centred difference h squared over 12. The truncation error is h squared over 12 times 6 r minus 1 times u x x x x: first order in delta t, second in h. At r equals one sixth the leading term cancels. Below, high modes decay too slowly; above, too quickly.
  10. Test the mode k equals 8 after 100 steps. At r equals 0.05 the grid gives 0.2880 against exact 0.2827: 1.9 percent too large. At 0.17, 0.013615 against 0.013633. At 0.4, 2.98 times 10 to the minus 5 against 4.08 times 10 to the minus 5: 27 percent too small. At 0.5, 43 percent too small. All stable.
  11. The top mode is worst. At r equals 0.5 the PDE kills mode 49 by 0.0087 per step, but the grid gives minus 0.9980: the sawtooth survives. After 100 steps the grid amplitude is 0.821; the true one is below 10 to the minus 200. Bounded does not mean clean. Below one quarter, nothing oscillates.
  12. Halving h makes the top eigenvalue four times larger, so delta t drops by four: four times as many steps. At r equals 0.4 and t equals 0.1, N equals 25, 50 and 100 need 157, 625 and 2500. In 1D, twice the nodes: eight times the work. In 2D, sixteen times.
  13. A better integrator barely helps: RK4 reaches minus 2.7853 on the real axis against minus 2, a step only 1.39 times larger. For air, with viscosity 1.47 times 10 to the minus 5, at 1 millimetre, the 2D limit is 0.0170 seconds, about one frame at 60 per second, and four times less per halving. So Stam's diffusion is implicit.
  14. Next, von Neumann analysis: feed one Fourier mode through the scheme and read off the growth factor G of k directly, with no matrix, even for centred advection, which is unstable for every delta t. After that, implicit methods: a linear solve each step, stable at any delta t, which is how Stam's solver handles diffusion.

Method of lines: discretise space first

Keep time continuous for a moment. Put the rod on a grid with spacing hh and let ui(t)u_i(t) be the temperature at node ii, a function of time. Replacing only uxxu_{xx} by the three-point stencil turns the PDE ut=αuxxu_t = \alpha u_{xx} into one ODE per node:

u˙i=αh2 (ui+1−2ui+ui−1),that isu˙=Au,\dot u_i = \frac{\alpha}{h^2}\,(u_{i+1} - 2u_i + u_{i-1}), \qquad\text{that is}\qquad \dot{\mathbf u} = A\mathbf u,

where A=αh2 tridiag(1,−2,1)A = \frac{\alpha}{h^2}\,\mathrm{tridiag}(1, -2, 1) is the matrix of the last lesson (zero Dirichlet ends). This is the method of lines: the PDE becomes a linear ODE system of the kind in 7.1 Systems & State Space, called semi-discrete because only space is discrete. Everything we know about such systems applies. In 7.2 Linear Systems & the Eigenvalue Method the solution is a sum of eigenvector components, each decaying like eλte^{\lambda t}, and here the eigenvectors are the sampled sines sin⁡(kπxi)\sin(k\pi x_i).

Now choose an ODE solver. Forward Euler gives un+1=un+Δt Aun\mathbf u^{n+1} = \mathbf u^n + \Delta t\,A\mathbf u^n. Written out row by row, that is

uin+1=uin+r (ui+1n−2uin+ui−1n),r=αΔth2,u_i^{n+1} = u_i^n + r\,(u_{i+1}^n - 2u_i^n + u_{i-1}^n), \qquad r = \frac{\alpha\Delta t}{h^2},

which is FTCS, the scheme of the heat lesson. So FTCS is the method of lines with forward Euler. Swapping in RK4 or backward Euler gives other schemes at no extra effort: that is the point of separating space from time.

Where the limit comes from: eigenvalues in the stability region

For a test equation y˙=λy\dot y = \lambda y, one forward Euler step multiplies yy by 1+λΔt1 + \lambda\Delta t. The method is stable when ∣1+λΔt∣≤1\lvert 1 + \lambda\Delta t\rvert \le 1: the disk of radius one centred at −1-1 in the λΔt\lambda\Delta t plane (the stability region of the Euler lesson). For a real negative λ\lambda this is the interval −2≤λΔt≤0-2 \le \lambda\Delta t \le 0.

A linear system decouples along eigenvectors. Expand un\mathbf u^n in the eigenvectors of AA; each component is multiplied per step by 1+λkΔt1 + \lambda_k\Delta t with its own eigenvalue. The scheme is stable exactly when every λkΔt\lambda_k\Delta t lies in the stability region, which is one inequality per eigenvalue. The last lesson gave them all:

λk=−4αh2sin⁡2kπh2,k=1,…,n,h=1n+1.\lambda_k = -\frac{4\alpha}{h^2}\sin^2\frac{k\pi h}{2}, \qquad k = 1, \dots, n,\quad h = \frac{1}{n+1}.

They are real and negative, so only the real interval [−2,0][-2, 0] matters, and the binding one is the most negative eigenvalue, the highest mode k=nk = n, where the sine is close to 11. The condition is

Δt 4αh2sin⁡2nπh2≤2⟺r≤12sin⁡2(nπh/2)≈12.\Delta t\,\frac{4\alpha}{h^2}\sin^2\frac{n\pi h}{2} \le 2 \quad\Longleftrightarrow\quad r \le \frac{1}{2\sin^2(n\pi h/2)} \approx \frac12 .

That is the limit Δt≤Δx2/(2α)\Delta t \le \Delta x^2/(2\alpha) of the heat lesson, now derived, and with its fine print: on a finite grid the exact threshold is a little above one half, 0.50050.5005 for 4949 interior nodes (1/(2sin⁡2(0.49π))1/(2\sin^2(0.49\pi))).

Worked example. Take n=7n = 7, h=18h = \tfrac18, α=1\alpha = 1. The eigenvalues from the last lesson run from λ1=−9.743\lambda_1 = -9.743 to λ7=−246.26\lambda_7 = -246.26. Forward Euler needs Δt≤2/246.26=0.008122\Delta t \le 2/246.26 = 0.008122, which is r≤0.5198=1/(2sin⁡2(7π/16))r \le 0.5198 = 1/(2\sin^2(7\pi/16)). The smooth mode alone would allow 0.2050.205, twenty-five times larger: the step is dictated by a mode that carries almost no energy in a smooth solution. On the 4949-node rod the eigenvalues span 9.879.87 to 99909990, a ratio of 10131013: the stiffness of 4.5 Stability Regions & Stiffness, which worsens as 1/h21/h^2.

The amplification factor of every mode

Put the pieces together. A grid mode sin⁡(kπxi)\sin(k\pi x_i) is multiplied by one number per step:

Gk=1+λkΔt=1−4rsin⁡2kπh2.G_k = 1 + \lambda_k\Delta t = 1 - 4r\sin^2\frac{k\pi h}{2}.

The exact PDE multiplies the same mode by e−(kπ)2Δte^{-(k\pi)^2\Delta t}, an exponential decay, so GkG_k should approximate it. Stability is ∣Gk∣≤1\lvert G_k\rvert \le 1 for all kk. Look at the two ends of the spectrum.

  • Smooth mode, k=1k = 1. sin⁡2≈(πh/2)2\sin^2 \approx (\pi h/2)^2 is tiny, so G1=1−rπ2h2≈1G_1 = 1 - r\pi^2h^2 \approx 1 and the mode decays slowly, as it should.
  • Sawtooth, k=nk = n. On the grid this mode is ui=±sin⁡(πxi)u_i = \pm\sin(\pi x_i) with alternating sign: neighbours point in opposite directions. Since sin⁡2≈1\sin^2 \approx 1, Gn≈1−4rG_n \approx 1 - 4r.

For 4949 interior nodes the exact values are G49=−0.5984G_{49} = -0.5984 at r=0.4r = 0.4, −0.9980-0.9980 at r=0.5r = 0.5, −1.0380-1.0380 at r=0.51r = 0.51 and −1.1978-1.1978 at r=0.55r = 0.55. Two things happen as rr grows. At r=1/4r = 1/4 the factor GnG_n crosses zero and turns negative: from then on the sawtooth flips sign each step, still decaying. At rr just over one half it crosses −1-1, and the sawtooth then grows by 1.0381.038 per step, then by 1.1981.198, in either sign. Nothing else changes: G1G_1 is about 0.9980.998 at all four. The instability is entirely in the top of the spectrum.

How long until it shows? A sawtooth seed is present in every real calculation. At r=0.51r = 0.51 a seed of 10−810^{-8} against a smooth solution of size 11 needs ln⁡(108)/ln⁡(1.038)≈490\ln(10^{8})/\ln(1.038) \approx 490 steps to become O(1)O(1): the run looks fine for hundreds of steps and then fails in tens. At r=0.55r = 0.55 the same trip takes ln⁡(108)/ln⁡(1.198)≈100\ln(10^{8})/\ln(1.198) \approx 100 steps. The lab runs exactly that (the bump preset carries a 10−810^{-8} seed).

2D: eigenvalues add

On a square grid with M×MM \times M interior nodes, the five-point Laplacian is A⊗I+I⊗AA\otimes I + I\otimes A (from the last lesson). Its eigenvectors are products sin⁡(kπxi)sin⁡(lπyj)\sin(k\pi x_i)\sin(l\pi y_j), and its eigenvalues are the sums

λkl=λk+λl=−4αh2(sin⁡2kπh2+sin⁡2lπh2),\lambda_{kl} = \lambda_k + \lambda_l = -\frac{4\alpha}{h^2}\Big(\sin^2\frac{k\pi h}{2} + \sin^2\frac{l\pi h}{2}\Big),

the discrete form of ∇2=∂x2+∂y2\nabla^2 = \partial_x^2 + \partial_y^2. The most negative is k=l=Mk = l = M, about −8α/h2-8\alpha/h^2, twice the 1D value. The checkerboard mode (M,M)(M, M) has G≈1−8rG \approx 1 - 8r, and stability needs 8r≤28r \le 2:

r≤14(exactly 0.2510 for M=24),Δt≤h24α.r \le \tfrac14 \quad(\text{exactly } 0.2510 \text{ for } M = 24), \qquad \Delta t \le \frac{h^2}{4\alpha}.

Each extra dimension adds another 4α/h24\alpha/h^2, so Δt≤h2/(2d α)\Delta t \le h^2/(2d\,\alpha) in dd dimensions: 1/61/6 in 3D. The averaging argument of the heat lesson gives the same bound; the eigenvalues also say which pattern fails: a checkerboard.

Worked example. At M=24M = 24, the factor of the checkerboard is 1−8rsin⁡2(24π/50)1 - 8r\sin^2(24\pi/50), so −0.9523-0.9523 at r=0.245r = 0.245 and −1.0320-1.0320 at r=0.255r = 0.255. A code tuned in 1D at r=0.4r = 0.4 is unstable the moment someone adds the second dimension: G=1−8(0.4)(0.998)=−2.19G = 1 - 8(0.4)(0.998) = -2.19.

Stable is not the same as accurate

Stability keeps the answer bounded. It does not make it right. For smooth solutions we ask about consistency: how much of the true solution is left when plugged into the scheme. Expand about a grid point, with ut=αuxxu_t = \alpha u_{xx} and so utt=α2uxxxxu_{tt} = \alpha^2u_{xxxx}. Euler’s time difference is ut+12Δt utt+⋯u_t + \tfrac12\Delta t\,u_{tt} + \cdots and the centred space difference is uxx+h212uxxxx+⋯u_{xx} + \tfrac{h^2}{12}u_{xxxx} + \cdots (take α=1\alpha = 1), so the truncation error is

uin+1−uinΔt−ui+1n−2uin+ui−1nh2=(Δt2−h212)uxxxx+⋯=h212(6r−1) uxxxx+⋯\frac{u^{n+1}_i - u^n_i}{\Delta t} - \frac{u_{i+1}^n - 2u_i^n + u_{i-1}^n}{h^2} = \Big(\frac{\Delta t}{2} - \frac{h^2}{12}\Big)u_{xxxx} + \cdots = \frac{h^2}{12}(6r - 1)\,u_{xxxx} + \cdots

First order in Δt\Delta t, second in hh: O(Δt,h2)O(\Delta t, h^2), and at fixed rr both are O(h2)O(h^2). At r=1/6r = 1/6 the leading term cancels. For a mode sin⁡(kπx)\sin(k\pi x), uxxxx=(kπ)4u_{xxxx} = (k\pi)^4 times the mode, so the scheme decays it at the rate (kπ)2−h212(1−6r)(kπ)4(k\pi)^2 - \tfrac{h^2}{12}(1 - 6r)(k\pi)^4: too slowly for r<1/6r \lt 1/6, too quickly above it, and worse the larger kk is.

The lab and a script confirm this. Run the pure mode k=8k = 8 for 100100 steps and compare with the exact decay e−(kπ)2te^{-(k\pi)^2t}. At r=0.05r = 0.05 (t=0.002t = 0.002) the grid amplitude is 0.28800.2880 against exact 0.28270.2827, which is 1.9%1.9\% too large; the prediction from the formula above is 1.9%1.9\%. At r=0.17r = 0.17 it is 0.0136150.013615 against 0.0136330.013633: 0.13%0.13\% off. At r=0.4r = 0.4 it is 2.98×10−52.98\times10^{-5} against 4.08×10−54.08\times10^{-5}, 27%27\% too small, and at r=0.5r = 0.5 it is 1.84×10−61.84\times10^{-6} against 3.26×10−63.26\times10^{-6}, 43%43\% too small. All stable. The bar chart in the lab draws both GkG_k and the exact factor.

The worst case is the top mode, where the discrepancy is not small at all. At r=0.5r = 0.5 the exact PDE kills k=49k = 49 by a factor e−(49π)2⋅0.5/2500=0.0087e^{-(49\pi)^2\cdot0.5/2500} = 0.0087 per step, while the grid gives −0.9980-0.9980: the sawtooth survives, flipping sign. After 100100 steps the grid amplitude is 0.8210.821; the true one is below 10−20010^{-200}. Those wiggles are what the physics says should vanish: do not call a run clean just because it stays bounded. Keeping rr below about 1/41/4 makes every GkG_k positive, so no mode oscillates.

What refinement costs

Halving hh makes the top eigenvalue four times larger, so Δt\Delta t must drop by four. To reach the same final time you need four times as many steps, each on twice as many nodes in 1D, so eight times the work; in 2D each step has four times the cells, so sixteen times. For r=0.4r = 0.4 and final time t=0.1t = 0.1, N=25,50,100N = 25, 50, 100 intervals need 157,625,2500157, 625, 2500 steps. Halving hh cuts the error by four while the work grows by eight: for fine grids the explicit method is the wrong tool, though for coarse grids and short times it is the simplest and often fastest code. The limit also follows the smallest cell: a mesh stretched near a wall runs at the step its tightest cell allows.

The lab

◆ Interactive 1D and 2D explicit diffusion: choose r, watch the amplification factor of every mode, and see the blow-up above the limit

Loading simulation…

The domain is the unit interval or square, α=1\alpha = 1, Δt=rh2\Delta t = rh^2, 4949 interior nodes in 1D and 24×2424 \times 24 in 2D, boundary held at 00. Bars show GkG_k (red when ∣G∣>1\lvert G\rvert \gt 1), dots the exact PDE factors, and the bottom strip max⁡∣u∣\max\lvert u\rvert on a log scale. The readout gives the worst mode, the measured growth of max⁡∣u∣\max\lvert u\rvert per step over the last ten steps, and the tracked mode’s amplitude.

  1. 1D bump, press “r just below the limit” (r=0.495r = 0.495). All bars are blue. max⁡∣u∣\max\lvert u\rvert is 0.3340.334 at step 100100 and 6.92×10−36.92\times10^{-3} at step 20002000, shrinking by 0.998050.99805 per step, the factor G1G_1 of the smooth mode. The sawtooth bar is −0.9780-0.9780: flipping, decaying.
  2. “r just above” (r=0.51r = 0.51). The last bar turns red at −1.0380-1.0380. The bump decays to 0.190.19 at step 300300, but the seed has grown: max⁡∣u∣\max\lvert u\rvert is 0.14950.1495 at step 500500 and rising, 40.0740.07 at step 700700, 2.87×1062.87\times10^6 at step 10001000, and the run is flagged blown up at step 10961096. The measured growth settles at 1.03801.0380, the bar’s magnitude. The log strip shows a decay, a minimum, then a straight line up.
  3. Highest mode, r=0.55r = 0.55. Each step multiplies the pattern by exactly −1.1978-1.1978: max⁡∣u∣=8313\max\lvert u\rvert = 8313 at step 5050.
  4. Random noise at r=0.4,0.5,0.55r = 0.4, 0.5, 0.55. After 100100 steps the maximum is 0.5130.513, 0.5390.539 and 3.12×1063.12\times10^6; the last grows 1.191.19 per step against ∣G49∣=1.198\lvert G_{49}\rvert = 1.198.
  5. 2D, bump. The limit is 0.25100.2510. At r=0.245r = 0.245 the plate decays smoothly (0.1110.111 at step 100100). At r=0.255r = 0.255 it decays until about step 500500 (4.96×10−34.96\times10^{-3}), then a checkerboard takes over: 6.5×1036.5\times10^3 at step 10001000, blown up at step 13071307, measured growth 1.03201.0320. At r=0.3r = 0.3 the blow-up takes only 124124 steps, and the checkerboard factor is −1.3905-1.3905.
  6. Single mode, k=8k = 8. After 100100 steps at r=0.4r = 0.4 the readout gives 2.98×10−52.98\times10^{-5} against exact 4.08×10−54.08\times10^{-5}; GnG^n equals the measured value, because a grid mode is an exact eigenvector. Try r=0.05r = 0.05 and 0.170.17 for the other numbers above.
  7. Mode k=49k = 49 at r=0.5r = 0.5. The dot (exact factor 0.00870.0087) sits far above the bar (−0.9980-0.9980): measured amplitude 0.8210.821 after 100100 steps, equal to G100G^{100}.

Computing it

🐍 PythonLab: amplification factors in 1D and 2D, and the cost of refining
⌘/Ctrl + Enter

The output reproduces the top-mode factors, the 2D values and the step counts quoted above.

🧪 Coding exerciseExercise: eigenvalues, the largest stable step, and a test by simulation
⌘/Ctrl + Enter

For n=19n = 19 the largest stable step is 0.00125770.0012577 (1.0061.006 times h2/2h^2/2); 98%98\% of it leaves max⁡∣u∣=5.0×10−6\max\lvert u\rvert = 5.0\times10^{-6} after 10001000 steps, and 102%102\% gives 1.4×10111.4\times10^{11}.

Concept checks

✅ Concept check

1D FTCS runs at $r = 0.6$. To two decimal places, what is the factor per step of the highest (sawtooth) mode? Use $G_n \approx 1 - 4r$.

✅ Concept check

A semi-discrete diffusion system has eigenvalues $-1$, $-100$ and $-10000$. What is the largest stable forward-Euler step?

✅ Concept check

Why does 2D explicit diffusion need $r \le 1/4$ where 1D needs $r \le 1/2$?

✅ Concept check

A 2D explicit heat solver runs at the stability limit. By what factor does the total work (steps times cells) grow when $h$ is halved?

Problems

✏️ Pen & paperEigenvalues and the step on three nodes●○○

Take n=3n = 3 interior nodes (h=14h = \tfrac14) and α=1\alpha = 1. Find the three eigenvalues of the semi-discrete matrix, the largest stable forward-Euler Δt\Delta t, and rr at that step.

Show worked solution

λk=−64sin⁡2(kπ/8)=−32(1−cos⁡(kπ/4))\lambda_k = -64\sin^2(k\pi/8) = -32(1 - \cos(k\pi/4)): λ1=−9.373\lambda_1 = -9.373, λ2=−32\lambda_2 = -32, λ3=−54.627\lambda_3 = -54.627. The limit is Δt≤2/54.627=0.03661\Delta t \le 2/54.627 = 0.03661. Then r=Δt/h2=0.03661×16=0.5858r = \Delta t/h^2 = 0.03661 \times 16 = 0.5858, which equals 1/(2sin⁡2(3π/8))=2−21/(2\sin^2(3\pi/8)) = 2 - \sqrt2. On a coarse grid the limit is noticeably above 12\tfrac12 (the sine is not yet 11).

✏️ Pen & paperHow long until the instability shows?●●○

On 4949 interior nodes G=1−4r(0.99901)G = 1 - 4r(0.99901). At r=0.6r = 0.6, starting from rounding noise 10−1610^{-16} against a solution of size 11, how many steps until the sawtooth is of order 11? Compare r=0.3r = 0.3.

Show worked solution

At r=0.6r = 0.6: G=1−2.4(0.99901)=−1.3976G = 1 - 2.4(0.99901) = -1.3976, so ∣G∣m=1016\lvert G\rvert^m = 10^{16} gives m=16ln⁡10/ln⁡1.3976=36.84/0.3349=110m = 16\ln 10/\ln 1.3976 = 36.84/0.3349 = 110 steps. The run is ruined within about a hundred steps. At r=0.3r = 0.3, G=1−1.2(0.99901)=−0.1988G = 1 - 1.2(0.99901) = -0.1988, and the sawtooth shrinks by a factor of five each step: stable, sign-flipping, gone within a few steps.

✏️ Pen & paperThe price of a finer mesh●●○

Air, ν=1.47×10−5 m2/s\nu = 1.47\times10^{-5}\,\mathrm{m^2/s} (from memory), 2D grid. (a) Largest explicit step at h=1 mmh = 1\,\mathrm{mm}? (b) Steps for one second. (c) The same at h=0.5 mmh = 0.5\,\mathrm{mm}, and the growth of total work.

Show worked solution

(a) Δt≤h2/(4ν)=10−6/(5.88×10−5)=0.01701 s\Delta t \le h^2/(4\nu) = 10^{-6}/(5.88\times10^{-5}) = 0.01701\,\mathrm{s}. (b) 1/0.01701=58.81/0.01701 = 58.8, so 5959 steps. (c) Δt≤0.004252 s\Delta t \le 0.004252\,\mathrm{s}, 236236 steps. That is 4×4\times the steps on 4×4\times the cells: 16×16\times the work for 4×4\times less spatial error.

✏️ Pen & paperWhere $6r - 1$ comes from●●●

Using ut=uxxu_t = u_{xx}, show that the FTCS truncation error is h212(6r−1)uxxxx+⋯\tfrac{h^2}{12}(6r - 1)u_{xxxx} + \cdots and say what the value r=1/6r = 1/6 does to the modes of the solution.

Show worked solution

Taylor in time: (u(t+Δt)−u(t))/Δt=ut+12Δt utt+⋯(u(t + \Delta t) - u(t))/\Delta t = u_t + \tfrac12\Delta t\,u_{tt} + \cdots. From the PDE, utt=(uxx)t=uxxxxu_{tt} = (u_{xx})_t = u_{xxxx}. Central difference in space: (u(x+h)−2u+u(x−h))/h2=uxx+h212uxxxx+⋯(u(x+h) - 2u + u(x-h))/h^2 = u_{xx} + \tfrac{h^2}{12}u_{xxxx} + \cdots. Subtract, using ut=uxxu_t = u_{xx}: the error is (12Δt−h212)uxxxx=h212(6r−1)uxxxx(\tfrac12\Delta t - \tfrac{h^2}{12})u_{xxxx} = \tfrac{h^2}{12}(6r - 1)u_{xxxx} since Δt=rh2\Delta t = rh^2. At r=1/6r = 1/6 the first and fourth-derivative terms cancel, so the leading error is gone and, by the classical result (from memory, not rederived here), the scheme is O(h4)O(h^4) for smooth data. Above 1/61/6 high modes decay too fast, below it too slowly.

Key Takeaways

  • Method of lines: discretise space and ∂tu=Au\partial_t\mathbf u = A\mathbf u is an ODE system. FTCS is forward Euler applied to it, with r=αΔt/h2r = \alpha\Delta t/h^2.
  • Each eigenvector decays by Gk=1+λkΔt=1−4rsin⁡2(kπh/2)G_k = 1 + \lambda_k\Delta t = 1 - 4r\sin^2(k\pi h/2) per step; the scheme is stable exactly when every λkΔt\lambda_k\Delta t lies in the Euler stability interval [−2,0][-2, 0].
  • The highest mode, a sawtooth, binds: r≤1/(2sin⁡2(nπh/2))≈1/2r \le 1/(2\sin^2(n\pi h/2)) \approx 1/2 in 1D. Above it the sawtooth grows by ∣1−4r∣\lvert 1 - 4r\rvert per step from rounding-size seeds, so the run looks fine for hundreds of steps and then explodes.
  • In 2D, eigenvalues add, the checkerboard binds, and r≤1/4r \le 1/4; in dd dimensions Δt≤h2/(2dα)\Delta t \le h^2/(2d\alpha).
  • Stable is not accurate: the truncation error is h212(6r−1)uxxxx\tfrac{h^2}{12}(6r - 1)u_{xxxx}, order O(Δt,h2)O(\Delta t, h^2), and high modes decay wrongly; at r=0.5r = 0.5 the sawtooth survives with G=−0.998G = -0.998.
  • Halving hh means four times the steps: 8×8\times the work in 1D, 16×16\times in 2D. RK4 raises the limit only 1.391.39-fold.
  • Next: von Neumann analysis. The eigenvalue argument here needed a matrix; there is a shortcut that feeds one Fourier mode through the scheme and reads the growth factor G(k)G(k) directly, so it works for schemes with no tidy matrix, including centred advection, which turns out to be unstable for every Δt\Delta t. After that, implicit methods trade a linear solve per step for stability at any Δt\Delta t, which is how Stam’s solver handles diffusion.
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: