Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

p06: Variable coefficient wave equation

Solve using FFT

ut+c(x)ux=0,x∈(0,2π),c(x)=15+sin⁡2(x−1)u_t + c(x) u_x = 0, \qquad x \in (0,2\pi), \qquad c(x) = \frac{1}{5} + \sin^2(x-1)

with initial condition

u(x,0)=u0(x)=exp⁡(−100(x−1)2)u(x,0) = u_0(x) = \exp(-100(x-1)^2)

periodic boundary conditions and Leapfrog scheme in time: for n=1,2,…n=1,2,\ldots

vjn+1=vjn−1−(2Δt)c(xj)wjn,wjn≈ux(xj,tn)v_j^{n+1} = v_j^{n-1} - (2 \Delta t) c(x_j) w_j^n, \qquad w_j^n \approx u_x(x_j, t_n)

Take initial values

vj0=u0(xj),vj−1=u0(xj+c(xj)Δt)v_j^0 = u_0(x_j), \qquad v_j^{-1} = u_0(x_j + c(x_j)\Delta t)
<Figure size 1200x1000 with 1 Axes>

Make animation

Loading...

The dotted line shows the speed function c(x)c(x).