API Reference

Core Classes

Core HarmonicMeasure class.

class harmonic_measure.core.HarmonicMeasure(geometry, panels_per_quadrant=4, nodes_per_panel=16, beta=None, _disc=None, _solver=None)[source]

Bases: object

Harmonic measure computation for 2D domains.

Parameters:
  • geometry (Superellipse or PanelDiscretization) – Domain boundary. If Superellipse, will create panel discretization.

  • panels_per_quadrant (int) – Panels per quadrant (if geometry is Superellipse)

  • nodes_per_panel (int) – Gauss-Legendre nodes per panel

  • beta (float) – Corner refinement parameter

  • _disc (PanelDiscretization | None)

  • _solver (DoubleLayerLaplace | None)

Examples

>>> curve = Superellipse(p=16)
>>> hm = HarmonicMeasure(curve)
>>> omega = hm.measure_corners([0, 0], radius=0.1)
geometry: Superellipse | PanelDiscretization
panels_per_quadrant: int = 4
nodes_per_panel: int = 16
beta: float | None = None
property discretization: PanelDiscretization
property solver: DoubleLayerLaplace
measure_subset(basepoint, subset_fn, smooth=True, delta=None)[source]

Compute harmonic measure of a boundary subset.

Parameters:
  • basepoint (array-like, shape (2,)) – Interior point from which to compute harmonic measure

  • subset_fn (callable or ndarray) – If callable: returns True for points in subset If ndarray: directly provides boundary data values

  • smooth (bool) – If True and subset_fn is callable, use smoothed indicator

  • delta (float, optional) – Smoothing width (default: auto-computed)

Returns:

omega – Harmonic measure ω(basepoint, subset)

Return type:

float

measure_corners(basepoint, radius, corners=None)[source]

Compute harmonic measure of corner neighborhoods.

Parameters:
  • basepoint (array-like, shape (2,)) – Interior point

  • radius (float) – Neighborhood radius around each corner

  • corners (list of (x, y), optional) – Corner locations. Default: (±1, ±a) for Lamé curves

Returns:

omega – Total harmonic measure of all corner neighborhoods

Return type:

float

density(basepoint)[source]

Compute harmonic measure density at each boundary node.

The density ρ satisfies: ω(z, A) ≈ ∫_A ρ(s) ds

Parameters:

basepoint (array-like, shape (2,)) – Interior point

Returns:

rho – Density at each boundary node

Return type:

ndarray, shape (N,)

plot_density(basepoint, ax=None, cmap='viridis')[source]

Plot harmonic measure density on the boundary.

Requires matplotlib.

Parameters:

Boundary Data

Boundary data utilities for harmonic measure computation.

harmonic_measure.boundary_data.sigmoid(t)[source]

Standard sigmoid function σ(t) = 1 / (1 + e^{-t}).

Parameters:

t (float | ndarray[tuple[Any, ...], dtype[_ScalarT]])

Return type:

float | ndarray[tuple[Any, …], dtype[_ScalarT]]

harmonic_measure.boundary_data.smooth_indicator(inside, delta=0.1)[source]

Convert boolean to smooth indicator value.

Returns ~1 if inside, ~0 if not, with transition width delta.

Parameters:
Return type:

float

harmonic_measure.boundary_data.smooth_corner_indicator(pts, corners, radius, delta=None)[source]

Smooth indicator for corner neighborhoods.

g(ξ) = σ((ρ - d(ξ)) / δ)

where d(ξ) is distance to nearest corner.

Parameters:
  • pts (ndarray, shape (N, 2)) – Boundary points

  • corners (list of (x, y)) – Corner locations

  • radius (float) – Neighborhood radius ρ

  • delta (float, optional) – Smoothing width (default: radius/5)

Returns:

g – Smooth indicator values

Return type:

ndarray, shape (N,)

harmonic_measure.boundary_data.corner_boundary_data(pts, a, rho, delta=None)[source]

