Nonlinear equations in time

This page explains how pdemagic solves

\[\frac{\partial u}{\partial t} = A u + N(u, \mathbf{x}, t)\]

on a periodic box. Boxes and round domains with boundary conditions, and regions of the plane, are stepped in their modes, by a scheme that keeps its order there: see between walls. \(A\) is a linear operator with constant coefficients, as in the linear case. \(N\) is everything else on the right-hand side: terms that are nonlinear in \(u\) and its derivatives in space, linear terms whose coefficients vary, and the source.

Burgers’ equation \(u_t + u u_x = \nu u_{xx}\), the Korteweg–de Vries equation \(u_t + 6 u u_x + u_{xxx} = 0\) and reaction–diffusion equations such as \(u_t = D \nabla^2 u + u - u^3\) are of this kind. So are, with a complex unknown, the Schrödinger equation with a potential, \(i u_t = -\tfrac12 u_{xx} + V(x) u\), and the nonlinear Schrödinger equation \(i u_t = -\tfrac12 u_{xx} - |u|^2 u\).

The method

The linear part is often stiff. The second derivative of the heat equation limits an explicit scheme to steps proportional to the square of the grid spacing, the third derivative of the Korteweg–de Vries equation to its cube.

pdemagic therefore treats \(A\) exactly, wave by wave, as in the linear case, and approximates only \(N\) in time. The scheme is the exponential Runge–Kutta scheme of fourth order by Cox and Matthews (J. Comput. Phys. 176, 2002). The length of a step is then limited by how fast \(N\) changes, and not by \(A\).

Space

\(N\) is evaluated pseudo-spectrally. Derivatives are taken in Fourier space, and products are formed at the grid points. A derivative may act on the unknown or on any expression in it, so the term \(u u_x\) can as well be written in its conservative form \(\partial_x (u^2/2)\).

A product of two fields that the grid resolves contains waves that the grid cannot hold. They would fold back onto waves that it can. The upper third of the wave numbers of \(N\) is therefore removed in every evaluation. For quadratic terms that is exact (the 2/3 rule).

Step control

Every step is taken twice: once whole, and once as two halves. The difference estimates the error of the step. If it exceeds the tolerance, the step is halved. If it is far below, the step is doubled. The two halves and the whole step are then combined into a result of fifth order.

Steps are always the time between two recorded times divided by a power of two. A step is therefore never longer than the time between two recorded times.

Between walls

On a box with boundary conditions, a round domain and a region of the plane, the equation is stepped in the modes of the domain, in which \(A\) with its conditions is a number for every mode. Two things are different from a periodic box, and each costs a scheme its order unless it is taken care of.

The term does not obey the conditions. The solution vanishes at a wall that holds it at zero, and \(N\) in general does not: a source does not, and neither does \(x\,u_x\). The order of the scheme of Cox and Matthews rests on a term that is as tame as the solution. Where it is not, the fastest modes are fed at every stage, and the scheme falls to the second order. pdemagic therefore steps in modes by the exponential Runge–Kutta scheme of Hochbruck and Ostermann (SIAM J. Numer. Anal. 43, 2005), whose conditions on its weights hold for every mode, however fast it decays. It evaluates \(N\) five times in a step where the scheme of Cox and Matthews evaluates it four times.

What a wall is given drives the modes. A value or a flux that is given on a face enters the equation of the modes as one more source, which is large for the fast modes. A scheme that steps it with \(N\) falls to the third order where it depends on time. It is known ahead, as a function of the time alone, so it is not stepped: within a step it is the cubic polynomial through its values at four points in time, and the operator acts on that exactly, mode by mode, as in the linear case. \(N\) is stepped for what is left.

With both, a system of two unknowns on \([0, 1]\), one that diffuses and one that does not, has these orders in time, for steps of equal length up to the time 1. Two half steps and a whole one are combined, which gives the fifth order where everything is smooth:

What the walls do

Order of the unknown that diffuses

Of the other

hold it at zero, and \(N\) is zero there

5

5

hold it at zero, and \(N\) is not zero there

3.5 to 4

4

let nothing through, and the slope of \(N\) is zero there

5

5

let nothing through, and the slope of \(N\) is not zero there

5

5

hold it at values that decay

5

4

are given a flux that decays

5

4

The scheme of Cox and Matthews had the second order for the unknown that does not diffuse in the second row. And with what the walls are given stepped beside \(N\), both unknowns had the third order in the fifth row.

An equation of second order in time is stepped with a matrix of two by two for each mode, by the scheme of Cox and Matthews, which kept its order there in every case that was measured: a wave does not damp its fast modes. What its walls are given is integrated exactly in the same way.

Accuracy

For Burgers’ equation with \(\nu = 0.3\), whose exact solution follows from the Cole–Hopf transformation, on 64 points up to \(t = 2\) with 21 recorded times:

Tolerance of a step

Error

Steps

1e-6

1.2e-9

20

1e-8

1.3e-10

29

1e-10

1.5e-12

74

1e-12

2.2e-13

160

The tolerance bounds the error of a single step relative to the size of the solution. Here the error at the end is well below it, because the solution decays. In general the errors of the steps add up.

A soliton of the Korteweg–de Vries equation on 256 points keeps its shape to 1.4e-11 over four units of time, in 640 steps of 0.006. The third derivative would limit an explicit scheme of fourth order to steps of 0.0015 on that grid, for stability alone.

What the planner chooses

  • The grid resolves the initial state, and has at least 32 points along its longest side.

  • The tolerance of a step is \(10^{-10}\) of the size of the solution.

  • The recorded times are 21, as in the linear case.

The grid can become too coarse

