Read what was decided¶
Use this when you want to know which method, box and grid pdemagic chose for a problem, before or after solving it.
Steps¶
Before solving, ask for the plan:
pm.plan(problem). After solving, the solution carries the plan that produced it:solution.plan.Print it. The entries under
method,gridandtimesare what will be executed. Thenotessay in words what the planner found and why it chose so.Read single entries as attributes:
plan.method.kind,plan.grid.shape,plan.notes.
Example¶
import sympy as sp
import pdemagic as pm
x, y = sp.symbols("x y", real=True)
u = sp.Function("u")(x, y)
problem = pm.Problem(
sp.Eq(pm.laplacian(u), -sp.exp(-(x**2 + y**2) / 2)),
domain=pm.FreeSpace(x, y),
)
plan = pm.plan(problem)
print(plan)
method:
kind: fourier
grid:
lower: [-7.434343434343434, -7.434343434343434]
upper: [7.434343434343436, 7.434343434343436]
shape: [64, 64]
periodic: [False, False]
notes:
- The equation is a Poisson equation in 2-dimensional free space.
- Box: chosen so that the source falls to 1e-12 of the maximum at the faces.
- Grid: the coarsest candidate on which the spectrum of the source falls below 1e-10 at high frequencies.
The same entries, one by one, and the plan of a solution:
assert plan.method.kind == "fourier"
assert plan.grid.shape == [64, 64]
assert plan.notes[0].startswith("The equation is a Poisson equation")
solution = pm.solve(problem)
assert solution.plan.to_json() == plan.to_json()
Notes¶
The notes are the first place to look when a result surprises you. A note with the words
NOT resolvedmeans that the planner could not resolve the problem by itself: see What to do when a plan says NOT resolved.What a plan holds depends on the problem: a problem in time has
times, an iteration amethod.tolerance, a shape in the plane amethod.degree. The methods of a plan lists every entry.The notes are the planner’s words about its own choice. They do not change when you change an entry: a last note then names the entries that you set, as in “Changed after planning: grid.shape”.
A disk, a ball or a cylinder without boundary conditions is solved with vacuum outside, and only the plan says so.
plan.to_dict()gives the plan as a dictionary andplan.to_json()as text: see Reuse a plan.How far the result can be trusted is not in the plan but in
solution.diagnostics: see Get more digits. The planner and its plan explains how the choices are made.