M74. Nonlinear waves between walls

Package: A14: nonlinear equations of second order in time on boxes and round domains with boundary conditions. With the driver of milestone 73 they are solved on regions of the plane as well.

What was built

  • An equation of second order in time takes terms that are stepped, on every domain that has modes: \(u_{tt} + \gamma\,u_t = A u + N\), with \(A\) the operator that the modes hold and \(N\) terms that are nonlinear or have coefficients that vary. The sine-Gordon equation between walls, a drum whose spring hardens, a membrane of any shape with a cubic term. Until now such an equation was solved on periodic domains alone, as a system.

  • The module methods::blocked. The exponential scheme with a matrix for each member of a basis, where exponential has a number. It was a part of coupled_stepping, written for the waves of a periodic grid. Now periodic systems and the modes of a domain use the same code.

  • in_modes::step_second. The state is the coefficients of the unknown and those of its rate of change, and the matrix of a mode is \(\begin{pmatrix} 0 & 1 \\ \sigma & -\gamma \end{pmatrix}\). It is written once, and bounded_evolution and shaped_evolution call it with what their unknown is given.

  • The pages for users. The topic page on nonlinear equations in time has a section on waves between walls, the reference lists the form for boxes, round domains and regions, the method page explains the matrix of a mode with the errors below, and the gallery has a kink that turns over at a free end.

Decisions

D74.1. A matrix of two by two for each mode, and the linear part stays exact

Developer, 2026-11-25.

There were two ways. The rate of change could have been one more unknown, with the operator among the terms that are stepped: no new code, and steps as short as the fastest mode of the grid asks, which between Chebyshev points is the fourth power of their number. Or the operator stays exact, which needs the exponential of the matrix that couples a coefficient and its rate. That exponential is the cosine and the sine of the mode with their decay, and the scheme of Cox and Matthews needs three more functions of the same matrix.

Periodic systems had all of it, for a matrix of any size for each wave. So it was moved, and not written again: methods::blocked holds the coefficients, the step and the control of the step for a state of several components, and takes a function that evaluates what is stepped. A wave and a mode are the same to it. The results of periodic systems are the same to the last bit.

D74.2. A region gets what the box gets, apart from a drift

Developer, 2026-11-25.

On a region a term that is stepped beside a second derivative in time was refused in three places: when the equation was read, for a potential whose phase differs from that of the second derivatives, and when a plan asked for stepping. With the driver all three are lifted by the one function that the box calls too. A plan that steps is taken for a wave equation with nothing to step as well, where it agrees with the propagator to eight digits.

A drift that the modes of a shape do not hold is still refused beside a second derivative in time. It could be stepped now. But such an equation grows at a rate of half the drift, and what a user who writes it means is better asked than assumed. It is left with A4.

What was measured

Against manufactured solutions, with the planner’s choices:

Problem

Error

Steps

\(u_{tt} + \tfrac12 u_t = u_{xx} - \sin u + f\) on \([0, 1]\), to the time 2

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

80

\(u_{tt} = \nabla^2 u - u^3 + f\) on the unit disk, to the time 2

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

148

\(u_{tt} + \tfrac12 u_t = \nabla^2 u - u^3 + f\) on the unit square as a region, to the time 1

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

40

The order in time, for the first of them with steps of equal length: \(1.6\cdot10^{-5}\), \(6.8\cdot10^{-7}\), \(2.4\cdot10^{-8}\) and \(7.6\cdot10^{-10}\) with 4, 8, 16 and 32 steps. Half the step leaves between a 23rd and a 31st of the error. The tests assert a sixteenth, on the string and on the region.

A kink of the sine-Gordon equation on a line of the length 24 with free ends, followed for 40 units of time through its reflection: 740 steps and 5.4 seconds, on 256 points. It is the new case box_sine_gordon_1d of the benchmarks. The sine takes 78 % of that time, in the interpreter of expressions, and the transforms between points and modes 18 %: the matrices of the modes do not show.

The 24 problems of milestones 72 and 73 give the same bytes as on main.

What was left

  • A value that is held on a wall and is not zero costs many steps, here as in an equation of first order (C18). The same kink between two ends that are held at \(0\) and \(2\pi\) takes 17 900 steps where the free ends take 740.

  • Systems with an equation of second order in time between walls and on regions are refused as before. They need the matrix of a mode for each unknown of the system, beside the numbers of the others (A23).

  • A derivative in time inside a term that is stepped, as a damping that varies, is refused (H8).

  • The planner’s grids end at 256 points along a side. A kink on a long line is resolved to \(4\cdot10^{-8}\) on that, which the plan says.