Nonlinear stationary equations

This page explains how pdemagic solves a stationary equation with a term that is nonlinear in the unknown,

\[L u + N(\mathbf{x}, u) = f ,\]

where \(L\) is a linear operator, with constant coefficients or with ones that vary, and \(N\) a function of the unknown and of the position. Two examples are the Poisson–Boltzmann equation, \(-\nabla^2 u + \kappa^2 \sinh u = \rho\), and the equation of a ground state, \(-\nabla^2 u + u - u^3 = 0\).

The method

Newton’s method replaces the equation by a sequence of linear ones. At a value \(u_k\) the nonlinear term is replaced by its tangent, \(N(u_k) + N'(u_k)\,(u - u_k)\), with the slope \(N' = \partial N / \partial u\). What remains is a linear equation for the next value, whose coefficient \(N'(u_k(\mathbf{x}))\) varies in space. That is an equation of the kind that the iteration for coefficients that vary solves. This page is about free space and periodic boxes. On a region of the plane each step is solved directly: see spectral elements.

pdemagic takes the slope from the equation itself: it differentiates the nonlinear term with respect to the unknown, symbol by symbol.

The unknown of the iteration is the effective source, as for a linear equation. The reference operator \(L_0\) has constant coefficients: those that the coefficients of \(L\) settle to, plus the value that the slope settles to at the start. With \(s = L_0 u\) the equation reads

\[G(s) = s + \sum_j \delta_j\, D_j u + \frac{N(u) - \bar N'\, u - f}{w} = 0, \qquad u = L_0^{-1} s ,\]

and each step of Newton’s method solves the linear equation \(G'(s_k)\,\sigma = -G(s_k)\) for the change \(\sigma\) by GMRES. The solve with \(L_0\) is the same in every step.

In free space this has the advantage that it has for a linear equation: where the solution is small, the nonlinear term is its tangent at zero, which is part of \(L_0\). So \(s\) vanishes away from the source, and the Green’s function of \(L_0\) gives a solution that decays as it should. For the Poisson–Boltzmann equation \(L_0 = -\nabla^2 + \kappa^2\), the screened equation that it becomes far from the charge.

Steps that are too long are shortened. A step is taken in full if that reduces the residual. Otherwise half of it is tried, then a quarter, and so on.

Each linear equation is solved loosely, to four digits. More would be wasted while the tangent is still far from the function.

Which solution is found

A nonlinear equation can have several solutions, or none. Newton’s method finds one that is near its starting value. That is zero unless the problem gives another one:

problem = pm.Problem(
    sp.Eq(-sp.Derivative(v, x, 2) + v - v**3, 0),
    domain=pm.FreeSpace(x),
    guess={v: 1.2 * sp.exp(-(x**2) / 2)},
)

From this starting value the method finds \(\sqrt2/\cosh x\). From zero it would stay at zero, which solves the equation as well, and pdemagic says so instead of returning it.

The plan names the start in its notes. The method cannot tell whether other solutions exist.

When it fails

Newton’s method does not always arrive. pdemagic then raises ConvergenceError and returns nothing:

  • The residual does not reach the tolerance within the steps that the plan allows.

  • No fraction of a step reduces the residual. The method is stuck, usually because the starting value is too far from any solution, or because the equation has none.

  • The method cannot leave its starting value. The linear equation there has no unique solution. \(u^3 = 1\) linearized at zero is \(0 \cdot u = 1\). On a periodic domain this happens when the unknown appears in derivatives only and the slope of the nonlinear term vanishes at the start. Another starting value helps.

Accuracy

For the manufactured solution \(u = 1.5\,e^{-r^2}\) of the Poisson–Boltzmann equation in the plane:

Points per axis

Error

24

8.5e-7

32

6.7e-11

40

4.8e-13

Each of these took 4 steps of Newton’s method and 8 steps of GMRES in all. A stronger nonlinearity takes more: 5 and 18 for a solution that reaches 4, and 8 and 66 for one that reaches 8, where \(\sinh u\) is in the thousands.

What the planner chooses

  • The box holds the source, the starting value, and the region where the coefficients of the linearized equation differ from the constants they settle to.

  • The grid resolves all of these.

  • The method runs to a residual of \(10^{-10}\), relative to the larger of the source and the effective source, in at most 50 steps of at most 200 steps of GMRES each. All three are entries of the plan.

The planner cannot know how far the solution reaches. If the nonlinear term matters beyond the box, the effective source does not vanish on its faces, and source_boundary_ratio says so. Widen the box in the plan then.

Diagnostics

Entry

Meaning

newton_steps

The steps of Newton’s method.

iterations

The steps of GMRES in all of them together.

residual

The residual of the nonlinear equation that was reached.

source_boundary_ratio

Covers the effective source. Not tiny: the solution has outgrown the box.

solution_tail

How far the spectrum of the effective source has decayed. Not tiny: the grid is too coarse for the solution.

Limits

  • The nonlinear term is a function of the unknown itself. A derivative of the unknown inside a nonlinear term, as in \(u\,u_x\) or \(|\nabla u|^2\), is not handled.

  • The term must have a slope. For a complex unknown that rules out its magnitude, its conjugate, and its real and imaginary parts.

  • The linear part is one that the iteration takes, with the same conditions on its coefficients.

  • One unknown, in free space or on a periodic box. On a region of the plane the same Newton’s method runs on a direct solve: see spectral elements, and between walls and on round domains on the iteration for coefficients that vary there: see collocation.

  • No search for solutions. One starting value gives at most one solution. Branches of solutions are not followed.