• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Help with some subtleties of Runge-Kutta 4 method

Biftheunderstudy

Senior member
I've been trying to solve a set of coupled differential equations for a while. The first 6 are 1st order ODE's in time, with no explicit time dependance. The last equation is a second order in space, and is a constraint equation.

I'm programming in Fortran 90 with a sideproject involving Matlab. My current strategy for solving the set of equations is to perform RK4 on the first 6 equations, break the last into 2 first orders ODE's and perform a separate RK4 on the now 2 equations.

I've run into a few problems. I've stored all of the independent variables in arrays with values defined at discrete grid points. Solving the constraint equation then has a bit of a problem since it relies on these variables.

Basically, in the RK4 scheme, the routine makes calls like:

K2 = h*func(x+dx/2,y+K1/2)

The problem is that my function 'func' is only defined on the grid with spacing dx, so a call to x with x+dx is asking for a value between the grid spacing.

I'm fishing for new ideas to get around this issue, any help is appreciated.
 
It took me awhile to figure this one out. If your function is only defined as points, technically it doesn't have a derivative. If an approximation of the function is acceptable, you might want to try interpolation, but that's only going to give you an approximate answer, and not necessarily a reasonable one.

This looks like it might be better asked in the Highly Technical forum.
 
The problem is that my function 'func' is only defined on the grid with spacing dx, so a call to x with x+dx is asking for a value between the grid spacing.

I don't understand this.
I would think you'd have points like:
x1 x2 x3 x4
And each one would be dx space apart? Why would x+dx then be between the grid spacing?
 
Back
Top