M63. Coefficients that vary, between walls

Package: A8: a stationary equation on a box with walls or on a round domain whose coefficients vary in space, such as \(\nabla\cdot(\varepsilon(\mathbf{x})\nabla u) + c(\mathbf{x})\,u = f\). The direct solver for constant coefficients there becomes the preconditioner of an iteration, as in free space since milestone 22.

What was built

  • bounded_varying: the summands of a stationary equation that are no terms with constant coefficients are read as linear terms with coefficients that vary. Their means over the domain join the operator that the modes hold. What is left is a remainder, which is evaluated at the points of the grid.

  • The iteration: GMRES on the effective source, with one direct solve and one evaluation of the remainder in each step. The equation is divided by the coefficient of its second derivatives first.

  • On a box any coefficient may vary: a medium inside a divergence, the coefficient of a second or a first derivative along one axis, and a potential. On a disk, a ring, a ball, a shell and a cylinder the term without derivatives may.

  • The method collocation_iterative in a plan, with the tolerance and the most steps of the iteration, and the diagnostics iterations and residual.

  • Refused, with the reason: a nonlinear stationary equation, a coefficient from an array, a coefficient that varies in front of a mixed derivative or of one above the second order, an equation that is not elliptic, and one that leaves its solution open up to a constant.

What it reaches

On the unit square, with the value given on its sides, for a solution that is known:

Equation

Grid

Steps

Largest error

Time

\(\nabla\cdot(\varepsilon\nabla u) = f\), \(\varepsilon = 10^{xy}\)

\(24^2\)

10

\(10^{-12}\)

0.01 s

The same, \(\varepsilon = 100^{xy}\)

\(24^2\)

17

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

0.02 s

The same, \(\varepsilon = 1000^{xy}\)

\(32^2\)

27

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

0.03 s

\(\varepsilon = 2 + \sin 6x\cos 5y\)

\(32^2\)

11

\(10^{-12}\)

0.03 s

\((1 + x^2)u_{xx} + (2 + \cos y)u_{yy} + x\,u_y - (1 + y)u = f\)

\(24^2\)

11

\(10^{-11}\)

0.01 s

\(\nabla^2 u + 20(1 + \tfrac12\sin 3x)\,u = f\)

\(24^2\)

7

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

0.01 s

A medium in the unit cube

\(24^3\)

7

\(6\cdot10^{-14}\)

0.2 s

The unit disk, a loss that varies

\(16\times32\)

4

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

0.01 s

A can, a loss that varies

\(24\times48\times48\)

6

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

0.1 s

The tests check a medium along a string, with the error falling by more than fifty from 8 points to 12 and again to 16, an equation whose every coefficient varies with a mix of the value and the slope at one end, a medium and a loss on a plate with a slope given on one side, a medium across a duct that is periodic along its length, a medium that varies by a factor of 55 and one that is complex, and a loss that varies on a disk, in a ball and in a can.

Decisions

D63.1. The iteration of free space, on the solver of the domain

Developer, 2026-11-20.

Milestone 22 solves an equation with coefficients that vary by an iteration on the solver for constant coefficients, which in free space is a convolution. Between walls that solver is the solve in the modes of the box, and the iteration is the same: a reference operator with constant coefficients, the effective source as the unknown, GMRES. The remainder is evaluated by the code that evaluates the stepped terms of an equation in time on the same grid, with the derivatives of collocation. Nothing of the method is new, and that is why the first run of every test passed.

D63.2. The mean stands for a coefficient

Developer, 2026-11-20.

In free space the value that stands for a coefficient is the one it settles to far away, which the far field needs. A box has no far field, and the mean over the domain is taken: it leaves a remainder that is small in the mean, and the scaling does the rest. The means are taken at eight points along each coordinate when the equation is read, since the operator of the modes, and whether the solution is fixed, must be known before there is a grid.

D63.3. Divided by the coefficient of the second derivatives

Developer, 2026-11-20.

Without the scaling the iteration sees the ratio of the medium to its mean, and takes a number of steps that grows with the root of the contrast. Divided by that ratio, the equation has second derivatives with constant coefficients, and what varies is of lower order: a medium that varies by a factor of a thousand takes 27 steps where one that varies by ten takes 10. The division is by the values at the points, and no formula is rearranged.

D63.4. A medium is taken as it is written

Developer, 2026-11-20.

The remainder of \(\nabla\cdot(\varepsilon\nabla u)\) is evaluated as a divergence of a flux: the slopes of the unknown, times the medium at the points, differentiated again. To expand it into \(\varepsilon\nabla^2 u + \nabla\varepsilon\cdot\nabla u\) would need the derivative of the medium, by a formula or by the grid. As written it needs neither.

D63.5. On a round domain, the term without derivatives

Developer, 2026-11-20.

The derivatives of a field on the grid of a round domain are not taken: the stepped terms of an equation in time have the same limit there (package A15). A potential needs none, and is taken on a disk, a ring, a ball, a shell and a cylinder. A medium on a round domain waits for A15.

What is left

  • A coefficient from an array.

  • A solution that is fixed up to a constant.

  • A medium on a round domain, with A15.

  • Nonlinear stationary equations between walls: A9, by Newton’s method on this iteration.

  • An eigenvalue iteration on this solve, for a potential that couples the coordinates.