Runge Kutta Method for in $1+1$ dimension

89 Views Asked by At

Given a partial differential equation

$\partial_t u(t,x) = F(t,x,u,u')$

Suppose I know the functions $u(t_0,x)$ and $u'(t_0,x)$ at some point $t_0$ for all $x$. In order to obtain the function $u$ at the next time step $t_0 + \Delta t$, I may use the Runge Kutta method. However, within Runge Kutta method, expressions of the form $F(t_0 + \Delta t, x, u + \Delta t \cdot g, ...)$ must be calculated. My question now is, if this "shift" of the function $u$ is carried out before differentiating with respect to $x$ or after.

In detail, does the expression look like this

$F\Big( t_0 + \Delta t, x, u + \Delta t \cdot g, \partial_x u + \Delta t \cdot g \Big)$

or like this

$F\Big( t_0 + \Delta t, x, u + \Delta t \cdot g, \partial_x (u + \Delta t \cdot g) \Big) = F\Big(t_0 + \Delta t, x, u + \Delta t \cdot g, \partial_x u \Big)$

2

There are 2 best solutions below

0
On BEST ANSWER

RK is really an ODE time stepping method, so to use it to solve a dynamic PDE, you should first convert to an ODE by spatial discretization. So for example in 1 space dimension you might do finite differences as $u(t,x) = u^j_i$ with $t=j\Delta t,x=i\Delta x$ and $u_x(t,x) \approx (\partial_x u)^j_i := \frac{u^j_{i+1}-u^j_{i-1}}{2\Delta x}$ (centered space differences). Then far enough away from the boundary you can take $F(t,x,u,u') \approx F^j_i:=F(j\Delta t,i\Delta x,u^j_i,(\partial_x u)^j_i)$. Then when you adjust $u$ you must also adjust the spatial derivative accordingly.

0
On

To best understand how to apply RK4 to multiple values, it is best to view it in vector form.

The time evolution of the ODE is governed by the temporal derivative of the state vector $\boldsymbol{Y}$

$$ \boldsymbol{\dot{Y}} = {\rm f}( t,\, \boldsymbol{Y} ) $$

where $\boldsymbol{Y} = \pmatrix{y_1 \\ y_2 \\ \vdots }$ is the state vector containing all your degrees of freedom.

In your case, you have spatial derivatives $y'_i$ that need to be expressed in terms of your state variables inside the ${\rm f}(t,\boldsymbol{Y})$ function.

A naive implementation would be

$$ \boldsymbol{Y}'=\frac{1}{\Delta x}\begin{bmatrix} & \frac{1}{2}\\ \text{-}\frac{1}{2} & & \frac{1}{2}\\ & \text{-}\frac{1}{2} & & \ddots\\ & & \ddots & & \ddots\\ & & & \ddots \end{bmatrix}\boldsymbol{Y} $$

now you can construct $\boldsymbol{\dot{Y}}$ since you have $t$,$\boldsymbol{Y}$ and $\boldsymbol{Y}'$

Finally on each sub-step you get to re-evaluate ${\rm f}()$ which means you need to re-evaluate the above

$$\begin{aligned}\boldsymbol{K}_{0} & ={\rm f}(t,\boldsymbol{Y})\\ \boldsymbol{K}_{1} & ={\rm f}(t+\Delta t/2,\boldsymbol{Y}+\Delta t/2\,\boldsymbol{K}_{0})\\ \boldsymbol{K}_{2} & ={\rm f}(t+\Delta t/2,\boldsymbol{Y}+\Delta t/2\,\boldsymbol{K}_{1})\\ \boldsymbol{K}_{3} & ={\rm f}(t+\Delta t,\boldsymbol{Y}+\Delta t\,\boldsymbol{K}_{2}) \end{aligned}$$

and the change in state variables

$$\Delta\boldsymbol{Y}=\frac{\Delta t}{6}\left(\boldsymbol{K}_{0}+2\boldsymbol{K}_{1}+2\boldsymbol{K}_{2}+\boldsymbol{K}_{3}\right)$$