API Reference

Geometry Protocol

Geometry protocol and utilities.

class panel_bie.geometry.Geometry(*args, **kwargs)[source]

Bases: Protocol

Protocol for boundary geometry discretizations.

Any object providing these attributes is compatible with panel-bie solvers. The superellipse.PanelDiscretization class implements this protocol.

property points: ndarray[tuple[Any, ...], dtype[floating]]

Boundary nodes, shape (N, 2).

property normals: ndarray[tuple[Any, ...], dtype[floating]]

Outward unit normals, shape (N, 2).

property weights: ndarray[tuple[Any, ...], dtype[floating]]

Quadrature weights (ds measure), shape (N,).

property curvature: ndarray[tuple[Any, ...], dtype[floating]]

Signed curvature at each node, shape (N,).

panel_bie.geometry.validate_geometry(geom)[source]

Validate geometry object has correct shapes and properties.

Parameters:

geom (Geometry)

Return type:

None

Kernel Functions

Kernel functions for boundary integral operators.

panel_bie.kernels.laplace_single_layer_kernel(x, y)[source]

Single-layer kernel G(x,y) = (1/2π) log|x-y| for 2D Laplace.

Parameters:
  • x (array, shape (2,)) – Target point

  • y (array, shape (2,)) – Source point

Returns:

Kernel value (undefined for x == y)

Return type:

float

panel_bie.kernels.laplace_double_layer_kernel(x, y, n_y)[source]

Double-layer kernel ∂G/∂n_y for 2D Laplace.

∂G/∂n_y = (1/2π) * (x - y) · n_y / |x - y|²

Parameters:
  • x (array, shape (2,)) – Target point

  • y (array, shape (2,)) – Source point

  • n_y (array, shape (2,)) – Outward unit normal at y

Returns:

Kernel value (undefined for x == y)

Return type:

float

panel_bie.kernels.laplace_double_layer_diagonal(kappa)[source]

Diagonal limit of double-layer kernel for smooth curve.

lim_{y→x} ∂G(x,y)/∂n_y = κ(x) / 4π

where κ is the signed curvature.

Parameters:

kappa (float)

Return type:

float

panel_bie.kernels.laplace_single_layer_matrix(targets, sources, weights)[source]

Assemble single-layer operator matrix.

A[i,j] = G(x_i, y_j) * w_j

Parameters:
  • targets (array, shape (M, 2)) – Target points

  • sources (array, shape (N, 2)) – Source points

  • weights (array, shape (N,)) – Quadrature weights

Returns:

A – Operator matrix

Return type:

array, shape (M, N)

panel_bie.kernels.laplace_double_layer_matrix(targets, sources, normals, weights, curvature=None, same_points=False)[source]

Assemble double-layer operator matrix.

A[i,j] = ∂G(x_i, y_j)/∂n_j * w_j (off-diagonal) A[i,i] = κ_i / 4π * w_i (diagonal, if same_points)

Parameters:
  • targets (array, shape (M, 2)) – Target points

  • sources (array, shape (N, 2)) – Source points (boundary nodes)

  • normals (array, shape (N, 2)) – Outward unit normals at sources

  • weights (array, shape (N,)) – Quadrature weights

  • curvature (array, shape (N,), optional) – Signed curvature at sources (required if same_points=True)

  • same_points (bool) – If True, targets == sources and diagonal correction is applied

Returns:

A – Operator matrix

Return type:

array, shape (M, N)

Laplace Solver

Laplace equation solvers using boundary integral methods.

class panel_bie.laplace.DoubleLayerLaplace(geometry, _A=None)[source]

Bases: object

Double-layer potential solver for interior Dirichlet problems.

Solves: Δu = 0 in Ω, u = g on ∂Ω

Using representation: u(x) = ∫_∂Ω μ(y) ∂G(x,y)/∂n_y ds_y

The density μ satisfies: (-½I + K)μ = g

Parameters:

Examples

>>> from superellipse import Superellipse
>>> curve = Superellipse(p=8)
>>> disc = curve.panel_discretization()
>>> solver = DoubleLayerLaplace(disc)
>>> mu = solver.solve(lambda pt: pt[0])  # u = x on boundary
>>> u_0 = solver.evaluate(mu, [0, 0])
geometry: Geometry
property n_nodes: int
assemble()[source]

Assemble the discretized operator matrix (-½I + K).

Returns:

A – Discretized integral operator

Return type:

ndarray, shape (N, N)

solve(g)[source]

Solve for density μ given boundary data g.

Parameters:

g (callable or ndarray) – If callable: g(point) returns boundary value at point If ndarray: directly provides values at boundary nodes

Returns:

mu – Solution density

Return type:

ndarray, shape (N,)

evaluate(mu, point)[source]

Evaluate solution at an interior point.

Parameters:
  • mu (ndarray, shape (N,)) – Solution density from solve()

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

Returns:

u – Solution value at point

Return type:

float

evaluate_grid(mu, grid, mask=None)[source]

Evaluate solution on a grid of points.

Parameters:
  • mu (ndarray, shape (N,)) – Solution density

  • grid (ndarray, shape (M, 2)) – Evaluation points

  • mask (ndarray, shape (M,), optional) – Boolean mask; only evaluate where True

Returns:

u – Solution values (NaN where mask is False)

Return type:

ndarray, shape (M,)

class panel_bie.laplace.SingleLayerLaplace(geometry, _A=None)[source]

Bases: object

Single-layer potential solver for exterior/Neumann problems.

Uses representation: u(x) = ∫_∂Ω σ(y) G(x,y) ds_y

Parameters:
geometry: Geometry
property n_nodes: int
assemble()[source]

Assemble the single-layer operator matrix.

Return type:

ndarray[tuple[Any, …], dtype[floating]]

evaluate(sigma, point)[source]

Evaluate single-layer potential at a point.

Parameters:
Return type:

float