Resolution of a PDE with second order Runge-Kutta

In summary, the author is trying to solve a second order differential equation using a Runge-Kutta scheme but is not having good results. He is also not familiar with a more common approach to this problem, the Crank-Nicholson scheme.
  • #1
Telemachus
835
30
Hi, I want to solve the p.d.e.:

##\frac{\partial u(x,t)}{\partial t} - \frac{\partial^2 u(x,t)}{\partial x^2}=f(x,t)##,

with periodic boundary conditions ##u(x,t)=u(L,t)##.

using a second order Runge-Kutta method in time. However, I am not having the proper results when I apply this method to a particular problem. I don't know if I am doing something wrong in the code, or if I am not applying the Runge-Kutta method properly.

So, this is what I did. First I wrote:
##\frac{\partial u(x,t)}{\partial t}=f(x,t)+\frac{\partial^2 u(x,t)}{\partial x^2}=g(t,x,u)##,

Then I've considered the semi discrete problem, within the Runge-Kutta scheme:

##u^{n+1}=u^n+\Delta t k_2##,

With: ##k_1=g(t^n,x,u^n)=f^n(x)+\frac{\partial^2 u^n(x)}{\partial x^2}##
and: ##k_2=g(t^n+\frac{\Delta t}{2},x,u^n+\frac{\Delta t}{2}k_1)= f^{n+\frac{1}{2}}(x)+\frac{\partial^2}{\partial x^2}\left( u^n(x)+\frac{\Delta t}{2}k_1 \right)##

So, this is not giving the correct result, and I wanted to know if I am applying the scheme in the proper way. I am assuming all functions are periodic with period L, so I can solve this by means of Fourier methods in the spatial variable.
 
Physics news on Phys.org
  • #2
Runge-Kutta can only solve first order differential equations. To solve a second order equation, you will need to convert it to a system of first order equations. This is done by creating a new variable
$$v=\frac{\partial u}{\partial x}$$
so the original ODE is rewritten as
$$\frac{\partial v}{\partial x}=v-f(x,t)$$
The system is now
$$\frac{\partial}{\partial x}\begin{bmatrix} v\\ u\end{bmatrix}=\begin{bmatrix}v-f(x,t)\\ v\end{bmatrix}$$
This can now be solved with the RK method.
 
  • Like
Likes Telemachus
  • #3
Hi. Thanks for your reply. The PDE I've posted is first order in time, and I am willing to use a Runge Kutta method in the time variable. However, when I do so, while treating the space variable with a spectral method, the solution is like evolving too slow in time, almost not evolving at all.
 
  • #4
Oh sorry, I misread the first derivative as being with respect to space. You are effectively solving the heat equation with a varying source term. RK is not able to solve problems of this type as far as I know. A more common approach to this problem is the Crank-Nicholson scheme which will give a solution that is second order accurate in both space and time. Are you familiar with this method?
 
  • Like
Likes Telemachus
  • #5
Yes, I've used Crank-Nicolson already for this problem. But anyway, I wanted to use Runge-Kutta, it can be used with what is called the method of lines, where the spatial operator is treated somehow (finite difference, spectral methods, etc.) and one obtains a set of ordinary differential equations. I've found a paper that shows this with finite differences, and a fourth order RK in time. The paper tells how to treat the runge kutta scheme in a way to get stability with no so restrictive time steps. However, I was trying a second order RK, and using other approach in the space variable (I've found the paper after trying, but I think I have done things in the correct way, at least formally, and I posted this to check that in particular).

However, I don't obtain good results, even for a very small ##\Delta t##, and I think that if the problem were stability, the solution should blow up, but what I obtain is that the problem is evolving really really slow in time. Perhaps I should check the program, or if someone sees something in wrong in what I did, that would be great too.

This is the paper I've found where you can see in detail how this is done for finite differences in space: http://www.sciencedirect.com/science/article/pii/0307904X77900063
 
  • #6
Okay, I'm not very familiar with this method but here is my interpretation. It looks like you should first discritize the spatial derivative such that
$$\frac{du_{i}}{dt}=f_{i}+\frac{u_{i+1}-2u_{i}+u_{i-1}}{h_{x}^{2}}$$
This leads to
$$\frac{d}{dt}\mathbf{u}=\mathbf{f}$$
where
$$\mathbf{u}=\begin{bmatrix}u_{1}\\ \vdots\\ u_{i}\\ \vdots\\ u_{N}\end{bmatrix}$$
$$\mathbf{f}=\begin{bmatrix}f(0,t)+u^{\prime}(0,t)\\ \vdots\\ f_{i}+\frac{u_{i+1}-2u_{i}+u_{i-1}}{h_{x}^{2}}\\ \vdots\\ f(L,t)+u^{\prime}(L,t)\end{bmatrix}$$
Then you can apply RK to the vector equation listed above, marching the whole system forward at each time step.
 
  • Like
Likes Telemachus
  • #7
Ok, thanks for your reply. I haven't used finite differences in the spatial derivative, but instead of that a Fourier approach. Tomorrow I'll give you the details of what I did (because I don't have it in here). But basically, I applied a Fourier transform to get the derivatives, following the steps detailed at the beginning of the topic. However, I might have committed a mistake, because as I did it, it looks like if I had started by discretizing the time variable, and I didn't worked it with much care. But what I did is that, I just applied the Runge-Kutta formula in the way detailed above, applying the spatial derivative in Fourier space at each time step.

So, if I remember it right, this is what I did:

##u^{n}=\sum u_k e^{i2 \pi k x}##,
##f^{n}=\sum f_k e^{i2 \pi k x}##,

Then replacing in the equation ##u^{n+1}=f^n+\Delta t k_2## I've obtained the Fourier coefficients for the advanced time step.
 

What is a PDE?

A PDE, or partial differential equation, is a mathematical equation that involves multiple variables and their partial derivatives. It is commonly used to model physical phenomena in fields such as physics, engineering, and finance.

What is second order Runge-Kutta?

Second order Runge-Kutta is a numerical method for solving differential equations. It involves using two approximations of the solution at different points and taking their average to get a more accurate result. It is a popular method for solving PDEs due to its simplicity and efficiency.

How does second order Runge-Kutta work for solving PDEs?

In second order Runge-Kutta, the PDE is discretized into a system of ordinary differential equations (ODEs) using a grid. The ODEs are then solved using the Runge-Kutta method, which involves calculating the solution at multiple points and using them to approximate the solution at the next point. This process is repeated until the desired level of accuracy is achieved.

What is the convergence rate of second order Runge-Kutta for PDEs?

The convergence rate of second order Runge-Kutta for solving PDEs is O(h^2), where h is the grid spacing. This means that as the grid is refined, the error in the solution decreases quadratically.

What are the advantages of using second order Runge-Kutta for PDEs?

Second order Runge-Kutta has several advantages for solving PDEs. It is easy to implement, works well for a wide range of PDEs, and has a relatively low computational cost. It also has a higher accuracy compared to first order methods, making it a popular choice for solving PDEs.

Similar threads

  • Differential Equations
Replies
1
Views
837
  • Differential Equations
Replies
7
Views
2K
Replies
5
Views
1K
  • Differential Equations
Replies
3
Views
2K
  • Differential Equations
Replies
3
Views
1K
  • Differential Equations
Replies
3
Views
1K
Replies
4
Views
1K
  • Differential Equations
Replies
4
Views
565
  • Differential Equations
Replies
1
Views
707
  • Differential Equations
Replies
6
Views
1K
Back
Top