Poisson’s equation in a finite cylinder

This page explains how pdemagic solves

\[-\nabla^2 u = g \quad \text{with } g = 0 \text{ outside a finite cylinder},\]

stated in cylindrical coordinates \((\rho, \varphi, z)\). The solution is the free-space one, on a grid that follows the cylinder, and the source may reach right up to its surface.

Why a different method

In a ball the free-space Green’s function separates, and the vacuum outside can be built into a radial integral (disks and balls). A finite cylinder has edges, and nothing separates outside it. The method therefore works in two steps: it first computes the solution on the surface, and then solves a boundary value problem inside.

This method discretizes the equation by finite differences and is second-order accurate. Only it and the boundary elements are: the others are spectral.

Step 1: the solution on the surface

On the surface the solution is the Green’s function integral over the source,

\[u(\mathbf{x}) = \int \frac{g(\mathbf{y})}{4\pi \lvert \mathbf{x} - \mathbf{y} \rvert}\, \mathrm{d}\mathbf{y},\]

evaluated with the midpoint rule on the cells of the grid. Surface points are at least half a cell away from every cell centre, so the integrand is finite, and the rule is second-order accurate up to a logarithm of the cell size.

The cylinder is symmetric under rotation, which makes the integral over the angle a convolution. An FFT turns it into a product per azimuthal order, for each pair of a ring on the surface and a ring of source cells.

One detail decides the accuracy. Between rings that are close, the kernel is sharply peaked in the angle, far more sharply than the angular grid of the solution can show. The kernel is therefore sampled as finely as its peak demands, up to several thousand points for neighbouring rings, and only the orders the solution has are kept. Without this, the error would not fall as the cells shrink.

Step 2: the inside

With the surface values known, the inside is a boundary value problem. It is discretized by second-order finite differences at the centres of cells along \(\rho\) and \(z\). Centres avoid the axis, where the coordinates are singular, and the prescribed surface values enter through mirror cells.

Per azimuthal order the linear system is solved directly, without iteration:

  • a sine transform diagonalizes the differences along the axis;

  • what remains is one tridiagonal system along the radius per axial mode.

Accuracy

Errors fall with the square of the cell size. Measured in the tests:

Cells along the radius and the axis

Uniformly charged cylinder, on the axis

Gaussian charge inside, relative

16

6.2e-4

2.1e-2

32

1.7e-4

6.3e-3

64

4.5e-5

1.6e-3

The uniformly charged cylinder is the harder case in principle, because the source reaches the surface. It is compared with the closed form of its potential on the axis. The Gaussian is narrow, which is why its errors are larger at the same cell size.

Along the angle the method is spectral.

What the planner chooses

  • Cells. 48 along the longer of the radius and the height, and cells of about the same size along the other. This is a fixed default: the planner does not estimate the error of a second-order method. Refine with grid.shape.

  • Angle. The fewest of 8, 16, 32, 64, 128 or 256 points at which the spectrum of the source along the angle has decayed to \(10^{-10}\).

Limits

  • The full solid cylinder around the \(z\) axis, with vacuum outside. With a condition on each of its surfaces, a cylinder, solid or hollow, is solved spectrally by collocation, on another grid.

  • Second order. A spectral method for vacuum outside is possible and would be the way to more digits.

  • The surface integral costs a number of operations that grows with the fifth power of the number of cells along one direction. It is fine for the default grid and noticeable beyond a hundred cells.