Every method so far marched forward in time: give Euler, RK4 or RK45 the state at and it walks on. Steady flow between two plates is different: the velocity is known at both walls and nowhere in between, so there is nothing to march from. Such a boundary value problem (BVP) is how the diffusion step and pressure projection of Stam’s fluid solver look from the inside. We attack the second-order equation of 5.2 Constant Coefficients & the Characteristic Equation in two ways: shooting, which reuses the integrator of 4.3 Runge–Kutta Methods & Butcher Tableaux, and finite differences, which give a matrix problem that is cheap to solve.
Transcript
- An initial value problem gives everything at one point, and marching finds the unique solution. A boundary value problem gives one condition at each end, and no such theorem holds. For y double prime equals minus y, the solution is s sine x, and the far condition says s sine L equals b. One solution, unless L is pi: then every slope works, or none does.
- Three kinds of condition. Dirichlet fixes the value: a wall temperature, or the no-slip velocity. Neumann fixes the derivative: insulation, or a symmetry plane so you can compute half a channel. Robin mixes the two: Newton cooling, where conducted heat equals convected heat. With Neumann at both ends the solution is only fixed up to an added constant.
- Steady flow between plates is a boundary value problem. Pressure drop balances viscous shear: mu u double prime equals minus G, with no-slip walls. Integrating twice gives a parabola, G over two mu times y times H minus y. For water, 1 centimeter apart, the peak is 0.01 meters per second. If the top plate slides at 0.005 instead, with no pressure drop, the profile is a straight line: Couette.
- Shooting turns the unknown into a guess. Fire the initial value problem from the left wall with launch slope s, and measure the miss at the right wall: F of s equals y of L minus b. A solution is a root of F, found with the secant method. For a linear equation, F is a straight line, so one secant step lands exactly: slope 1.188395.
- Nonlinear equations can have several answers. For y double prime equals minus e to the y, with both ends at zero, the residual F crosses zero twice. Secant from 0 and 1 finds slope 0.549353, a shallow arc. Secant from 8 and 12 finds 10.846899, a tall arc, launched steeply so the restoring force turns it around. Same equation, same walls: you must know to look for both.
- Shooting has a weak spot. For y double prime equals 100 y, the wanted solution decays like e to the minus 10 x, but any launch error excites e to the plus 10 x. The secant method finds s equal minus 10 to double precision, yet the integration cannot hold the decay: at L equals 3, the end value is wrong by a factor of 10 to the 9. Finite differences stay near 10 to the minus 3.
- Finite differences cut the interval into cells and demand the equation at every interior node. The second difference approximates u double prime with error of order h squared. For plate flow with five cells, each row touches only its neighbors: a tridiagonal matrix, with minus 0.0032 on the right. The four dots are the solution, largest 0.0096. A parabola has no fourth derivative, so this answer is exact up to round-off.
- The Thomas algorithm is Gaussian elimination written for three diagonals: one forward sweep, one backward sweep, 8 N minus 7 operations. Dense elimination costs two thirds N cubed. At N equals 100 that is 793 against 681550, a factor of 859; at 200, a factor of 3385. Doubling N doubles Thomas, and multiplies dense by 7.8.
- Does it converge? For a manufactured sine solution, the maximum error drops by 4 each time h is halved: second order. Neumann with a ghost point keeps that. Replace the ghost row by a one-sided difference and the ratio falls to 2. One first-order row spoils the whole grid: at N equals 128 its error is larger than the ghost-point error at N equals 8.
- Stam's fluid solver ends every step with a pressure projection: a Poisson equation with Neumann walls, then subtract the gradient. Diffusion is a boundary value problem too. In one dimension these are exactly this lesson's tridiagonal systems. In two, each row has five non-zeros, and solvers use iterative sweeps instead. Next: the eigenvalues and eigenfunctions of the same operator.
Initial versus boundary conditions
An initial value problem gives all its data at one point: with and prescribed. For smooth the theorem of 3.7 Existence & Uniqueness says there is exactly one solution near that point, and RK4 finds it by marching. A two-point BVP gives one condition at each end: and . No such theorem holds, and the next example shows why.
Take with . The general solution is and forces , so , where is the launch slope. As an IVP, is a number you choose: unique solution. As a BVP, the second condition demands
This is a one-by-one linear system , which fails the way any linear system can (see the kernel in 1.3 Linear Systems, Kernel & Column Space):
- : exactly one solution, . For the required slope is at , at , at , at and at : it explodes as .
- , : , so every slope works, infinitely many solutions.
- , : , no solution.
The sim’s shooting panel shows this as the residual , the miss distance at the right wall for launch slope . At , the computed and : zero up to RK4’s truncation error, for every . At , both are : a flat line that never crosses zero. The trouble sits at because there the homogeneous problem () already has the nonzero solution : the eigenvalue problem of 8.2 Eigenvalue Problems & Sturm–Liouville Theory. Nonlinear BVPs add a fourth outcome, several solutions (two, below).
Three kinds of boundary condition
At an end one scalar condition is imposed:
- Dirichlet: the value, . A wall with fixed temperature; a no-slip wall where the fluid velocity equals the wall velocity.
- Neumann: the derivative, . A fixed heat flux, the insulated case being . In a fluid, a symmetry plane has , so you can compute half a channel.
- Robin: a mix, . Newton cooling: heat conducted to the surface, , equals the heat convected away, , giving . A slip wall with friction is also Robin.
Neumann at both ends fixes only up to an added constant, since and have the same derivatives.
Worked example: flow between plates
For steady, fully developed flow of a viscous fluid between plates at and (standard reduction of the Navier–Stokes momentum equation, not re-derived here), only the streamwise velocity survives and pressure drop along the channel balances viscous shear: . With no-slip walls , integrate twice:
The conditions give , , so
Numbers. Water ( Pa s), cm, Pa/m: , so and m/s. The sim’s “Poiseuille” problem solves this numerically and prints largest m/s. If instead the top plate slides at and there is no pressure drop, gives the Couette profile : with m/s the sim’s largest is , at the moving plate.
The shooting method
Idea: replace the unknown by a guess. Fire the IVP , , with RK4 to and measure the miss . A BVP solution is a root of , a scalar root-finding problem. Bisection needs a bracket (a sign change of ); the secant method needs two guesses,
Linear case: one step. For linear the solution is (superposition), so is a straight line and the secant formula lands exactly on its root. For , , : , , and one secant step gives , with (lab block A).
Nonlinear case: several roots. Take , . (This Bratu-type problem is a standard test; that it has exactly two solutions at this parameter is quoted from memory, and the experiment below finds both.) The residual (lab block B, 1000 RK4 steps):
| 0 | 0.5 | 1 | 5 | 8 | 11 | 12 | |
|---|---|---|---|---|---|---|---|
changes sign twice, once in and once in , so two brackets for bisection. Secant started at gives in five steps () with midpoint value ; started at it gives in five steps () with . Same equation, same walls, two different solutions: a shallow arc, and a tall arc launched so steeply that the strong restoring force turns it around in time. Which one shooting finds depends on where you start, so you must know to look for both.
Where shooting fails: growing solutions
Consider , , . Every solution is ; the wanted one has . A launch slope gives , and the unwanted piece grows by while the wanted one shrinks by . The slope is a double with about sixteen digits, so even the best slope carries a rounding error that is amplified into a wrong end value. Lab block C (RK4, , secant from and ):
| shooting | exact | relative error | FD worst relative error | ||
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 |
The secant method found to double precision in every row; it is the integration that cannot hold the decaying solution against the growing one. Roundoff-driven digits depend on the machine (the sim and Python agree on orders of magnitude). At shooting beats finite differences, which is honest: its trouble starts when (the growing-to-decaying ratio, printed by the sim) outruns . Finite differences solve for all values at once and the diagonal of the system is dominant, so their error stays near (from the truncation, next section) and grows only mildly with .
Finite differences and the tridiagonal system
Cut into cells of width with nodes . Adding the Taylor expansions of ,
so the second difference approximates with error . Demand at each interior node:
The wall values , are known and move to the right side, leaving equations in unknowns. Each row has three non-zero entries: a tridiagonal matrix. For Poiseuille with ( m, , as the sim prints):
The solution is the four dots in the sim, with largest value (the grid has no node at the centre, where the exact value is ). For this problem the numerical answer is exact: for a parabola, so the term above vanishes, and the measured error is round-off only, between and for (lab, sim). A parabola therefore cannot test convergence.
Convergence test: a manufactured solution. Choose on , so and the boundary data come from (). Lab block D, maximum error over the nodes:
| 8 | 16 | 32 | 64 | 128 | |
|---|---|---|---|---|---|
| error | |||||
| ratio | 3.97 | 4.00 | 4.00 | 4.00 |
Halving divides the error by (up to at the coarsest step): second order, as the Taylor series said.
The Thomas algorithm is Gaussian elimination written for three diagonals. With sub-diagonal , diagonal , super-diagonal and right side :
Each row is touched once forward and once backward, about operations (exactly , counted) against for dense elimination. The sim’s counter runs both on the same matrix: : against ; : against ; : against (a factor ); : against (). Doubling doubles the Thomas cost () and multiplies the dense cost by . No row exchanges are needed because the diagonal () is at least the two off-diagonals together () (stated from memory).
Neumann and Robin conditions
With the value is unknown too, so row must use the boundary condition. The ghost point trick: pretend a node exists, impose the centred difference , so , and substitute into the ordinary equation at node :
(Robin adds to the diagonal.) The matrix stays tridiagonal; its last row is . The cheaper choice is a one-sided difference , but it is the derivative at the midpoint , off by from the node. Same sine problem, maximum error (lab block D):
| right end | ratios | |||||
|---|---|---|---|---|---|---|
| Neumann, ghost | 3.97, 4.00, 4.00, 4.00 | |||||
| Neumann, one-sided | 2.00 each | |||||
| Robin, ghost | 3.95, 4.00, 4.00, 4.00 | |||||
| Robin, one-sided | 2.00 each |
One first-order row in a second-order scheme makes the whole solution first order: the boundary error is and the solve spreads it across the grid. At the one-sided Neumann error () is larger than the ghost-point error at (). For the half-channel Poiseuille problem (, symmetry at ) the ghost version is exact (round-off below ), while the one-sided version gives a centre velocity of , , for against the exact : the error halves each time.
Try it
What to try. (1) Poiseuille: round-off error for every ; set and read the matrix. (2) Sine problems: then ; for Neumann untick the ghost box and watch the ratio fall to . (3) Press “count operations”. (4) Shooting, : and , then “L = pi” with and . (5) Bratu: both secant starts. (6) , : the blue curve peels away from the exact decay.
Computing it
Now build the finite-difference solver yourself: the tridiagonal solve, then the plate-flow problem on top of it.
Concept checks
Problems
For , , , find the launch slope or say why none exists: (a) , ; (b) , ; (c) , ; (d) , .
Show worked solution
, so . (a) (sim: ). (b) : nearly resonant, so a tiny change in or moves a lot. (c) : infinitely many, one for every . (d) : none.
Take the half-channel Poiseuille problem on with and , and use cells () with the ghost-point row. Write the two equations, solve them, and compare with the exact .
Show worked solution
Unknowns ; . Row 1: . Row 2 (ghost point, ): . From row 2, ; into row 1: , so and . The exact values are and : exact, because the profile is quadratic. (Set and the half-channel problem in the sim: error at round-off.)
The sim counts operations for the dense solve and for Thomas at . Using and , estimate the ratio at , and say what it means for a 2D grid of unknowns.
Show worked solution
Formula check at : , within of the count. At : dense , Thomas , ratio about (an estimate from the formula; the sim only counts up to ). In 2D the unknowns number , a dense matrix would be and could not even be stored, which is why sparse structure and iterative solvers matter.
Key Takeaways
- A BVP gives conditions at two points and cannot be marched. For , , the count depends on : one solution ( at ), none, or infinitely many (at ).
- Dirichlet fixes the value (temperature, no-slip), Neumann the flux or slope (insulation, symmetry plane), Robin a mix (convective cooling).
- Plate flow is : Poiseuille , with m/s for and cm; Couette is linear.
- Shooting: secant on ; one step when linear, and has two solutions ( and ) from different starts. Growing modes break it: on the end value is wrong by a factor at and at , while finite differences stay near .
- Finite differences give a tridiagonal system, solved in operations (dense: against at ), with error ratio per halving of .
- Ghost points keep Neumann and Robin second order; a one-sided row drops the ratio to .
- Next: the eigenvalues and eigenfunctions of the same operator, 8.2 Eigenvalue Problems & Sturm–Liouville Theory.