comparison +time/Rk4SecondOrderNonlin.m @ 984:0585a2ee7ee7 feature/timesteppers

Inline the rk.rungekutta_4 function.
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 08 Jan 2019 12:19:33 +0100
parents f5e14e5986b5
children
comparison
equal deleted inserted replaced
983:b89379fb0814 984:0585a2ee7ee7
59 vt = obj.w(end/2+1:end); 59 vt = obj.w(end/2+1:end);
60 t = obj.t; 60 t = obj.t;
61 end 61 end
62 62
63 function obj = step(obj) 63 function obj = step(obj)
64 obj.w = time.rk.rungekutta_4(obj.w, obj.t, obj.k, obj.F); 64 w = obj.w;
65 k = obj.k;
66
67 k1 = obj.F(t, w);
68 k2 = obj.F(t + 0.5*k, w + 0.5*k*k1);
69 k3 = obj.F(t + 0.5*k, w + 0.5*k*k2);
70 k4 = obj.F(t + k, w + k*k3);
71
72 obj.w = w + k*(1/6)*(k1+2*(k2+k3)+k4);
65 obj.t = obj.t + obj.k; 73 obj.t = obj.t + obj.k;
66 obj.n = obj.n + 1; 74 obj.n = obj.n + 1;
67 end 75 end
68 end 76 end
69 77