Base runge kutta implementation (need refactoring)