# Methods How pdemagic solves what it solves. You do not need these pages to use it: the planner picks the method. They are for when you want to know what happens, how accurate it is, and where its limits are. Each page states the equation, explains the method, gives measured errors and costs, and lists the limits. ## Which method is used when | Problem | Method | Accuracy | |---|---|---| | Poisson's equation in free space, with periodic directions | [Fourier convolution with a truncated Green's function](fourier-poisson.md) | spectral | | Screened Poisson equations, and any linear equation on a periodic box | [The same, with other symbols](linear-fourier.md) | spectral | | The Helmholtz equation in free space | [Convolution with the outgoing Green's function](helmholtz.md) | spectral | | Equations on boxes with boundary conditions, stationary and in time | [Collocation, in the modes of each axis](collocation.md) | spectral, exact in time where the equation is linear | | The same on disks, rings, balls, shells and cylinders | [Collocation along the radius, with waves or harmonics along the angles](round-domains.md) | spectral, exact in time where the equation is linear | | Linear equations of second order on a region of the plane that curves bound: Laplace, Poisson, Helmholtz, and the same in a medium, with drift, with a potential, with directions that differ | [Spectral elements](spectral-elements.md) | spectral, where the solution is smooth up to the boundary | | Heat, waves and the Schrödinger equation on such a region | [The modes of the shape, from spectral elements](elements-in-time.md) | spectral, exact in time | | Poisson's equation in disks and balls with vacuum outside | [Angular harmonics and radial Green's functions](harmonics-poisson.md) | spectral | | Poisson's equation in finite cylinders with vacuum outside | [Surface values and finite differences](cylinder-poisson.md) | second order | | Linear equations whose coefficients vary in space, in free space and on periodic boxes: a permittivity, a potential, a medium for waves | [Iteration on the solver for constant coefficients](varying-coefficients.md) | spectral | | The same between walls and on round domains | [Iteration on collocation](iteration-between-walls.md) | spectral | | Nonlinear stationary equations in free space and on periodic boxes: Poisson–Boltzmann, ground states | [Newton's method on that iteration](newton.md) | spectral | | Nonlinear stationary equations on a region of the plane | [Newton's method on spectral elements](element-newton.md) | spectral | | The plate equation on a box, with two conditions on each face | [Two equations of second order, joined on the faces](plate-equation.md) | spectral | | Nonlinear stationary equations between walls and on round domains | [Newton's method on collocation](iteration-between-walls.md#nonlinear-equations) | spectral | | Poisson's equation around conductors and sharp dielectrics | [Boundary elements](boundary-poisson.md) | second order | | Linear equations in time, in free space and on periodic boxes: heat, waves, Schrödinger | [Exact propagation in Fourier space](propagator.md) | spectral, exact in time | | Nonlinear equations in time, on periodic boxes, on boxes and round domains with boundary conditions, and on regions of the plane | [Exponential time stepping](exponential.md) | spectral, fourth order in time | | Systems of equations | [One small matrix per Fourier wave](coupled.md) | spectral | | Systems in time on boxes and round domains with boundary conditions | [Each unknown in its own modes, stepped together](systems-between-walls.md) | spectral, fourth order in time | | Stationary systems on a region of the plane | [Spectral elements, with all unknowns in one matrix](element-systems.md) | spectral | | The lowest eigenvalues of a Schrödinger operator on a periodic box | [A block iteration on the action of the operator](subspace.md) | spectral | | The lowest modes of a box or a round domain with boundary conditions | [The modes of collocation, sorted](cavity-modes.md) | spectral | | The lowest modes of a box or a round domain with a medium, a potential of any form or a mixed derivative, and of a plate | [An iteration on the stationary solve](inverse-modes.md) | spectral | | The lowest modes of a region of the plane | [The same block iteration, on the stationary solve of spectral elements](element-modes.md) | spectral | ## Values between the points of a grid A solution comes on a grid, and has a value at any other point of its domain too: `solution(x, y)`. That value is not interpolated from the neighbours of the point. It is the value of the expansion that the method solved with, read off the values on the grid, which hold all of it: - **Along a periodic axis**, the trigonometric sum through the points of the axis. With an even number of points the highest wave is taken as a cosine, which is all that the points see of it. - **Along an axis between walls, and along a radius**, the polynomial through the points of the axis: Chebyshev points, which include the walls, or Gauss points, which lie inside, so that the polynomial also gives the values on the rim of a disk and at its centre. - **On a region of the plane**, the polynomials of the elements: see [spectral elements](element-grids.md#values-anywhere). The axes of a grid are taken one after the other. For a wave that the grid holds the result is exact up to rounding: a sum of three waves on a periodic grid of 12 by 12 points comes out to $2\cdot10^{-13}$ at random points, and a solution between walls to $10^{-13}$, also on the walls. A value sums over the whole grid, so a thousand points on a grid of $64^3$ take a tenth of a second. The integral of a solution over its domain, `solution.integral()`, is taken by the quadrature of the same points: equal weights along a periodic axis, the weights of Gauss or of Clenshaw and Curtis along the others, the radius or its square as the measure of polar, cylindrical and spherical coordinates, and on a region the areas that the points of the elements stand for. For a resolved solution it is exact up to rounding: $\pi/8$ for the membrane on a disk comes out to $10^{-14}$ on a grid in polar coordinates and on elements alike. Where a direction is free there are no such values yet. The grid is then a cut out of all of space, and the method summed its waves over a larger, padded box that is not kept. In a ball the polar angle has an axis of neither kind, and the cylinder with vacuum outside is solved by finite differences. ## What the methods have in common - **Free space is exact.** No method cuts the domain off at an artificial boundary and puts a condition there. The condition at infinity is built into a Green's function, or into the padding of a transform. A boundary is there only when the problem has one. - **What can be exact, is.** Linear parts with constant coefficients are inverted or propagated exactly, wave by wave or mode by mode. Only what cannot be treated that way is discretized. - **The planner's choices are data.** The method, the grid and every tolerance are entries of a [plan](../topics/planner.md), and can be changed. ```{toctree} :hidden: fourier-poisson linear-fourier helmholtz collocation round-domains iteration-between-walls plate-equation cavity-modes inverse-modes spectral-elements element-corners element-grids element-systems element-newton elements-in-time element-modes harmonics-poisson cylinder-poisson varying-coefficients newton boundary-poisson propagator exponential coupled systems-between-walls subspace ```