Wave Equation (2D)
- pdevisualizer.wave2d.step_wave(u, u_prev, c, dt, dx, dy)[source]
Perform one time step of the 2D wave equation using finite differences.
Uses the explicit leapfrog scheme: u^(n+1) = 2u^n - u^(n-1) + c²dt²[(u^n_{i+1,j} - 2u^n_{i,j} + u^n_{i-1,j})/dx² +
(u^n_{i,j+1} - 2u^n_{i,j} + u^n_{i,j-1})/dy²]
- pdevisualizer.wave2d.step_wave_first(u0, v0, c, dt, dx, dy)[source]
Perform the first time step of the wave equation using initial velocity.
For the first step, we use: u^1 = u^0 + dt*v^0 + (dt²/2)*c²∇²u^0
- pdevisualizer.wave2d.solve_wave(u0, v0=None, c=1.0, dt=0.1, dx=1.0, dy=1.0, steps=100)[source]
Solve the 2D wave equation for a given number of time steps.
- pdevisualizer.wave2d.animate_wave(u0, v0=None, c=1.0, dt=0.1, dx=1.0, dy=1.0, frames=100, interval=50)[source]
Animate the 2D wave equation starting from initial conditions.