2

I've been given the formula for RK2 and shown how to use it on an ODE to solve $y'(t) = f(y, t)$, where $f(y,t)$ is explicitly known.

Equipped only with this knowledge I have been asked to use RK2 on a PDE, where neither side of the equation is known, except that I see that I must substitute the spacial derivative with a finite difference operator. I am required, for the purpose of this assignment to use a center space finite difference, as shown below.

My work so far:

Given $\partial_tu(x,t) = -c\partial_xu(x,t)$ is analogous to $y'(t) = f(y,t)$ when we consider all variables besides t as constants:

$$ k_1 = \Delta t f(y_n, t_n) \\k_2 = \Delta t f(y_n + k_1, t_n + \Delta t)\\ y_{n+1} = y_n + \frac{1}{2}(k_1 +k_2) + \mathcal{O}(\Delta t^3) $$

Becomes:

$$ k_1 = \Delta t f(u_{j+1}, u_{j-1}) = -c\Delta t \frac{u^n_{j+1} - u^n_{j-1}}{2\Delta x} \\k_2 = \Delta t f(u_n +k_1, t_n + \Delta t) = ????? \\ u^{n+1}_j = u^n_j + \frac{1}{2}(k_1 +k_2) + \mathcal{O}(\Delta t^3) $$ $$ \text{where }u^n_j \text{ means } u(x_0 + j\Delta x, n\Delta t) $$

I have no idea how to add $k_1$ to my new "function" of $u_{j+1}$ and $u_{j-1}$ in order to find $k_2$. My textbook (Numerical Recipes [in fortran 77!]) does not review RK2 in combination with PDEs, and neither do my class notes. I have no idea how to functionally put RK2 to work on a PDE without knowing this step. I am not far enough along in the course to make use of linear algebra, though I have seen suggestions to do so.

This question seems quite similar, but I do not understand the accepted answer:

Runge-Kutta method for PDE

The answer seems to just put finite difference to use. I don't see Runge Kutta used at all. It looks like a finite difference operator is used and that's it.

rocksNwaves
  • 1,001

1 Answers1

3

One approach for performing such time-integration is the method of lines (MOL). Let us introduce the nodal values $u_j(t) = u(x_j,t) = u(x_0 + j\Delta x,t)$. Using centered differencing to approximate the spatial derivative, the PDE gives \begin{aligned} \frac{\text d}{\text{d} t} u_j(t) &= -c\, \partial_x u(x_j,t) \\ & \simeq -c\, \frac{u_{j+1}(t) - u_{j-1}(t)}{2\, \Delta x} \, . \end{aligned} The system of ordinary differential equations \begin{aligned} \frac{\text d}{\text{d} t} {\bf u}(t) &= -\frac{c}{2\, \Delta x} \left( \begin{array}{ccccc} 0 & 1 & &\\ -1 & \ddots & \ddots &\\ & \ddots & \ddots & 1\\ & & -1 & 0 \end{array} \right) \, {\bf u}(t) - \frac{c}{2\, \Delta x} \left( \begin{array}{c} -u_0(t)\\ 0\\ \vdots\\ 0\\ u_N(t) \end{array} \right) ,\\ &= {\bf f}({\bf u}(t)) \, , \end{aligned} made by the vector ${\bf u} = (u_1,\dots ,u_{N-1})^\top$ of nodal values can then be integrated in time explicitly using Runge-Kutta methods.

In particular, if the forward Euler (RK1) method ${\bf u}^{n+1} = {\bf u}^{n} + \Delta t\, {\bf f}({\bf u}^n)$ is used for time-integration, then an unstable scheme $$ u_j^{n+1} = u_j^n -c\, \frac{\Delta t}{2\,\Delta x} (u_{j+1}^n - u_{j-1}^n)\, , \qquad 1 \leq j \leq N-1 $$ is obtained. A slight modification of this method gives the stable Lax-Friedrichs scheme.

If the proposed improved Euler (RK2) method is used for time integration, one has \begin{aligned} \tilde u_j^{n+1} &= u_j^n + \Delta t\, k_1 \\ &= u_j^n -c\, \frac{\Delta t}{2\, \Delta x} (u_{j+1}^n - u_{j-1}^n) \, ,\\ u_j^{n+1} &= u_j^n + \frac{1}{2} (k_1+k_2)\\ &= u_j^n -c\, \frac{\Delta t}{4\, \Delta x} (u_{j+1}^n - u_{j-1}^n + \tilde u_{j+1}^{n+1} - \tilde u_{j-1}^{n+1}) \, . \end{aligned} Finally, for $2 \leq j \leq N-2$, $$ u_j^{n+1} = u_j^n -c\, \frac{\Delta t}{2\, \Delta x} (u_{j+1}^n - u_{j-1}^n) + c^2\, \frac{\Delta t^2}{8\, \Delta x^2}(u_{j+2}^n - 2u_{j}^n + u_{j-2}^n) \, , $$ which looks quite similar to the Lax-Wendroff scheme, but may have different stability properties.

EditPiAf
  • 21,328
  • Could you explain the nature of the identity-like matrix? Why are there two sets of diagonal 1's?

    Also, would the second vector look like $(u_0(t), u_1(t), \dots u_{N-1}(t))^T$? I'm confused by it only having a single entry, as well as why it isn't subtracted instead of added.

    It looks like you expand the vector $\frac{d}{dt}u(t)$ using some finite difference method and rearrange the whole thing to get $u^{n+1}_j$ alone on the left hand side, giving us Euler ($\tilde{u}^{n+1}$).

    And, I think I see my $k_1$ and $k_2$ buried in the last line of your answer!

    – rocksNwaves Mar 02 '18 at 19:05
  • I understand that dependency as the need for boundary conditions when I finally code this up. Following your derivation though, I guess my question was about the algebra... I've just never seen an identity matrix with two diagonal sets of 1's.

    I'm trying to do this derivation that you showed me on paper right now, and I keep getting a $\frac{\Delta x}{c} \frac{d}{dt}\mathbf{u}(t)$ on the right hand side. I expand that using forward time differencing? Is this a mistake on my part? I like to do the derivation myself because I'm bad at math in general. I can't figure out my mistake.

    – rocksNwaves Mar 02 '18 at 19:30
  • I'm sorry, I don't understand. My question is about the method as prescribed in my question. I can see that you are talking about a related method, but it does not help me. – rocksNwaves Mar 03 '18 at 20:03