A nonlinear equation creates waves that its initial state does not have. Burgers’ equation with a small viscosity steepens into a front, for example. The planner sees only the initial state.

The diagnostics therefore report solution_tail: how much of the solution at the end lies in the highest waves that the method keeps, as a fraction of its largest Fourier coefficient. A value that is not tiny means that the grid has become too coarse, and that grid.shape in the plan should be raised.

If the solution ceases to exist, as for \(u_t = u^2\), the steps shrink without end. pdemagic then stops with ConvergenceError when a step would need more than max_steps parts of the time between two recorded times.

Free directions

In free space the solution leaves the box, and the exact propagation follows it on a padded transform. A term that is stepped can be followed in the same way if it acts only where its coefficient is: a term that is linear in the unknown, with a coefficient that settles to a constant away from the box. A potential in the Schrödinger equation is the main example, \(i\,\partial_t \psi = -\tfrac12 \nabla^2 \psi + V(\mathbf{x})\,\psi\) with a well or a barrier \(V\).

The constant that a coefficient settles to is made part of \(A\), the operator with constant coefficients: \(c(\mathbf{x})\,u\) is \(c_\infty u + (c(\mathbf{x}) - c_\infty)\,u\), and only the second part is stepped. It vanishes away from where the coefficient varies. The constant is read off the faces of the box, and it must not depend on time.

The state is then the transform on the padded box, \(A\) is propagated exactly on it, and what is left of the term is evaluated on the grid of the box.

The padding must hold everything that travels, and a term can make the solution faster:

  • A first derivative with the coefficient \(b(\mathbf{x})\) moves the solution with the velocity \(-b_\infty\) that it settles to, and by up to \(\max |b - b_\infty|\) more.

  • A potential keeps \(d\,k^2 + V\) along the way of a wave in \(\partial_t u = i\,d\,\nabla^2 u - i\,V u\). A wave with the wave number \(k\) that runs down the whole range of the potential leaves with \(\sqrt{k^2 + \text{range}(V)/|d|}\).

The padding is planned with these. Only the unknown itself and its first derivatives may carry such coefficients, because for them it is known how far the solution travels.

A packet that meets a barrier, on a box that it leaves, agrees with the same packet on a ring that is long enough to hold all of it to \(10^{-7}\), and the bound state \(1/\cosh x\) of the well \(-1/\cosh^2 x\) keeps its shape and turns its phase to \(10^{-8}\). A potential that is lifted by a constant gives the same wave function with its phase turned, to \(10^{-8}\).

Cost

A step costs twelve evaluations of \(N\), and an evaluation costs one transform per derivative in \(N\) and two more. The parts of \(N\) that depend on neither the time nor the unknown, such as a potential, are sampled once before the first step. The Korteweg–de Vries example above takes 0.2 seconds.

Second order in time, in modes

On a box, a round domain or a region with boundary conditions,

\[\frac{\partial^2 u}{\partial t^2} + \gamma\,\frac{\partial u}{\partial t} = A u + N(u, \mathbf{x}, t)\]

is stepped as well. In the modes of the domain \(A\) is diagonal, with an eigenvalue \(\sigma\) for each mode. The state of a mode is its coefficient \(y\) and the rate of change \(z\) of that coefficient, and the linear part couples the two:

\[\begin{split}\frac{d}{dt}\begin{pmatrix} y \\ z \end{pmatrix} = \begin{pmatrix} 0 & 1 \\ \sigma & -\gamma \end{pmatrix} \begin{pmatrix} y \\ z \end{pmatrix} + \begin{pmatrix} 0 \\ n \end{pmatrix}\end{split}\]

with \(n\) the coefficient of \(N\), and of what the boundary is given where that does not depend on time. The scheme is that of Cox and Matthews, with this matrix for each mode where an equation of first order has the number \(\sigma\): its exponential, the cosine and the sine of the mode with their decay, takes the place of \(e^{\sigma h}\). So the wave equation is exact, however fine the grid, and a step is as long as \(N\) allows. Periodic systems are stepped with the same matrices, one for each wave: see systems.

For the sine-Gordon equation with a damping and a source, \(u_{tt} + \tfrac12 u_t = u_{xx} - \sin u + f\) on \([0, 1]\) with zero at both ends and the solution \(\cos 2t\,\sin \pi x\), up to the time 2:

Steps of equal length

Error

4

\(1.6\cdot10^{-5}\)

8

\(6.8\cdot10^{-7}\)

16

\(2.4\cdot10^{-8}\)

32

\(7.6\cdot10^{-10}\)

Half the step leaves between a 23rd and a 31st of the error: the scheme is of fourth order, and the result of each step is corrected by the difference of a whole step and two halves. With the planner’s tolerance the error is \(8\cdot10^{-12}\) after 80 steps. The same equation with a cubic term in the place of the sine is solved to \(5\cdot10^{-13}\) on a disk and to \(9\cdot10^{-10}\) on a square that is a region.

Limits

  • Nonlinear terms need a domain that is periodic in every direction, or a box or a round domain with boundary conditions. With free directions the solution leaves the box, and a nonlinear term would have to be followed outside it. On a box with boundary conditions the scheme for walls steps in the modes of the box, and on a round domain in theirs, there for terms without derivatives: see collocation. On a region of the plane it steps in the modes of the shape, for terms with the unknown and its first derivatives: see spectral elements.

  • With free directions, the terms that are stepped must act in the box. See the section above.

  • Systems are stepped in the same way, on a periodic domain with a matrix per wave: see systems. Between walls each unknown of a system is stepped in its own modes: see systems between walls.

  • In an equation of second order in time, what is stepped holds no derivative in time. A damping that varies is not taken.

  • No shocks. A solution that develops a discontinuity cannot be resolved by a spectral method on any grid.