Wave Equation

AI authored to showcase ironpad capabilities.

1D Wave Equation 🌊

The wave equation is one of the fundamental PDEs in physics:

\frac{\partial^2 u}{\partial t^2} = c^2 \, \frac{\partial^2 u}{\partial x^2}

It describes how disturbances propagate through a medium — vibrating strings, sound waves, electromagnetic radiation, and quantum mechanical wavefunctions.

This Notebook

We solve the 1D wave equation using the finite difference method and render 200 frames of the wave's evolution as a looping animation:

  • Grid: 800 spatial points (one per pixel column)
  • Initial condition: Two Gaussian pulses at different positions
  • Boundary: Fixed ends (u = 0) — pulses reflect with inverted phase
  • CFL condition: c \cdot \Delta t / \Delta x = 0.5 \le 1 ✓ (ensures numerical stability)

Watch the pulses propagate, bounce off the walls, and interfere with each other!

Wave Animation

Understanding the Physics

Reflection at Boundaries

With fixed boundaries (u = 0 at both ends), waves reflect with inverted phase — the pulse flips upside down. This is because the displacement must remain zero at the boundary.

Superposition

When reflected waves overlap, their displacements add linearly. The wave equation is linear, so any sum of solutions is also a solution. This creates intricate interference patterns.

Standing Waves

After multiple reflections, overlapping traveling waves form standing wave patterns — nodes (stationary points) and antinodes (maximum oscillation). The fundamental frequency is f_1 = c \,/\, 2L.

Energy Conservation

The finite difference scheme conserves total wave energy (when CFL \le 1):

E = \frac{1}{2} \int \left( u_t^2 + c^2 \, u_x^2 \right) dx = \text{const}

Try Modifying

  • Change the pulse positions or widths (\sigma parameter)
  • Add a third pulse or use a sine wave initial condition
  • Increase NUM_FRAMES or STEPS_PER_FRAME for longer evolution
  • Try c = 2.0 for faster wave propagation