Standard corner indicator for Lamé curves.

Corners are at (±1, ±a).

Parameters:
  • pts (ndarray, shape (N, 2)) – Boundary points

  • a (float) – Aspect ratio (y semi-axis)

  • rho (float) – Corner neighborhood radius

  • delta (float, optional) – Smoothing width

Returns:

g – Boundary data values

Return type:

ndarray, shape (N,)

Diagnostics

Diagnostics for boundary crowding and convergence.

class harmonic_measure.diagnostics.RefinementRecord(round=0, panels_per_quadrant=0, m_per_panel=0, beta=0.0, n_nodes=0, arc_len=0.0, delta_abs=None, delta_rel=None)[source]

Bases: object

Record of a single refinement step.

Parameters:
round: int = 0
panels_per_quadrant: int = 0
m_per_panel: int = 0
beta: float = 0.0
n_nodes: int = 0
arc_len: float = 0.0
delta_abs: float | None = None
delta_rel: float | None = None
harmonic_measure.diagnostics.corner_arc_len_once(n, a, c, *, beta, panels_per_quadrant, m_per_panel)[source]

Single discretization solve for corner harmonic mass.

Parameters:
  • n (int) – Lamé exponent (p = 2n)

  • a (float) – Aspect ratio

  • c (float) – Corner radius parameter (ρ = c/n)

  • beta (float) – Corner refinement parameter

  • panels_per_quadrant (int) – Number of panels per quadrant

  • m_per_panel (int) – Gauss-Legendre nodes per panel

Returns:

  • arc_len (float) – Corner arc length ≈ 2π u(0)

  • u0 (float) – Harmonic measure u(0)

  • n_nodes (int) – Total number of boundary nodes

Return type:

tuple[float, float, int]

harmonic_measure.diagnostics.corner_arc_len_converged(n, a, c, *, tol=1e-08, quality='mid', max_rounds=10, verbose=False)[source]

Adaptively refine until corner harmonic mass converges.

Uses “no whammies” approach: increase discretization parameters until the quantity of interest stabilizes.

Parameters:
  • n (int) – Lamé exponent (p = 2n)

  • a (float) – Aspect ratio

  • c (float) – Corner radius parameter

  • tol (float) – Convergence tolerance (absolute or relative)

  • quality (str) – ‘fast’, ‘mid’, or ‘high’ - affects initial parameters

  • max_rounds (int) – Maximum refinement rounds

  • verbose (bool) – Print progress

Returns:

  • arc_len (float) – Converged corner arc length

  • u0 (float) – Converged harmonic measure u(0)

  • final_params (dict) – Final discretization parameters

  • history (list[RefinementRecord]) – Refinement history

Return type:

tuple[float, float, dict, list[RefinementRecord]]

harmonic_measure.diagnostics.adaptive_convergence(n, a, c, tol=1e-10, verbose=False)[source]

Convenience wrapper for corner_arc_len_converged.

Returns just the arc length and history.

Parameters:
Return type:

tuple[float, list[RefinementRecord]]

harmonic_measure.diagnostics.corner_scaling_diagnostic(ns, a=1.0, c=2.0, tol=1e-08, verbose=False)[source]

Compute corner harmonic mass across a range of Lamé exponents.

Fits log(arc_len) ~ slope * log(n) to estimate scaling exponent.

Parameters:
  • ns (list of int) – Lamé exponents to test

  • a (float) – Aspect ratio

  • c (float) – Corner radius parameter

  • tol (float) – Convergence tolerance

  • verbose (bool) – Print progress

Returns:

  • ns (ndarray) – Exponent values

  • arc_lens (ndarray) – Corner arc lengths

  • slope (float) – Fitted slope (should be ≈ -2 for right-angle corners)

Return type:

tuple[ndarray[tuple[Any, …], dtype[_ScalarT]], ndarray[tuple[Any, …], dtype[_ScalarT]], float]