Numerical Analysis of Advection Equations

For simplicity, consider a one-dimensional wave Let the value at coordinate \(x\) at time \(t\) be \(f(x-ut)\) For example, if a sine wave moves in the positive x-axis direction at velocity \(u\), then \(f(x-ut) = sin(x-ut)\) At this time, \(\frac{\partial f}{\partial t} + u \frac{\partial f}{\partial x} =0 \) holds. This is the advection equation First-Order Upwind Difference Method Approximate with a straight line Since this is numerical analysis, \(x\) is discrete like \(\dots,x_{i-1},x_i,x_{i+1},\dots\) Let the approximation of \(f\) at \(x = x_i\) be \(F_i^n(x)\) This method approximates with a straight line, so \(F_i^n(x)=a(x-x_i) + f_i^n, a = \frac{f_i^n - f_{i-1}^n}{\Delta x}\) Where \(f_i^n\) is the value after advancing the time step \(n\) times at \(x = x_i\) Time advances by \(\Delta t\) per time step When advancing the time step, $f_i^{n+1} = F_i^n(x_i-u\Delta t) = a(-u \Delta t) + f_i^n= - \frac{u \Delta t}{\Delta x}(f_i^n - f_{i-1}^n) + f_i^n$ In the program, just repeat the following with $K=u \frac{\Delta t}{\Delta x}$ The figure shows a rectangular wave input There’s also downwind for(i=1; i<99; i++) f_new[i] = -K * (f[i]-f[i-1]) + f[i]; for(i=1; i<99; i++) f[i] = f_new[i]; Lax-Wendroff Method Approximate with a quadratic function Approximate with $F_i^n(x) = a(x-x_i)^2 + b(x-x_i) + c$ Since three constants $a,b,c$ are needed, put appropriate values into $x$: $F_i^n(x_{i-1}) = a \Delta x ^2 - b \Delta x + c = f_{i-1}^n$ $F_i^n(x_{i}) = c = f_{i-1}^n$ $F_i^n(x_{i+1}) = a \Delta x ^2 + b \Delta x + c = f_{i+1}^n$ Where $x_{i+1} - x_{i} = x_{i} - x_{i-1}=\Delta x$ Solving this gives: $$ F_{i}^n(x) = a(x-x_i)^2 + b(x-x_i) + f_i^n, \\ a = \frac{f_{i+1}^n - 2f_{i}^n + f_{i-1}^n}{2\Delta x^2}, b = \frac{f_{i+1}^n - f_{i-1}^n}{2\Delta x} $$ When advancing the time step: $$ f_i^{n+1} = F_i^n(x_i-u\Delta t) = f_i^n - \frac{u\Delta t}{2 \Delta x}(f_{i+1}^n - f_{i-1}^n) + \frac{(u\Delta t)^2}{2 \Delta x ^2}(f_{i+1}^n -2 f_i^n- f_{i-1}^n) $$ In the program, similar to upwind difference, just repeat the following with $K=u \frac{\Delta t}{\Delta x}$ for(i=1; i<99; i++) f_new[i] = f[i] - K*K*(f[i+1]-f[i-1])/2....

April 26, 2016