view +time/Rungekutta4proper.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 910a05dcdfdf
children 8894e9c49e40
line wrap: on
line source

classdef Rungekutta4proper < time.Timestepper
    properties
        F
        k
        t
        v
        m
        n
    end


    methods
        function obj = Rungekutta4proper(F, k, t0, v0)
            obj.F = F;
            obj.k = k;
            obj.t = t0;
            obj.v = v0;
            obj.m = length(v0);
            obj.n = 0;
        end
        
        function [v, t] = getV(obj)
            v = obj.v;
            t = obj.t

        end

        function state = getState(obj)
            state = struct('v', obj.v, 't', obj.t, 'k', obj.k);
        end

        function obj = step(obj)
            obj.v = time.rk4.rungekutta_4(obj.v, 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