Mercurial > repos > public > sbplib
view +time/Rungekutta4SecondOrder.m @ 87:0a29a60e0b21
In Curve: Rearranged for speed. arc_length_fun is now a property of Curve. If it is not supplied, it is computed via the derivative and spline fitting. Switching to the arc length parameterization is much faster now. The new stuff can be tested with testArcLength.m (which should be deleted after that).
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Sun, 29 Nov 2015 22:23:09 +0100 |
parents | b18d3d201a71 |
children | e7e73173d44d b5e5b195da1e |
line wrap: on
line source
classdef Rungekutta4SecondOrder < time.Timestepper properties F k t w m D E S M C n end methods function obj = Rungekutta4SecondOrder(D, E, S, k, t0, v0, v0t) obj.D = D; obj.E = E; obj.S = S; obj.m = length(v0); obj.n = 0; I = speye(obj.m); O = sparse(obj.m,obj.m); obj.M = [O, I; D, E*I]; % Multiply with I to allow 0 as input. if S == 0 obj.C = zeros(2*obj.m,1); else obj.C = [zeros(obj.m,1), S]; end obj.k = k; obj.t = t0; obj.w = [v0; v0t]; obj.F = @(w,t)(obj.M*w + obj.C); end function [v,t] = getV(obj) v = obj.w(1:end/2); t = obj.t; end function [vt,t] = getVt(obj) vt = obj.w(end/2+1:end); t = obj.t; end function obj = step(obj) obj.w = time.rk4.rungekutta_4(obj.w, obj.t, obj.k, obj.F); obj.t = obj.t + obj.k; obj.n = obj.n + 1; end end methods (Static) function k = getTimeStep(lambda) k = rk4.get_rk4_time_step(lambda); end end end