# A room with an open window A steady tone in a long room with hard walls, whose far side is open and lets the sound out. ```python import sympy as sp import pdemagic as pm x, y = sp.symbols("x y", real=True) p = sp.Function("p")(x, y) k = 9 room = pm.Box({x: (0, 3), y: (0, 1)}) walls = dict.fromkeys(room.faces, sp.Eq(pm.normal_derivative(p), 0)) walls[x, 3] = sp.Eq(p.diff(x) - sp.I * k * p, 0) voice = sp.exp(-100 * ((x - 0.5) ** 2 + (y - 0.4) ** 2)) sound = pm.Problem( sp.Eq(pm.laplacian(p) + k**2 * p, -voice), domain=room, boundary=walls ) pm.solve(sound).plot(part="real") ``` ## What it shows The Helmholtz equation on a box with walls, with a source inside: a voice near the left end of the room. Three walls are hard, which for sound means no slope of the pressure across them. The fourth side is a window as large as the wall. The condition there has a complex coefficient, $\partial p/\partial x - i k p = 0$: a wave that meets the face head-on leaves through it and is not reflected. A wave that meets it at an angle is reflected in part. The solution is complex, and the picture shows its real part, the pressure at one instant: crests and troughs that follow each other from the voice to the window. ## What pdemagic decided The planner chose collocation at Chebyshev points (`collocation`). A condition with a complex coefficient is a mix of value and derivative like any other, and the solve is direct. The grid has 256 by 85 points, the coarsest candidate that resolves the solution and the source to $10^{-10}$. ## More - [Waves of one frequency](../topics/helmholtz.md) - [Let waves out through a wall](../howto/a-wall-that-lets-waves-out.md) - [Collocation on boxes with boundary conditions](../methods/collocation.md) - [What is solved on boxes with walls](../ref/equations-boxes.md)