Waves in a square with Neumann boundary conditions @NilsBerglund
Waves in a square with Neumann boundary conditions  @NilsBerglund
Uploaded May 2026 | Updated November 2026, 16 hours ago
Having tested Neumann versus Dirichlet boundary conditions in a certain number of geometries, I now sufficiently trust my algorithm to make some simulations with only Neumann boundary conditions, though they do show some unphysical dissipation. This one is in a square, and can be compared to the particle simulation youtu.be/XCqQNJcrEdw
Dirichlet boundary conditions, meaning that the wave height is zero at the boundary of the domain, are a good model for an elastic membrane, for instance for a drum, or for sound waves. For water waves, however, it is be realistic to use Neumann boundary conditions, meaning the the wave height has a horizontal tangent at the boundary.
Dirichlet boundary conditions are very easy to implement in a finite difference scheme: it suffices to keep the wave height equal to zero outside the domain, and use this zero value when computing the discrete Laplacian. For Neumann boundary conditions, however, one has to implement the condition that the normal derivative of the wave height is zero at the boundary. This is implemented here by adding "ghost" points next to the grid points in the domain, and computing their value in such a way that the normal derivative is approximately zero. These points are then used to compute the discrete Laplacian at points in the domain next to the boundary.
The color hue depends on the wave height.

Render time: 30 minutes 24 seconds
Compression: crf 25
Color scheme: Viridis by Nathaniel J. Smith, Stefan van der Walt and Eric Firing
github.com/BIDS/colormap

Music: "Orbital Romance" by Sir Cubworth@SirCubworth

See also
https://images.math.cnrs.fr/des-ondes-dans-mon-billard-partie-i/ for more explanations (in French) on a few previous simulations of wave equations.

The simulation solves the wave equation by discretization. The algorithm is adapted from the paper hplgit.github.io/fdm-book/doc/pub/wave/pdf/wave-4print.pdf
C code: github.com/nilsberglund-orleans/YouTube-simulations
https://www.idpoisson.fr/berglund/software.html
Many thanks to Marco Mancini and Julian Kauth for helping me to accelerate my code!

#wave #resonator #harmonics
Waves in a square with Neumann boundary conditions
Nils Berglund |

Waves in a square with Neumann boundary conditions

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER