Fun with Waves in Matlab – Wave Equation Modeling

Dev

Setup

Matlab is cool. Math is cool. Enough said.
Amazing how all this beauty is held inside such a seemingly simple formula, the wave equation.
{ \partial^2 u \over \partial t^2 } = c^2 \nabla^2 u
This is the basics of the setup. It is a rectangular pool that can simulate perturbations based on the above wave equation. The model implements finite differences for its solution on the 2D mesh. e.g. (f_x = (f_i – f_[i-1]) / da)

Details of Model

The inner oscillations are a result of model error. I wasn’t sure if this error was from the size of the impulse or the size of the mesh. The variables needed to be isolated. I doubled the size of the mesh points in each direction. To keep the impulse size the same, the input was now a 2×2 impulse instead of a 1×1. As seen, the inner oscillations have a higher frequency compared to before. This means the model error of inner oscillation frequency is dependent on the mesh size.
I wondered what happens in real life when something gets dropped into a big bowl of water. It turns out that there is one big oscillation followed by medium sized ripples. Running the simulation with a bigger impulse and a very fine mesh, I obtain similar results. As shown, you can see one big oscillation followed by medium-sized ripples.
In addition to the medium-sized ripples, you can still see little oscillations of high frequency. As shown previously, these depend on the step size.
In real life, there are a discrete number of water molecules to move up and down. There aren’t infinitely many points in the mesh.
Maybe these frequencies that depend on the step size show up in real life too. Or maybe not.

Boundary Value Manipulation

Any Dirichlet boundary conditions* can be imposed by reassigning the boundary to its fixed value after every iteration. I wanted to see what happened on the shape of a guitar. It is interesting how there is sort of a mirror of the source in the front of the guitar. There was only one impulse applied to this shape, even though it looks like there is a smaller impulse on the top of the guitar.

*A Dirichlet boundary condition is a fancy word for a boundary that doesn’t move, like a wall that has a jump rope tied to it – or a guitar bridge with guitar strings tied to it.

Fun Experiment DOUBLE SLIT!! xD

Applying more Dirichlet boundary values to form two slits for waves to come out. Look at that beautiful diffraction pattern!! (:

 
Until next time

Leave a Reply

Your email address will not be published. Required fields are marked *