Thanks for your help @luraess. That does clear things up! Just so I am clear though, the reason the wave equation is formatted that way in your example is due to us wanting to solve for the next time step, so using a center finite difference scheme we have:
\frac{d^2P}{dt^2} \approx \frac{P(t+dt)-2P(t)+P(t-dt)}{dt^2}
Therefore, at the next time step our solution is:
P(t+dt) \approx 2P(t) - P(t-dt) + dt^2(c^2\nabla^2P)
Where c
is the sound speed of the medium and \nabla^2P would be defined by @d2_xi(P)/dx^2 + ...
in the code.