Solving non-linear PDE with Runge-Kutta 4th order

958 Views Asked by At

I want to solve the following non-linear PDE with Runge Kutta 4th order:

$$\partial_t y(t,x)=y(t,x)\partial_x y(t,x)- 3t^2=:f(t,y)$$

The initial conditions $y(t_0,x_j)=:y_0^j$ are given at each lattice point $x_j$. From this one can also calculate $\partial_x y$ at each lattice point at $t_0$ as follows: $(y')_0^{j}:=(\partial_x y)(t_0,x_j)$.

Next I consider the time steps at $x_j$. According to Wiki I have to calculate:

$$k_1^j:=f(t_0,y_0^j)$$

But how do I evaluate the following?

$$k_2^j:=f(t_0+\frac{\Delta t}{2},y_0^j+\frac{\Delta t}{2}k_1^j)$$

I have the spatial derivative in $f$ and therefore it is not clear to me what it means that I evaluate the function at $y=y_0^j+\frac{\Delta t}{2}k_1^j$?

Does it mean

$$f(t_0+\frac{\Delta t}{2},y_0^j+\frac{\Delta t}{2}k_1^j)=\left(\partial_xy\right)\left(t_0+\frac{\Delta t}{2},x_0^j\right)-3\left(t_0+\frac{\Delta t}{2}\right)^2$$

??

1

There are 1 best solutions below

0
On BEST ANSWER

Ok. I solved it.

First write the PDE as:

$$\partial_t y(t,x)=y(t,x)\partial_x y(t,x)- 3t^2=y(t,x)\frac{y(t,x+\Delta x)-y(t,x)}{\Delta x}- 3t^2=:f(t,y) ~~(*)$$

We discretize the spatial coordinates $x_0,x_1,\cdots x_i\cdots$ and the time coordinate $t_0,t_1,\cdots t_j\cdots$.

We define the function $y_i(t)$ at each lattice point:

$$y_i(t):=y(t,x_i)$$

Then we can write equation $(*)$ as:

$$\partial_t y_i(t)=y_i(t)\frac{y_{i+1}(t)-y_i(t)}{\Delta x}-3t^2=: f_i(t)$$

In vector notation:

$$\partial_t \vec{y}(t)=\begin{pmatrix}y_0\frac{y_1-y_0}{\Delta x}-3 t^2\\y_1\frac{y_2-y_1}{\Delta x}-3 t^2\\...\\y_i\frac{y_{i+1}-y_{i}}{\Delta x}-3 t^2\\...\end{pmatrix}=:\vec{f}(t,\vec{y})$$

Based on this we can apply the Runge-Kutta scheme straight forwardly.

  • $\vec{y}(t_0)=:\vec{y}^{(0)}$ is given.

  • $\vec{k}_1:=\vec{f}(t_0,\vec{y}^{(0)})$

  • $\vec{k}_2:=\vec{f}(t_0+\frac{\Delta_t}{2},\vec{y}^{(0)}+\frac{\Delta t}{2}\vec{k}_1)$

  • $\vec{k}_3:=\vec{f}(t_0+\frac{\Delta_t}{2},\vec{y}^{(0)}+\frac{\Delta t}{2}\vec{k}_2)$

  • $\vec{k}_4:=\vec{f}(t_0+\Delta_t,\vec{y}^{(0)}+\Delta t\vec{k}_3)$

  • $\vec{y}^{(1)}=\vec{y}^{(0)}+\frac{\Delta t}{6}\left(\vec{k}_1+2\vec{k}_2+2\vec{k}_3+\vec{k}_4\right)$

Repeat steps for $\vec{y}^{(2)}$ etc.