Mercurial > repos > public > sbplib
comparison +time/Rk4SecondOrderNonlin.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 | cd2e28c5ecd2 |
children | 50d5a3843099 |
comparison
equal
deleted
inserted
replaced
580:2ce903f28193 | 816:b5e5b195da1e |
---|---|
58 function [vt,t] = getVt(obj) | 58 function [vt,t] = getVt(obj) |
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 state = getState(obj) | |
64 [v, t] = obj.getV(); | |
65 [vt] = obj.getVt(); | |
66 state = struct('v', v, 'vt', vt, 't', t, 'k', obj.k); | |
67 end | |
68 | |
63 function obj = step(obj) | 69 function obj = step(obj) |
64 obj.w = time.rk4.rungekutta_4(obj.w, obj.t, obj.k, obj.F); | 70 obj.w = time.rk4.rungekutta_4(obj.w, obj.t, obj.k, obj.F); |
65 obj.t = obj.t + obj.k; | 71 obj.t = obj.t + obj.k; |
66 obj.n = obj.n + 1; | 72 obj.n = obj.n + 1; |
67 end | 73 end |