/* simple Runge-Kutta */
function RK_secondOrder()
{
/* Methode */
this.RKsO = function(grad, s, v, dt)
{ // Gradientenfunktion, s, v Variable, delta Schrittweite
var k1s, k2s, k3s, k4s, k1v, k2v, k3v, k4v;
//console.log("in RK before s: " + s + " v: "+v);
k1s = v; // Initialisierung
k1v = grad(s, v);
k2s = v + k1v*dt/2; // 1. Schritt
k2v = grad(s + k1s*dt/2, v + k1v*dt/2);
k3s = v + k2v*dt/2; // 2. Schritt
k3v = grad(s + k2s*dt/2, v + k2v*dt/2);
k4s = v + k3v*dt; // 3. Schritt
k4v = grad(s + k3s*dt, v + k3v*dt);
s = s + (k1s + 2*k2s + 2*k3s + k4s)*dt/6; // 4. Schritt
v = v + (k1v + 2*k2v + 2*k3v + k4v)*dt/6;
//console.log("in RK after s: " + s + " v: "+v);
return [s, v];
}
}