d00mvw
09-27-2007, 05:14 AM
Hi Everyone
I recently copied and compiled the Runge-Kutta Fehlberg example (odeint.c,rkqs.c,rkck.c) from NR. I've been testing it with a simple mass-spring (no damping) system i.e.
dydx[1]=y[2];
dydx[2]=-k*y[1];
where k is the spring stiffness. Using the program as is from NR, the results compare well to those produced by the ode45 function in Matlab for low values of k. However, increasing the value of k (the frequency of oscillation), the results begin to differ from Matlab i.e. I appear to get an aliased result of lower frequency. Clearly, the odeint is taking too large a step and not picking up the details at higher spring stiffness. Therefore, how do you go about modifying odeint so it does capture the true result? Do I need to look at the error estimation or the method by which it reduces the step size?
Forgive my ignorance, I'm a newbie to all this and would really appreciate some direction. Thanks in advance :).
I recently copied and compiled the Runge-Kutta Fehlberg example (odeint.c,rkqs.c,rkck.c) from NR. I've been testing it with a simple mass-spring (no damping) system i.e.
dydx[1]=y[2];
dydx[2]=-k*y[1];
where k is the spring stiffness. Using the program as is from NR, the results compare well to those produced by the ode45 function in Matlab for low values of k. However, increasing the value of k (the frequency of oscillation), the results begin to differ from Matlab i.e. I appear to get an aliased result of lower frequency. Clearly, the odeint is taking too large a step and not picking up the details at higher spring stiffness. Therefore, how do you go about modifying odeint so it does capture the true result? Do I need to look at the error estimation or the method by which it reduces the step size?
Forgive my ignorance, I'm a newbie to all this and would really appreciate some direction. Thanks in advance :).