Fundamentals / Numerical mathematics / Numerical partial differential equations

Wave resolution and verification

Prescribe the first time level of a vibrating string, measure a convergence order and decide what a residual reveals under grid refinement.

Release a mode from rest

For a unit string with fixed ends take initial shape \(u_i^0=\sin(\pi i/N)\) and initial velocity zero. Derive the factor relating \(u_i^1\) to \(u_i^0\) for the centred wave scheme with Courant number \(C\). Evaluate it for \(N=4,\ C=0.5\).

Worked solution

The central second difference of the sine is \(-4\sin^2(\pi/(2N))u_i^0\) before dividing by \(h^2\). The first-step Taylor formula therefore gives

\[u_i^1=[1-2C^2\sin^2(\pi/(2N))]u_i^0.\]

At \(N=4,C=0.5\), the factor is

\[1-0.5\sin^2(\pi/8)=0.92678.\]

Copying the initial displacement instead would omit the physical acceleration produced by the curved shape.

Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.

Quantify a grid-dependent observable

A computed outflow on meshes \(h,h/2,h/4\) is 2.080, 2.020 and 2.005 W. Assuming an asymptotic \(Q_h=Q+c h^p\), estimate \(p\), the extrapolated flux and the fine-grid error. Can those figures alone demonstrate conservation to the same tolerance?

Worked solution

The successive differences are 0.060 and 0.015 W, whose ratio is 4. Thus

\[2^p=4,\ p=2.\]

Extrapolate \(Q=2.005+(2.005-2.020)/3=2.000\) W, giving estimated fine-grid error +0.005 W.

A separate conservation check must sum inflows, outflows, sources and storage. A sequence of outflow values can converge cleanly even under a method that systematically loses heat elsewhere.

Explore the related calculation with adjustable inputs. Refine the grid on a known solution and keep the small linear-solver residual separate from the spatial field error.

Relate flux jumps to a residual indicator

A unit rod is approximated by two equal linear elements with nodal values \((0,1,1)\) and \(k=1\). Compute each element’s flux, the flux jump at their interface, and the elementwise second derivative. In a source-free steady model, explain what a check based only on that second derivative would miss.

Worked solution

The slopes are 2 and 0, giving fluxes −2 and 0 in the positive coordinate direction. The right-element flux minus the left-element flux is therefore 2. Second derivatives vanish inside both linear pieces.

In a source-free steady conductor the same flux must cross the interface from either element. An interior derivative check would report zero inside each element while ignoring the change at the joining node. An indicator including interface flux mismatch detects this loss of balance.

Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.

Refine a three-cell source patch

Split the unit interval into thirds and set \(f=0,9,0\) on successive cells, with zero temperature at both ends. Assemble the two interior values, calculate all three indicators and find a smallest set that accounts for \(80\%\) of the sum of indicator squares.

Worked solution

The middle cell contributes \(9(1/3)/2=3/2\) to each endpoint. The interior matrix is \(3\begin{pmatrix}2&-1\\-1&2\end{pmatrix}\), so symmetry gives

\[u_1=u_2=1/2.\]

The slopes are \(3/2,0,-3/2\). Both jumps have magnitude \(3/2\).

Each attached jump contributes \((1/6)(3/2)^2=3/8\) to a cell. The middle source term contributes \((1/3)^2(81/3)=3\). Thus the indicator squares are \(3/8,15/4,3/8\), totaling \(9/2\). The middle fraction is

\[(15/4)/(9/2)=5/6.\]

Marking just that cell exceeds the target.

Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.

Revisit chapter 6 · Choose cells to refine from residuals and flux jumps.

Predict the error before making a finer grid

In the variable-diffusion laboratory the mode-one errors on 24, 48 and 96 cells per side are \(1.33345\times10^{-3}\), \(3.33763\times10^{-4}\) and \(8.34283\times10^{-5}\). Estimate the last observed order, then predict the error at 192 cells and the number of interior unknowns. Decide whether reducing only the algebraic residual tolerance is likely to produce the same improvement.

Work through the solution

For \(E_N\approx C N^{-p}\), the last doubling gives

\[p=\log_2(E_{48}/E_{96})\simeq2.00.\]

Another doubling predicts \(E_{192}\simeq2.09\times10^{-5}\). Eliminating prescribed boundary nodes leaves \(191^2=36\,481\) interior values. The observed rate is a checkable prediction for this smooth fixed mode. A smaller residual on the 96-cell mesh solves the same discrete equations more accurately. The reported residual is already small, and refinement is what changes their truncation error.

Use the OneSimulation laboratory to check your answer