Hi,

I have been given a code that uses fourth order RK method for solving a PDE system.

I'm not very familiar with Runge-Kutta methods, so I've always seen it as can be found in:
Runge

But this code uses an alternative implementation. I cannot find any reference to such an implementation and I cannot seem to prove that they are really calculating the same thing.

Perhaps the best is to show the code:

Using the function f to calculate the derivative:

double f(double t, double hx, double ThC, double u[], int i)
{
double hx2, x;

hx2 = hx*hx;
x = i*hx;
return(ThC*(u[i+1]-2*u[i]+u[i-1])/hx2 );
}


Then, I have implemented the standard runge-kutta as:

for (i=1;i<N;i++) t1[i]=u[i]+0.5*(k1[i]=del_t*f(t, hx, ThC, u, i));
for (i=1;i<N;i++) t2[i]=u[i]+0.5*(k2[i]=del_t*f(t+ht, hx, ThC, t1, i));
for (i=1;i<N;i++) t3[i]=u[i]+ (k3[i]=del_t*f(t+ht, hx, ThC, t2, i));
for (i=1;i<N;i++) k4[i]= del_t*f(t+del_t, hx, ThC, t3, i);

for (i=1;i<N;i++) u[i]+=(k1[i]+2*k2[i]+2*k3[i]+k4[i])/6.0;

The alternative implementation (which gives very similar results) is:

for (i=1;i<N;i++) t1[i] = u[i] + (del_t/4)* f(t,hx,ThC,u,i);
for (i=1;i<N;i++) t2[i] = u[i] + (del_t/3)* f(t,hx,ThC,t1,i);
for (i=1;i<N;i++) t3[i] = u[i] + (del_t/2)* f(t,hx,ThC,t2,i);
for (i=1;i<N;i++) u[i] = u[i] + del_t * f(t,hx,ThC,t3,i);

If you think you can give me a hand, I can give more details (the whole code, the problem that this is trying to solve, together with the exact solution, etc.).

Thanks a lot,