The 2D wave equation is used to model how many waves, such as light or sound, propagate in a two dimensional space over time. This equation is fairly fundamental everywhere in physics and engineering.
Applying finite differences (FD) for the interior nodes
Solving for
where
For boundary conditions, applying the 1D wave equation's radiating boundary conditions (RBCs):
Using the forward propagating wave:
Discretizing at
Combining these:
Solving for
Apply the same technique for top, left, and bottom boundaries.
To install the packges: pip install -r requirements.txt. To run the Python script - python wave_sim.py - you will notice it will be "laggy" due to the computations and zero optimizations in the code.
To run the C version build it via gcc -o sim wave_sim.c -lm and then ./sim. The simulation via C will be a lot faster but it only prints in the terminal (for now atleast)! The way it is printed is not ideal and was implemented fairly quickly. Feel free to change the colors or the values for display.
Python output:
C Output:

