Processing math: 100%

« Previous
Next »

The computational algorithm

  1. u0=I
  2. compute u1
  3. for n=1,2,,Nt1:
    1. compute un+1
More precisly expressed in Python:

t = linspace(0, T, Nt+1)  # mesh points in time
dt = t[1] - t[0]          # constant time step.
u = zeros(Nt+1)           # solution

u[0] = I
u[1] = u[0] - 0.5*dt**2*w**2*u[0]
for n in range(1, Nt):
    u[n+1] = 2*u[n] - u[n-1] - dt**2*w**2*u[n]

Note: w is consistently used for ω in my code.

« Previous
Next »