Mercurial > repos > public > sbplib
comparison +time/Rungekutta.m @ 933:34b3d092a4d0 feature/timesteppers
Add methods timePoints and quadWeights to Rungekutta class.
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Mon, 03 Dec 2018 16:49:43 -0800 |
parents | 3860dad28239 |
children | 0585a2ee7ee7 |
comparison
equal
deleted
inserted
replaced
932:3860dad28239 | 933:34b3d092a4d0 |
---|---|
58 function obj = step(obj) | 58 function obj = step(obj) |
59 [obj.v, obj.V, obj.K] = obj.scheme(obj.v, obj.t, obj.n); | 59 [obj.v, obj.V, obj.K] = obj.scheme(obj.v, obj.t, obj.n); |
60 obj.t = obj.t + obj.dt; | 60 obj.t = obj.t + obj.dt; |
61 obj.n = obj.n + 1; | 61 obj.n = obj.n + 1; |
62 end | 62 end |
63 | |
64 % Returns a vector of time points, including substage points, | |
65 % in the time interval [t0, tEnd]. | |
66 % The time-step obj.dt is assumed to be aligned with [t0, tEnd] already. | |
67 function tvec = timePoints(obj, t0, tEnd) | |
68 N = round( (tEnd-t0)/obj.dt ); | |
69 tvec = zeros(N*obj.s, 1); | |
70 s = obj.coeffs.s; | |
71 c = obj.coeffs.c; | |
72 for i = 1:N | |
73 ind = (i-1)*s+1 : i*s; | |
74 tvec(ind) = ((i-1) + c')*obj.dt; | |
75 end | |
76 end | |
77 | |
78 % Returns a vector of quadrature weights corresponding to grid points | |
79 % in time interval [t0, tEnd], substage points included. | |
80 % The time-step obj.dt is assumed to be aligned with [t0, tEnd] already. | |
81 function weights = quadWeights(obj, t0, tEnd) | |
82 N = round( (tEnd-t0)/obj.dt ); | |
83 b = obj.coeffs.b; | |
84 weights = repmat(b', N, 1); | |
85 end | |
63 end | 86 end |
64 end | 87 end |