The methods of a plan¶
Every value that plan.method.kind takes, with the parameters that
stand beside it and the problems that get it, and the other parts of a
plan: the grid, the times and the notes.
The parts of a plan¶
import sympy as sp
import pdemagic as pm
x, t = sp.symbols("x t", real=True)
u = sp.Function("u")(x, t)
rod = pm.Problem(
sp.Eq(u.diff(t), u.diff(x, 2)),
domain=pm.Box({x: (0, 1)}),
time=(t, 0, 0.1),
initial={u: sp.sin(sp.pi * x)},
boundary=sp.Eq(u, 0),
)
print(pm.plan(rod))
method:
kind: mode_propagator
steps: 1
grid:
lower: [0.0]
upper: [1.0]
shape: [24]
periodic: [False]
rules:
- chebyshev
times:
start: 0.0
end: 0.1
count: 21
notes:
- The equation is of first order in time, with a linear operator of second order with constant coefficients in space, on a 1-dimensional box.
- Boundary conditions: the value at x = 0, the value at x = 1.
- Method: exact propagation in the modes of the box, with Chebyshev points along the axes with faces.
- Grid: the coarsest candidate on which the spectrum of the solution and of what is given falls below 1e-10 at high frequencies.
- Time: recorded at 21 times. Nothing that is given depends on time, so each of them is exact in time.
Entry |
Meaning |
|---|---|
|
The method: one of the kinds below. It must suit the problem. |
|
The parameters of that kind. A kind without parameters has none. |
|
The first and the last point along each axis, in the coordinates of the domain. Along a periodic axis they are the ends of one period. |
|
The number of points along each axis. |
|
Which axes are periodic. An empty list means none. |
|
How the points of each axis are placed. The entry is missing where every axis is uniform. |
|
For a problem in time: the solution is recorded at |
|
What the planner found and why it chose what it chose, in words. They have no effect on the solve. |
Every entry is read and set as an attribute, as in
plan.grid.shape = (96, 96) or plan.times.count = 5. Only the entries
that a plan holds can be set: plan.method.tolerance exists for the
kinds that have a tolerance.
The rules of a grid¶
Rule |
Where the points lie |
Used along |
|---|---|---|
|
Equally spaced. Along a periodic axis they start at |
free and periodic axes, angles around an axis, the grid over a region |
|
Chebyshev points of the second kind: both ends are included, and the points crowd towards them. |
an axis of a box that ends in faces, the axis of a cylinder with conditions |
|
The nodes of the Gauss–Legendre rule, strictly inside the bounds. |
the radius of a disk, a ball and a cylinder with conditions, and of a disk and a ball with vacuum outside |
|
The angles whose cosines are the Gauss–Legendre nodes. |
the polar angle of a ball |
|
The midpoints of equal cells, half a step inside the bounds. |
the radius and the axis of a cylinder with vacuum outside |
What the grid means¶
Domain |
The grid |
|---|---|
free directions |
A box that the planner puts around the sources, the initial state or the bound states. The diagnostics tell whether it was large enough. |
a box, a round domain |
The domain itself, in its own coordinates. |
a region |
Equally spaced points over the rectangle that holds the region, where the solution is given: see grids on a shape. It does not affect the accuracy: |
bodies |
Where the solution is evaluated. The accuracy depends on |
The kinds¶
In free space and on periodic boxes:
Kind |
Problems that get it |
Parameters |
How it works |
|---|---|---|---|
|
Poisson, screened Poisson and Helmholtz with free and periodic directions. Any linear equation with constant coefficients, and stationary linear systems, on a domain that is periodic in every direction. |
none |
|
|
Linear stationary equations with coefficients that vary in space. |
|
|
|
Stationary equations with a term that is nonlinear in the unknown. |
|
|
|
Linear equations and systems in time with constant coefficients. |
|
|
|
Equations and systems in time with nonlinear terms or coefficients that vary. Also on boxes and round domains with conditions. |
|
|
|
Eigenproblems. |
|
|
|
Poisson’s equation around conductors and dielectrics, in free space in three dimensions. |
|
On boxes with walls and on round domains with conditions:
Kind |
Problems that get it |
Parameters |
How it works |
|---|---|---|---|
|
Linear stationary equations of second order with constant coefficients. |
none |
|
|
Stationary equations with coefficients that vary, and on a box with a mixed derivative. |
|
|
|
Stationary equations with a term that is nonlinear in the unknown. |
|
|
|
The plate equation on a box. |
none |
|
|
Linear equations of first and second order in time with constant coefficients. |
|
|
|
Equations in time with nonlinear terms or coefficients that vary: of first order, of second order on periodic domains and between walls, and systems of them. |
|
|
|
Eigenproblems whose modes are products of the modes of the axes. |
none |
|
|
Every other eigenproblem: a medium, a potential of any form, a mixed derivative, a plate. |
none |
On round domains with vacuum outside:
Kind |
Problems that get it |
Parameters |
How it works |
|---|---|---|---|
|
Poisson’s equation in a disk or a ball. |
none |
|
|
Poisson’s equation in a cylinder. |
none |
On regions of the plane:
Kind |
Problems that get it |
Parameters |
How it works |
|---|---|---|---|
|
Linear stationary equations and systems. |
|
|
|
Stationary equations and systems with nonlinear terms. |
|
|
|
Linear equations of first and second order in time that are exact in the modes of the shape. |
|
|
|
Equations of first and second order in time with terms that are stepped, and systems of equations of first order. |
|
|
|
Eigenproblems. |
|
Which forms of an equation each kind takes is on the pages of what is solved where.
The parameters¶
“The planner’s value” is what pm.plan returns.
Iterations¶
Kind |
Parameter |
Meaning |
The planner’s value |
|---|---|---|---|
|
|
The iteration stops when the residual has fallen to this fraction of the right-hand side. |
|
|
The most steps before the iteration gives up. |
200 |
|
|
|
The iteration stops when the residual of every eigenfunction has fallen to this fraction of the largest eigenvalue. |
|
|
The most iterations before it gives up. |
500 |
Newton’s method¶
Kind |
Parameter |
Meaning |
The planner’s value |
|---|---|---|---|
|
|
The method stops when the residual of the equation has fallen to this fraction of the larger of the source and the effective source. |
|
|
|
The same, as a fraction of the larger of the source and the nonlinear term. |
|
all three |
|
The most steps of Newton’s method before it gives up. |
50 |
|
|
The most steps of the iteration within one step of Newton’s method. On a region each step is solved directly. |
200 |
Time¶
Kind |
Parameter |
Meaning |
The planner’s value |
|---|---|---|---|
|
|
The number of steps between two recorded times. It only matters for a source or for boundary values that depend on time, which are interpolated in time within each step. |
1, and more where something that is given depends on time |
|
|
The error of a single step, relative to the size of the solution, that is accepted. |
|
|
The most steps between two recorded times before the stepping gives up. |
1048576 |
Elements and panels¶
Kind |
Parameter |
Meaning |
The planner’s value |
|---|---|---|---|
|
|
The degree of the polynomials on each quadrilateral, in both directions. The accuracy is raised by it. |
chosen for each problem |
|
About how long the sides of the triangles are that the quadrilaterals are cut from, three from each. |
chosen for each problem |
|
|
|
The number of layers of elements that shrink towards each corner of the boundary at which the solution has a singularity, each half the size of the one before. Zero for a mesh that takes no notice of corners. |
chosen for each problem, zero for a shape without such a corner |
|
|
About how many triangles the surfaces of all bodies that are given as shapes are divided into, together. A body given as a mesh keeps its own triangles. |
1000 |
What a plan may hold at most is on the page of known limits, under “Size and speed”.
See also: The planner and its plan,
pm.Plan and the
diagnostics that each method reports.