/ concept-collection / fastandaccurate
Sign in
concept-collection / fastandaccurate
fastandaccurate / docs / problems / laplace-dirichlet-2d.md
120 lines · 5.1 KBPreviewCodeBlameHistoryRaw
1# Problem: laplace-dirichlet-2d (version 1)
3This document is the canonical statement of the problem. Results refer to
4it by the pair (problem id, problem version); any change that could alter
5a measured number requires a version bump.
7## The problem
9Solve the Laplace equation
11 Δu = 0 in Ω, u = g on ∂Ω,
13where Ω is the star-shaped plane domain bounded by the curve
15 x(t) = r(t) (cos t, sin t), r(t) = 1 + a cos(k t), t ∈ [0, 2π),
17and g is Dirichlet data specified below. The problem is posed in the
18continuum: a solver receives the curve and the data as functions, chooses
19its own discretization, and is scored on the values it returns at a fixed
20set of evaluation points.
22## The exact solution
24The data g is manufactured from an exact harmonic function, a sum of
25three logarithmic point sources placed outside the domain:
27 u*(x) = Σ_j c_j log |x − s_j|, c = (1.0, −0.6, 0.8).
29Source s_j is the boundary point at parameter φ_j = 2π(j−1)/3 + 0.4
30pushed a distance d along the outward unit normal, and g = u* restricted
31to ∂Ω. Since u* is harmonic in Ω, it is the unique solution, and errors
32are measured against it directly rather than against a reference
33computation. The distance d controls difficulty: u* continues
34harmonically only up to the sources, so the smaller d, the shorter the
35distance the data continues past the boundary, and methods whose
36representations assume a generous continuation lose it. A solver must
37not use knowledge of the sources; they exist only to manufacture g.
39## Official instances
41| id | a | k | d | character |
42|---|---|---|---|---|
43| disk-easy | 0 | 0 | 0.5 | the unit disk, distant sources |
44| star-medium | 0.2 | 3 | 0.4 | mild geometry, comfortable continuation |
45| star-hard | 0.3 | 5 | 0.08 | wavy boundary, data barely continues |
47Committed results exist only at these instances, so every solver is
48compared on identical inputs. The parameters may be varied freely in the
49site's interactive views, but such runs are not recorded.
51## What is scored
53Each instance fixes 289 evaluation points: 32 rays at angles
54θ_j = 2πj/32 + 0.13 (j = 0, …, 31), radial fractions
55ρ ∈ {0.1, 0.2, …, 0.9} along each ray (the point at fraction ρ on ray
56θ is ρ r(θ) (cos θ, sin θ)), ordered radius-major, plus the origin last.
57The solver returns u at exactly these points. Reported errors are
59 relMax = max_i |u_i − u*_i| / max_i |u*_i|,
60 relL2 = ( Σ_i (u_i − u*_i)² / Σ_i u*_i² )^{1/2}.
62relMax is the headline number; both are recorded. Note that the
63evaluation points deliberately stay a modest distance inside the domain
64(fraction 0.9 at most). Accuracy very close to the boundary is a genuine
65and separate difficulty (the close-evaluation problem for integral
66methods, boundary-layer resolution for grid methods) and a future
67problem version may add a near-boundary target set; version 1 does not
68test it.
70## Timing protocol
72One run is a full call of the solver, including its own discretization,
73assembly, solve, and evaluation. The harness performs one untimed warmup
74run (which absorbs numbl's JIT compilation and is recorded separately as
75the cold time), then N timed runs (N = 3 unless stated), and reports the
76median as the solve time. All timing is tic/toc inside the MATLAB
77session, so browser and node runs measure the same thing. Times from
78different machines are not comparable; every result records its
79environment, and comparisons across environments are the reader's
80responsibility.
82## Solver interface
84A solver is a MATLAB function file
86 function out = solver(prob, n)
88where n is the solver's own resolution parameter (its meaning is the
89solver's choice; the standard sweep list is declared in the solver's
90manifest) and prob is a struct with fields
92| field | meaning |
93|---|---|
94| `prob.curve` | `@(t) -> [x y]`, boundary point at parameter t (column vectors in, m×2 out) |
95| `prob.curveD` | first derivative of the curve with respect to t |
96| `prob.curveDD` | second derivative |
97| `prob.g` | `@(t) -> g`, Dirichlet data at boundary parameter t |
98| `prob.evalXY` | 289×2, the evaluation points |
99| `prob.vizXY` | m×2, visualization grid points (m = 0 when not requested) |
101The return value is a struct: `out.uEval` (289×1, required) and
102`out.uGrid` (m×1; `[]` when `prob.vizXY` is empty). The solver must not
103reconstruct the sources analytically or otherwise special-case the known
104solution; submissions are reviewed for this.
106## Visualization grid
108When requested, `prob.vizXY` lists a 200×200 grid of points over the
109bounding square [−R, R]², R = 1.05(1 + |a|), with flat index
110p = ix·200 + iy for x = xs[ix], y = xs[iy] (y varies fastest, MATLAB
111meshgrid column order). Points outside Ω are included and the viewer
112masks them; grid values are never scored.
114## Limitations
116The exact solution is smooth and free of boundary singularities, so this
117problem does not test corner handling, nonsmooth data, or interior
118sources (a nonzero right-hand side would exclude plain boundary-integral
119methods; that belongs to a different problem). The domain family is
120star-shaped by construction, which some methods can exploit.
moveopenescclose