In 9.2 The Heat (Diffusion) Equation we ran FTCS on a rod and saw it explode when 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.
Transcript
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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 and let be the temperature at node , a function of time. Replacing only by the three-point stencil turns the PDE into one ODE per node:
where 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 , and here the eigenvectors are the sampled sines .
Now choose an ODE solver. Forward Euler gives . Written out row by row, that is
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 , one forward Euler step multiplies by . The method is stable when : the disk of radius one centred at in the plane (the stability region of the Euler lesson). For a real negative this is the interval .
A linear system decouples along eigenvectors. Expand in the eigenvectors of ; each component is multiplied per step by with its own eigenvalue. The scheme is stable exactly when every lies in the stability region, which is one inequality per eigenvalue. The last lesson gave them all:
They are real and negative, so only the real interval matters, and the binding one is the most negative eigenvalue, the highest mode , where the sine is close to . The condition is
That is the limit of the heat lesson, now derived, and with its fine print: on a finite grid the exact threshold is a little above one half, for interior nodes ().
Worked example. Take , , . The eigenvalues from the last lesson run from to . Forward Euler needs , which is . The smooth mode alone would allow , twenty-five times larger: the step is dictated by a mode that carries almost no energy in a smooth solution. On the -node rod the eigenvalues span to , a ratio of : the stiffness of 4.5 Stability Regions & Stiffness, which worsens as .
The amplification factor of every mode
Put the pieces together. A grid mode is multiplied by one number per step:
The exact PDE multiplies the same mode by , an exponential decay, so should approximate it. Stability is for all . Look at the two ends of the spectrum.
- Smooth mode, . is tiny, so and the mode decays slowly, as it should.
- Sawtooth, . On the grid this mode is with alternating sign: neighbours point in opposite directions. Since , .
For interior nodes the exact values are at , at , at and at . Two things happen as grows. At the factor crosses zero and turns negative: from then on the sawtooth flips sign each step, still decaying. At just over one half it crosses , and the sawtooth then grows by per step, then by , in either sign. Nothing else changes: is about 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 a seed of against a smooth solution of size needs steps to become : the run looks fine for hundreds of steps and then fails in tens. At the same trip takes steps. The lab runs exactly that (the bump preset carries a seed).
2D: eigenvalues add
On a square grid with interior nodes, the five-point Laplacian is (from the last lesson). Its eigenvectors are products , and its eigenvalues are the sums
the discrete form of . The most negative is , about , twice the 1D value. The checkerboard mode has , and stability needs :
Each extra dimension adds another , so in dimensions: 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 , the factor of the checkerboard is , so at and at . A code tuned in 1D at is unstable the moment someone adds the second dimension: .
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 and so . Euler’s time difference is and the centred space difference is (take ), so the truncation error is
First order in , second in : , and at fixed both are . At the leading term cancels. For a mode , times the mode, so the scheme decays it at the rate : too slowly for , too quickly above it, and worse the larger is.
The lab and a script confirm this. Run the pure mode for steps and compare with the exact decay . At () the grid amplitude is against exact , which is too large; the prediction from the formula above is . At it is against : off. At it is against , too small, and at it is against , too small. All stable. The bar chart in the lab draws both and the exact factor.
The worst case is the top mode, where the discrepancy is not small at all. At the exact PDE kills by a factor per step, while the grid gives : the sawtooth survives, flipping sign. After steps the grid amplitude is ; the true one is below . Those wiggles are what the physics says should vanish: do not call a run clean just because it stays bounded. Keeping below about makes every positive, so no mode oscillates.
What refinement costs
Halving makes the top eigenvalue four times larger, so 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 and final time , intervals need steps. Halving 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
The domain is the unit interval or square, , , interior nodes in 1D and in 2D, boundary held at . Bars show (red when ), dots the exact PDE factors, and the bottom strip on a log scale. The readout gives the worst mode, the measured growth of per step over the last ten steps, and the tracked mode’s amplitude.
- 1D bump, press “r just below the limit” (). All bars are blue. is at step and at step , shrinking by per step, the factor of the smooth mode. The sawtooth bar is : flipping, decaying.
- “r just above” (). The last bar turns red at . The bump decays to at step , but the seed has grown: is at step and rising, at step , at step , and the run is flagged blown up at step . The measured growth settles at , the bar’s magnitude. The log strip shows a decay, a minimum, then a straight line up.
- Highest mode, . Each step multiplies the pattern by exactly : at step .
- Random noise at . After steps the maximum is , and ; the last grows per step against .
- 2D, bump. The limit is . At the plate decays smoothly ( at step ). At it decays until about step (), then a checkerboard takes over: at step , blown up at step , measured growth . At the blow-up takes only steps, and the checkerboard factor is .
- Single mode, . After steps at the readout gives against exact ; equals the measured value, because a grid mode is an exact eigenvector. Try and for the other numbers above.
- Mode at . The dot (exact factor ) sits far above the bar (): measured amplitude after steps, equal to .
Computing it
The output reproduces the top-mode factors, the 2D values and the step counts quoted above.
For the largest stable step is ( times ); of it leaves after steps, and gives .
Concept checks
Problems
Take interior nodes () and . Find the three eigenvalues of the semi-discrete matrix, the largest stable forward-Euler , and at that step.
Show worked solution
: , , . The limit is . Then , which equals . On a coarse grid the limit is noticeably above (the sine is not yet ).
On interior nodes . At , starting from rounding noise against a solution of size , how many steps until the sawtooth is of order ? Compare .
Show worked solution
At : , so gives steps. The run is ruined within about a hundred steps. At , , and the sawtooth shrinks by a factor of five each step: stable, sign-flipping, gone within a few steps.
Air, (from memory), 2D grid. (a) Largest explicit step at ? (b) Steps for one second. (c) The same at , and the growth of total work.
Show worked solution
(a) . (b) , so steps. (c) , steps. That is the steps on the cells: the work for less spatial error.
Using , show that the FTCS truncation error is and say what the value does to the modes of the solution.
Show worked solution
Taylor in time: . From the PDE, . Central difference in space: . Subtract, using : the error is since . At 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 for smooth data. Above high modes decay too fast, below it too slowly.
Key Takeaways
- Method of lines: discretise space and is an ODE system. FTCS is forward Euler applied to it, with .
- Each eigenvector decays by per step; the scheme is stable exactly when every lies in the Euler stability interval .
- The highest mode, a sawtooth, binds: in 1D. Above it the sawtooth grows by 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 ; in dimensions .
- Stable is not accurate: the truncation error is , order , and high modes decay wrongly; at the sawtooth survives with .
- Halving means four times the steps: the work in 1D, in 2D. RK4 raises the limit only -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 directly, so it works for schemes with no tidy matrix, including centred advection, which turns out to be unstable for every . After that, implicit methods trade a linear solve per step for stability at any , which is how Stam’s solver handles diffusion.