M42. Derivatives in terms that are stepped, on a shape

Package: A4, its seventh part: in time on a region of the plane, a term that is stepped may hold a first derivative of the unknown. That covers drift, and terms such as \(u\,u_x\).

What was built

  • The derivative of a field on elements (Elements::derivative_of): within an element that of its polynomial, and at a point that elements share the mean of theirs, weighted with the areas that the point stands for.

  • The terms of the stepper, at points that are no grid. The terms that are stepped on a shape are now the staged terms of the exponential scheme (exponential::Term), which periodic boxes and boxes with walls use. They are evaluated at the points of the elements by Term::evaluate_where, and their steady parts are sampled once by Term::given_where. Until now a shape compiled a program of its own, which could read the unknown and nothing else.

  • Drift is stepped. In an equation of first order in time the first derivatives with constant coefficients are taken out of the operator and stepped with the other terms. They were refused.

  • What is refused, and where. A derivative above the first order in a term that is stepped, also as a derivative of a derivative, a Laplacian, a gradient or a divergence of the unknown there. The plan refuses it, not the solve.

  • The plan says it: a note on the method names the derivatives.

What it reaches

All against exact solutions, on meshes with the spacing 1.

Problem

Degree

Tolerance

Error

Steps

\(u_t = \nabla^2 u - 2u_x\) on a triangle, value on the sides

2

\(10^{-9}\)

\(2.1\cdot10^{-3}\)

320

4

\(10^{-9}\)

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

640

6

\(10^{-9}\)

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

1 280

8, the planner’s choice

\(10^{-10}\)

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

5 120

A front of Burgers’ equation on a disk with a hole

3

\(10^{-8}\)

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

160

4

\(10^{-8}\)

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

320

5

\(10^{-8}\)

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

320

6

\(10^{-10}\)

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

2 560

The planner’s choice for the triangle takes 37 s, and a drift of 20 in place of 2 takes 20 480 steps and 143 s. A blob that a rotation carries a quarter turn through a disk, with a diffusion of 1/50, takes 166 steps and 2.3 s at degree 6.

Decisions

D42.1. The derivative at a shared point is the mean, weighted with the areas

Developer, 2026-11-19.

The polynomials of two elements agree along their common side, and their derivatives across it do not. At a shared point the derivative is the mean over the elements, weighted with the area that the point stands for in each. This is no choice of convenience: it is the weak form of the term, tested with the polynomials of the elements, integrated with the points of the elements, and divided by the area of the point, which is what the modes of the shape are built from (the mass is diagonal). A term that is nonlinear in the derivative is evaluated with this mean, not averaged after it is evaluated. The two differ by the square of the jump, which falls with the error of the elements.

D42.2. A shape steps the terms of the stepper

Developer, 2026-11-19.

A shape now compiles its stepped terms as every other domain does, into stages: a derivative, of the unknown or of an expression, is a stage whose result the next stage reads. The evaluation takes a function that samples a program at all points, so that the points need not be a grid. A derivative of an expression, such as \((u^2/2)_x\), came with it.

D42.3. Drift is stepped, also with constant coefficients

Developer, 2026-11-19.

A drift with constant coefficients is linear and could be propagated exactly. It is stepped all the same: the modes of a shape are those of a symmetric matrix, which the Laplacian with its conditions gives, and a drift makes the operator non-symmetric, with modes that are not orthogonal and may be badly conditioned. Stepping it was one line. The price is in the table above: thousands of steps where the drift is as strong as the diffusion. Propagating it exactly is recorded as open in A4.

In an equation of second order in time nothing is stepped on a domain with walls, so a drift is still refused there.

D42.4. First derivatives only

Developer, 2026-11-19.

A second derivative in a stepped term could be taken as the mean of the derivative of a mean. That is not the weak form of a second derivative: it leaves out what the boundary adds, so a condition on the slope would not act on that term, and it squares the crowding of the points in the size of the steps. A medium or directions that differ in time need the weak form, and are left as the next part of A4. The refusal looks at how the term is written, so that a derivative of a derivative does not pass as two first ones.

What is left

  • A4: second derivatives in stepped terms, drift that is propagated, systems, arrays as data, corners in time.

  • Terms that are stepped in an equation of second order in time, on any domain with walls.