Switch off time in the heat equation and wait. What remains is the steady state, and in one dimension we already found it: 9.2 The Heat (Diffusion) Equation showed that gives a straight line between the two end temperatures. On a plate the same wait gives Laplace’s equation, , and the straight line becomes a surface held up only by its edges. It is the equation behind the velocity potential of ideal flow around a wing and the pressure that Stam’s solver computes at every time step. This lesson solves it exactly on a rectangle and a disk, extracts its three great properties (mean value, maximum principle, uniqueness), and then computes it as a simulator does, by relaxation. Separation of variables is done in full, since the heat and wave equations need it too.
Transcript
- Switch off time in the heat equation and wait. In one dimension the steady state is a straight line. On a plate it obeys Laplace's equation, u x x plus u y y equals 0: a surface held up only by its edges.
- A function with zero Laplacian is called harmonic. So are x, x y, x squared minus y squared and e to the x cosine y, but not x squared plus y squared, whose Laplacian is 4. Add a source f on the right and it is Poisson's equation.
- The Laplacian measures how far u sits from the average of its surroundings: on a grid, the four neighbours minus 4 u, over h squared. So Laplace's equation says each point equals the average of its four neighbours: no bumps and no dips.
- Give u on the edge and find the harmonic function inside. On a rectangle, with 0 on three sides and f on top, try a product X of x times Y of y. Both sides of the divided equation must be a constant, minus lambda, and only positive lambda gives sines across, with sinh along.
- Any sum of these products is harmonic and zero on three sides. Matching the top edge asks for a sine series of f, which gives b n. For f equal to 1, b n is 4 over n pi for odd n. One term is a rough hump; adding n equals 3 flattens the top.
- At the centre of the unit square the first term gives 0.25372, adding n equals 3 gives 0.24990, and the next gives 0.25000: one quarter. The mode strength dies like e to the minus n pi times 1 minus y, so a ripple is down by 1 over e at only wavelength over 2 pi from its edge.
- On a disk, use polar coordinates. A periodic angle forces an integer n, and the radial solutions are r to the n or r to the minus n. The second blows up at the centre, so keep r to the n, with the Fourier coefficients of the edge data. Edge data cosine 2 theta gives the saddle.
- Take edge data 1 on the upper half and 0 on the lower. Then b n is 2 over n pi for odd n, and the series sums to an arctangent. At r equal one half, theta equal pi over 2, it reads 0.79517, and the partial sums home in.
- Put the coefficients back into the series and the bracket is a geometric series: Poisson's integral formula. The kernel is positive, integrates to 1, and spikes at phi equals theta as r goes to 1, so each interior value is a weighted average of the edge.
- At the centre r is 0, the kernel is 1, and the value is the average over the circle: the mean value property, for any harmonic function and any circle. For the hot quarter arc, the boundary average, the grid centre and the Poisson centre all read 0.25.
- Consequences. An interior maximum M would be the average of values at most M on a small circle, so all equal M: extremes live on the boundary. Two solutions with the same edge data differ by a harmonic function that is 0 on the edge, so the solution is unique.
- To compute it, replace each interior value by the average of its neighbours: Jacobi iteration, the explicit heat step at r equal 1 over 4. To reach a residual of 10 to the minus 6, Jacobi needs 2309 sweeps, Gauss-Seidel 1166, and SOR at omega 1.85 only about 95.
- Why so many? Jacobi multiplies the slowest error mode by cosine pi h, which is 0.99692 at h equal 1 over 40. Sweeps scale like 1 over h squared: 10, 20 and 40 intervals take 197, 687 and 2309. The best SOR factor gives 0.8545, and needs only about 1 over h.
- A small residual is not a small error. The residual is only 1 minus rho times the error, so Jacobi at h equal 1 over 40 can hide an error 324 times its residual, and the converged grid keeps its discretization error. Set the tolerance from the grid.
- Why care? Ideal flow is irrotational and incompressible, so the velocity is the gradient of a potential phi that obeys Laplace's equation. In Stam's solver the pressure obeys a Poisson equation every time step, so 1 over h squared sweeps is the bottleneck.
- To recap. A harmonic function is the average of its neighbours. The rectangle gives sinh, the disk gives r to the n, and the mean value property gives the maximum principle and uniqueness. Jacobi needs about 1 over h squared sweeps, SOR about 1 over h.
- Next, the finite-difference lesson. Here we took the five-point stencil and the boundary arm weights on trust. There we derive them from Taylor series, and measure how fast the grid error shrinks as h does.
Harmonic functions and the neighbor average
A function with is called harmonic. Members: , , , (, ). Non-member: , whose Laplacian is . With a source on the right, is Poisson’s equation.
The reading from 2.11 The Laplacian & Vector Identities is the one to keep: measures how far at a point sits from the average of around it. On a grid with spacing ,
So Laplace’s equation says : every point is the average of its four neighbors, with no bumps and no dips. (The stencil is derived in the finite-difference lesson; here it is the discrete mean value property, taken on trust.)
The problem is a boundary-value problem: give on the edge (a Dirichlet condition) and find the harmonic function inside. Giving the normal derivative instead (a Neumann condition, a prescribed heat flux) works too, with one catch from the divergence theorem: the net flux must equal , so with the fluxes must cancel. The pressure below meets that exact condition.
The rectangle: separation of variables
Take , , with on the left, right and bottom, and on top. Try a product . Then , and dividing by ,
The left side depends only on , the right side only on , and they are equal, so both are a constant, which we call . The two ordinary differential equations are and .
The boundary conditions pick the sign. must vanish at and ; for the solutions are exponentials or lines, which cross zero at most once, so only works. This is the two-point BVP of 8.1 Two-Point Boundary Value Problems, with nonzero solutions only for
For , with and , we get . Each product is harmonic and vanishes on three sides, and so does any sum, so write
where the division by makes the top-edge value . Matching asks for a sine series of , so
Example. Unit square, on top, elsewhere. Then , which is for odd and for even . At the center,
The term is , adding gives , and the playground below prints the next, : the answer is .
Why so fast? The factor is the mode’s strength at distance from the edge that drives it. Where the heat equation killed short wavelengths in time, Laplace’s equation kills them in distance: a ripple of wavelength is down by at only from its edge, and the interior sees just the broad shape of the boundary. The price is at the edge itself. With the data jump at the top corners, the coefficients fall only like , and the series is slow there (so is the grid). A general edge set is four such problems added together, swapping and for the side edges; the lab’s exact panel does that.
The disk: polar separation and Poisson’s formula
For a disk, use polar coordinates, where the Laplacian is
(The in the first term is the ring circumference the flux crosses.) Put and multiply through by :
Periodicity in forces the constant to be with and , the role the end conditions played for the rectangle. The radial equation is an Euler equation, solved by with , so or (and or for ). The solutions with or blow up at the center of a plate with no hole in it, so we keep :
with and the Fourier coefficients of the edge data on (, similarly ). For radius , replace by .
Example. gives : the saddle, harmonic as claimed. Second example: on the upper half (), on the lower. Then , every , for odd , and (a closed form, from memory) , which at is ; the playground sums the series toward it.
Put the coefficient integrals back into the series:
The bracket is with , a geometric series, and it equals . This is the Poisson integral formula:
The kernel is positive, integrates to , and as spikes at : the interior temperature is a weighted average of the edge temperatures, the nearest weighted most. Everything that follows is in this.
Mean value, maximum principle, uniqueness
Mean value property. At the center, , the kernel is : . The value at the center is the average over the circle. Moving the origin shows it for any harmonic function and any circle inside its domain: the continuous version of .
Maximum principle. A non-constant harmonic function on a bounded region takes its maximum and minimum on the boundary, never inside. Mechanism: if the maximum were reached at an interior point , then is the average of over a small circle around where every value is at most , so all equal . Repeating from those points spreads over the whole region: was constant. On the disk it is even more direct: the Poisson kernel is a positive weight, so cannot leave the range of .
Uniqueness. If two solutions share boundary data, their difference is harmonic with zero data. By the maximum principle its maximum and its minimum are both , so . The same argument gives stability, . Neumann data fix the answer only up to an added constant, the null space the pressure equation inherits.
Relaxation: computing a harmonic function
Start from any guess and repeat “replace each interior value by the average of its neighbors”. That sweep is Jacobi iteration, and it is the explicit heat step of the previous lesson: is FTCS in 2D with , the largest stable value there. Relaxing is running the heat equation until it stops changing.
How many sweeps? Decompose the error into sine modes . A Jacobi sweep multiplies mode by . The slowest is :
On the lab’s grid, , this is . Sweeps scale like , so halving costs four times the sweeps (the playground counts , , for , , intervals). Long wavelengths die slowly, as in the heat equation.
Two cures. Gauss-Seidel uses new values as soon as they exist; its slowest factor is (from memory), about half the sweeps. SOR pushes each update further: , . For the square the best is (Young’s result, from memory; the lab tests it), giving at . SOR sweeps grow like , not .
The residual (how much one more sweep would change the values) is not the error. For the slowest mode, residual error, so Jacobi at can hide an error times its residual. And the converged grid answer is itself off from the exact solution by the discretization error, which no number of sweeps removes.
The lab
The square has intervals per side; the disk has across its diameter, with arm-length weights where the circle cuts between nodes. The interior starts at zero.
- Solver race, top edge . Residual first below : Jacobi at sweep , Gauss-Seidel , SOR at sweep , at sweep . At the stops, Jacobi sits from the converged grid solution ( times its residual); SOR at sits away. The button’s needs : the optimum is flat.
- Series terms. Grid center . With series term the series center is , with it is . The largest grid-series difference is at term, at , at and at : it sits beside the top corners, and the last value is the grid’s own corner error (rms ).
- One-term data. Top edge : the exact answer is , center . The converged grid center is , the largest difference : discretization error with nothing singular.
- Planes and saddles. The 5-point stencil has no error on linear or quadratic functions, so for the ramp () and saddle () presets the grid answer is exact up to the stopping rule, and the difference from the series is the series’ truncation: for the ramp at terms, at .
- Disk. On the converged grid is within of the Poisson integral. On the hot quarter arc the boundary average, grid center and Poisson center all read : the mean value property. The largest difference, , is at the rim node under the jump in the data (rms ). The interior range readout stays inside the boundary range: the maximum principle.
- Paint it. Drag along an edge with a brush temperature: change one edge value and every interior point moves. Nothing is carried along; the influence is global.
Computing it
The lab’s first rows reproduce the series numbers above and the sweep counts (, , ); the last rows show the disk series converging to the closed form, .
Concept checks
Problems
Which of , , (for ) is harmonic? For the harmonic ones that are polynomials, find the boundary data on the unit circle and the polar form.
Show worked solution
: , , sum : harmonic. : , , sum : not harmonic. : , harmonic (it blows up at the origin, so the disk solution rejected it). For , , give : on the unit circle , the term of the disk series.
On the unit disk the edge data are . Write the solution, evaluate it at , and check the mean value property on the circle .
Show worked solution
The data are already a finite Fourier series: , , . So . At , , : . On the circle the average over kills and (each averages to over a full turn), leaving , which is at the center ( gives ). The mean value property holds on every circle, not just the boundary one.
A unit square has its top, right, bottom and left edges held at , , and degrees. Find the center temperature without solving anything, and explain why the answer is exact for the grid solution too.
Show worked solution
Let be the solution with the top at and the others at , and , , its rotated copies. Their sum has boundary value on every edge, so by uniqueness it is the constant . The copies are rotations of one another, so each is the same at the center: . By linearity the answer is degrees. The grid problem has the same structure (a rotation-symmetric stencil, a constant solves it, unique solution), so the converged grid center is exactly ; the lab’s for Jacobi at its stop is iteration error.
(a) Show that one Jacobi sweep equals one FTCS step of the 2D heat equation with . (b) For , estimate the sweeps to cut the slowest error mode by for Jacobi and for SOR with the best .
Show worked solution
(a) FTCS in 2D: . At the terms cancel, : the Jacobi update. (b) Jacobi: , so . SOR: , , . That is the against scaling: a factor .
Key Takeaways
- A harmonic function () equals the average of its neighbors: on every circle (mean value property) and on a grid, . Poisson’s adds a source.
- Rectangle: separation with zero data on opposite sides forces , then in ; a sine series of the top data fixes the coefficients. Ripples of wavelength penetrate only about .
- Disk: the periodic angle forces integer , regularity at the center keeps , and the coefficients are the Fourier coefficients of the edge data; summing the series gives the Poisson integral, a positive weighted average of the edge values.
- Mean value property maximum principle (no interior extremes) uniqueness and stability. Neumann problems are unique only up to a constant, and need compatible fluxes.
- Jacobi relaxation is explicit heat flow at ; its slowest error mode decays like , so it needs about sweeps ( at ). Gauss-Seidel halves that, optimal SOR needs about ().
- A small residual is not a small error (a factor for Jacobi here), and sweeps past the discretization error buy nothing.
- Potential flow (, ) and the pressure projection are Laplace and Poisson problems: elliptic, global, and the expensive step of a fluid solver.
- Next, the finite-difference lesson takes the five-point stencil and the boundary arm weights that we used here on trust, derives them from Taylor series, and measures how fast the grid error shrinks as does.