M51. Integrals of a solution

Package: K6, its third part: solution.integral() gives the integral of an unknown over the domain, by the quadrature of the grid or of the elements that the method solved with.

What was built

  • Grid::integrals: the weights of every axis, multiplied, times what a cell of the coordinates is worth in space.

  • shaped::integrals: on a shape, the values at the points of the elements times the areas that the points stand for. The elements of a plan are now built again in one place, for values at points and for integrals.

  • integrals in the core, which picks the measure by the coordinates of the domain: 1 in Cartesian ones, the radius in polar and cylindrical ones, its square in spherical ones, where the weights of the polar angle integrate over its cosine.

  • solution.integral(unknown=None) in Python: a number, or one for each recorded time.

What it reaches

Problem

Exact

Error

The membrane on a disk, on elements

\(\pi/8\)

\(4\cdot10^{-15}\)

The same on a grid in polar coordinates

\(\pi/8\)

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

\((1 - r^2)/6\) in a ball

\(4\pi/45\)

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

\((1 - r^2)/4\) along a cylinder of the length 2

\(\pi/4\)

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

A wave beside a constant on a periodic square

\(8\pi^2\)

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

\(\sin 3x\,e^{y}\) between walls

by sympy

\(10^{-14}\)

Heat in a disk that lets none out, at 21 times

the same at all

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

The L-shape with eight layers of elements towards its corner has the area 3 to \(10^{-12}\).

Decisions

D51.1. The quadrature of the method

Developer, 2026-11-19.

An integral is taken with the weights that belong to the points of the solution: those of the trapezoidal rule along a uniform axis, which on a periodic axis are exact for every wave that the points hold, those of Gauss and of Clenshaw and Curtis along their axes, and on a shape the areas of the elements. Nothing is interpolated first. The error is that of the solution.

D51.2. The measure belongs to the coordinates

Developer, 2026-11-19.

In a disk the integral is over the area, and in a ball over the volume: the factor that the coordinates bring is applied, and the user does not write it. That is what “the integral over the domain” means, and it is what makes the heat in a ball a number that is conserved.

D51.3. Where a direction is free, over the box

Developer, 2026-11-19.

A potential in free space falls off too slowly to have an integral over all of space, and a solution that does have one is known on its box only. So the integral is over the box of the grid, and the documentation says so. It is not refused: the integral of a wave packet or of a density over a box that holds it is what one wants.

What is left

  • Integrals of expressions in a solution: its square, its energy.

  • The gradient of a solution, and the flux through a face or a piece of a boundary.