What to do when a plan says NOT resolved

Use this when a note of the plan holds the words NOT resolved: the planner tried its finest grid, and the spectrum of the solution or of what is given still had not decayed.

Steps

  1. Read the note. It names what is not resolved, how far the spectrum fell, and the entry of the plan that refines: grid.shape, method.degree, method.spacing or method.steps.

  2. Look for the cause in the problem. Most often it is a singularity: values on two faces that disagree in the corner where they meet, a jump in what is given, a corner that points into a shape.

  3. If the cause is not meant, remove it: give values that fit in the corners.

  4. If it is meant, decide what you need. Away from the singularity the solution is still right to several digits. Refine with the entry that the note names, solve again, and compare the values that matter to you.

Example

A plate that is held at 1 along its top and at 0 on the other faces. The values jump in the two upper corners:

import sympy as sp
import pdemagic as pm
from pdemagic import curves

x, y = sp.symbols("x y", real=True)
u = sp.Function("u")(x, y)
laplace = sp.Eq(pm.laplacian(u), 0)
box = pm.Box({x: (0, 1), y: (0, 1)})

conditions = dict.fromkeys(box.faces, sp.Eq(u, 0))
conditions[y, 1] = sp.Eq(u, 1)
jumping = pm.solve(pm.Problem(laplace, domain=box, boundary=conditions))

assert "NOT resolved" in jumping.plan.notes[2]
assert jumping.plan.grid.shape == [256, 256]  # the finest automatic candidate
assert jumping.diagnostics["solution_tail"] > 1e-4
# In the middle the value is 1/4, by symmetry. Five digits are right.
assert 1e-6 < abs(jumping(0.5, 0.5) - 0.25) < 1e-5

# Values that fit in the corners are resolved on 24 by 24 points.
conditions[y, 1] = sp.Eq(u, sp.sin(sp.pi * x))
fitting = pm.plan(pm.Problem(laplace, domain=box, boundary=conditions))
assert fitting.grid.shape == [24, 24]
assert not any("NOT resolved" in note for note in fitting.notes)

# The jump on a shape in the plane: elements keep its harm near the corners.
square = curves.Polygon((0, 0), (1, 0), (1, 1), (0, 1))
sides = dict.fromkeys(square.sides, sp.Eq(u, 0))
sides[square.sides[2]] = sp.Eq(u, 1)  # the top
on_elements = pm.solve(
    pm.Problem(laplace, domain=pm.Region(x, y, square), boundary=sides)
)
assert abs(on_elements(0.5, 0.5) - 0.25) < 1e-10

Notes

  • On a box every point of the grid feels a singularity, and the error falls slowly with the grid: here by four for twice the points along each axis.

  • A weaker note says that finer grids gain little, because the solution has a kink or a singularity. A membrane under an even load on a square gets it: its corners leave the spectrum at about \(10^{-8}\), and the value in its middle is still right to ten digits.

  • On a shape in the plane the planner looks for corners that point inwards and lets the mesh shrink towards them, which keeps ten digits. It does not look for jumps in what is given: within a few hundredths of the two corners the solution above is not right.

  • NOT resolved in time is about a source or boundary values that depend on time: raise method.steps.

  • A source or an initial state that is not smooth loses the fast convergence on every grid. Shocks are out of reach for these methods.

  • Accuracy and diagnostics explains the measures, and Known limits lists what loses digits without an error.