- #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.
##\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.