Mercurial > repos > public > sbplib
comparison +time/Rungekutta4SecondOrder.m @ 816:b5e5b195da1e feature/timesteppers
Add getState to timesteppers, returning the relevant state of the timestepper
- Add getState which returns the 'state' of the specialized timestepper.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 10 Sep 2018 16:19:16 +0200 |
parents | b18d3d201a71 |
children | 8894e9c49e40 |
comparison
equal
deleted
inserted
replaced
580:2ce903f28193 | 816:b5e5b195da1e |
---|---|
47 function [vt,t] = getVt(obj) | 47 function [vt,t] = getVt(obj) |
48 vt = obj.w(end/2+1:end); | 48 vt = obj.w(end/2+1:end); |
49 t = obj.t; | 49 t = obj.t; |
50 end | 50 end |
51 | 51 |
52 function state = getState(obj) | |
53 [v, t] = obj.getV(); | |
54 [vt] = obj.getVt(); | |
55 state = struct('v', v, 'vt', vt, 't', t, 'k', obj.k); | |
56 end | |
57 | |
52 function obj = step(obj) | 58 function obj = step(obj) |
53 obj.w = time.rk4.rungekutta_4(obj.w, obj.t, obj.k, obj.F); | 59 obj.w = time.rk4.rungekutta_4(obj.w, obj.t, obj.k, obj.F); |
54 obj.t = obj.t + obj.k; | 60 obj.t = obj.t + obj.k; |
55 obj.n = obj.n + 1; | 61 obj.n = obj.n + 1; |
56 end | 62 end |