Mercurial > repos > public > sbplib
comparison +time/Rungekutta4SecondOrder.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 | ad6de007e7f6 |
comparison
equal
deleted
inserted
replaced
983:b89379fb0814 | 984:0585a2ee7ee7 |
---|---|
97 vt = obj.w(end/2+1:end); | 97 vt = obj.w(end/2+1:end); |
98 t = obj.t; | 98 t = obj.t; |
99 end | 99 end |
100 | 100 |
101 function obj = step(obj) | 101 function obj = step(obj) |
102 obj.w = time.rk.rungekutta_4(obj.w, obj.t, obj.k, obj.F); | 102 w = obj.w; |
103 k = obj.k; | |
104 | |
105 k1 = obj.F(t, w); | |
106 k2 = obj.F(t + 0.5*k, w + 0.5*k*k1); | |
107 k3 = obj.F(t + 0.5*k, w + 0.5*k*k2); | |
108 k4 = obj.F(t + k, w + k*k3); | |
109 | |
110 obj.w = w + k*(1/6)*(k1+2*(k2+k3)+k4); | |
103 obj.t = obj.t + obj.k; | 111 obj.t = obj.t + obj.k; |
104 obj.n = obj.n + 1; | 112 obj.n = obj.n + 1; |
105 end | 113 end |
106 end | 114 end |
107 | 115 |