LOOP
compute force
velocity += force/mass * time step
position += velocity * time step
ENDLOOP
which translates to the actual program code
FORALL i
f = c^2*(u[i-1] + u[i+1] – 2u[i])/h^2
v[i] = v[i] + f*dt
u_new[i] = u[i] + v[i]*dt
ENDFOR
u = u_new
This implementaion uses WebGL and was built with the help of webglfundamentals.org. Feel free to change the parameters.
Click on a column to create a wave.