Pages

Saturday, April 6, 2024

Round Wave in a Square Hole

The little camper we've been living in for the past 6 months (!) has a shower in its bathroom, but the bathroom's size and design is similar to those you find on an airplane, so adding a shower doesn't leave much room for a person. Instead, I typically take showers in the campground's bath house, but that comes with its own quirks. Often the drains won't keep up with the shower's water input, and I'll get a standing pool in the stall. What caught my attention recently was the waves I made as I moved around, which bounced off the walls and recombined, creating interesting patterns. I realized I could adapt the simulation I originally made for waves on the ball drum to two dimensions and do some experimenting! Easier said than done it turned out, and it took me a bit to get things working properly, but I'm quite pleased with the result.

The key to the dynamics is an operator called the Laplacian, which measures the curvature around a point on an N-dimensional surface. For a 2D grid, we can calculate it as

In our case, f represents the height of the water at a given point, and h is the size of our grid points. This gives us the force on the water, so we integrate twice to get the new heights. When h would hit one of the walls, we use a similar tactic to my Roomba post, and use a mirror image of the wave. That gives us the interesting dynamics I was looking for.

Below you'll find my simulation of the waves – click or click-and-drag to disturb the water. There's no damping, but (since energy is conserved) the waves get weaker as they spread out, so you may need to draw more than a single point to see reflections from the walls. You might notice it's a bit pixelated – The integration is not very efficient, so to speed things up it's simulated on a small grid and scaled up. This was actually the cause of the delay in finishing, since it took me a couple tries to get the scaling to work. You can hit the reset button to clear your waves and go back to a calm blue ocean/public shower stall. Have fun!


Canvas not supported; please update your browser.

No comments:

Post a Comment