Choose and inspect a grid

The spatial dependence of a field suggests a natural choice of grid. When spherical symmetry removes the angular dependence, a radial grid can represent the field economically through a single coordinate. Retaining that dependence calls for a full spherical grid, while a two-centre geometry often benefits from prolate coordinates and their angular sectors. Although the coordinate arrays differ, all three grids expose the same sampling, integration, differentiation, and Poisson operations, allowing you to carry familiar numerical ideas from one geometry to another.

Grid

Field array indices

Coordinates available when sampling

RadialGrid

(r,)

r

SphericalGrid

(r, theta, phi)

r, theta, phi, x, y, z, rho

ProlateGrid

(xi, eta)

xi, eta, r_a, r_b, r, rho, z

from flodi import RadialGrid, SphericalGrid, ProlateGrid

radial = RadialGrid.uniform(n_r=120, r_max=5.0)
spherical = SphericalGrid.uniform(
    n_r=16, n_theta=10, n_phi=12, r_max=5.0
)
prolate = ProlateGrid.uniform(
    n_xi=18, n_eta=14, xi_max=5.0, distance=2.0
)
print(radial.shape, spherical.shape, prolate.shape)

These modest dimensions demonstrate construction. For your investigation, use the assignment’s grid requirements and compare resolutions and domain sizes as you assess the numerical approximation.

Centres, faces, and physical volumes

A uniform step is convenient for arranging samples, but its physical meaning depends on the coordinates. In a radial grid, for example, equally thick shells occupy more volume as their radius increases. FLODI therefore stores the physical volume represented by each sample separately from the coordinate spacing. Inspecting grid.shape, grid.cell_volumes, and the coordinate arrays helps you see how the weighted integral represents the geometry before you use it in a calculation.

One radial cell between two faces, with its centre highlighted.

Field values live at cell centres; boundary values live on faces.

On a radial grid, r_faces marks the shell boundaries and domain endpoints, while r records the centres where the field is sampled. Consequently, the outer face lies half a cell width beyond the last stored centre value. This layout differs from the endpoint grid used for the reduced radial equation; the comparison in Representations and normalization helps you keep the two representations consistent when moving between them.

Grid geometry is fixed after construction. To change the domain, resolution, or centre separation, construct a new grid and sample the functions there. Fields from two separately constructed grids cannot be combined directly, even when their shapes agree.

Two-centre coordinates

The prolate constructor’s distance is the separation \(D\) of the foci, with \(a=D/2\). Focus A lies at \(z=-a\) and focus B at \(z=+a\). The coordinates satisfy

\[\xi=\frac{r_A+r_B}{D},\qquad \eta=\frac{r_A-r_B}{D},\qquad z=a\xi\eta,\qquad \rho=a\sqrt{(\xi^2-1)(1-\eta^2)}.\]

These relations give the coordinate names their geometric meaning: r_a and r_b measure distance to the two foci, r measures from the midpoint, and rho measures the perpendicular distance from the bond axis. In particular, this geometric \(\rho\) is distinct from the total electron density, which the assignment denotes by \(n\). Keeping the meanings explicit helps when translating an expression written in distances into a callable on the grid.

The outer face xi_max is an ellipsoid, not a sphere of radius xi_max. Its axial and equatorial radii are \(a\xi_{\max}\) and \(a\sqrt{\xi_{\max}^2-1}\). Changing distance changes the physical region even when xi_max and the array shape stay fixed.

Refinement and domain extension

On a radial grid, the cell width is \(R/N_r\). On a prolate grid,

\[\Delta\xi=\frac{\xi_{\max}-1}{N_\xi},\qquad \Delta\eta=\frac{2}{N_\eta}.\]

To test coordinate resolution, hold the domain and geometry fixed and reduce the steps. To test the outer boundary, extend the domain while keeping the steps fixed as closely as possible. Record the actual steps, including any rounding needed for integer cell counts, so that you can interpret what changed in each comparison.