A harbour

Swell that enters a harbour through its mouth, spreads behind the quay, passes an island and runs out on the beach.

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

x, y = sp.symbols("x y", real=True)
h = sp.Function("h")(x, y)
k = 12
quay = curves.Polygon((-2, 0), (2, 0), (2, 2), (0.3, 2), (-0.3, 2), (-2, 2))
island = curves.Circle((0.5, 0.9), 0.3)
beach, mouth = quay.sides[0], quay.sides[3]

leaving = pm.normal_derivative(h) - sp.I * k * h
shore = dict.fromkeys([*quay.sides, island], sp.Eq(pm.normal_derivative(h), 0))
shore[beach] = sp.Eq(leaving, 0)
shore[mouth] = sp.Eq(leaving, -2 * sp.I * k)

swell = pm.Problem(
    sp.Eq(pm.laplacian(h) + k**2 * h, 0),
    domain=pm.Region(x, y, quay, island),
    boundary=shore,
)
pm.solve(swell).plot(part="real")
The figure that the example above draws. The figure that the example above draws.

What it shows

The Helmholtz equation on a region of the plane, for the height \(h\) of waves of one period on the water of a harbour. The sides of the polygon are pieces of the boundary, and each takes its own condition, also two pieces of one straight line: the quay at the top has a mouth in its middle. The quays and the island are hard walls, with no slope along the normal, and on the beach at the bottom \(\partial h/\partial n - ikh = 0\) lets the waves out. At the mouth the same expression is given the value \(-2ik\), which sends in a wave of height one and lets out what comes back. The mouth is about as wide as a wave is long, so the swell spreads in all directions behind it. The island scatters it, and behind the island the water is calmer.

What pdemagic decided

The planner chose spectral elements (spectral_elements): 135 quadrilaterals with polynomials of degree 10. The plan also says what limits the accuracy. At the two ends of the mouth what is given jumps, and the solution has a singularity there, so that a higher degree gains little. Solved again on a mesh four times as fine, the heights change in the fourth or fifth decimal place.

More