Mercurial > repos > public > sbplib
annotate +time/Rungekutta4proper.m @ 846:c6fcee3fcf1b feature/burgers1d
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Thu, 20 Sep 2018 17:51:19 +0200 |
parents | e1a05acc1b5d |
children |
rev | line source |
---|---|
41
910a05dcdfdf
Added Rk4 as it should be.
Jonatan Werpers <jonatan@werpers.com>
parents:
13
diff
changeset
|
1 classdef Rungekutta4proper < time.Timestepper |
0 | 2 properties |
3 F | |
4 k | |
5 t | |
6 v | |
7 m | |
8 n | |
9 end | |
10 | |
11 | |
12 methods | |
280
e1a05acc1b5d
Added some documentation.
Jonatan Werpers <jonatan@werpers.com>
parents:
41
diff
changeset
|
13 % Timesteps v_t = F(v,t), using RK4 fromt t = t0 with timestep k and initial conditions v = v0 |
41
910a05dcdfdf
Added Rk4 as it should be.
Jonatan Werpers <jonatan@werpers.com>
parents:
13
diff
changeset
|
14 function obj = Rungekutta4proper(F, k, t0, v0) |
910a05dcdfdf
Added Rk4 as it should be.
Jonatan Werpers <jonatan@werpers.com>
parents:
13
diff
changeset
|
15 obj.F = F; |
0 | 16 obj.k = k; |
17 obj.t = t0; | |
18 obj.v = v0; | |
19 obj.m = length(v0); | |
13
b18d3d201a71
Fixed initialization of step counter in timesteppers.
Jonatan Werpers <jonatan@werpers.com>
parents:
0
diff
changeset
|
20 obj.n = 0; |
0 | 21 end |
22 | |
23 function [v,t] = getV(obj) | |
24 v = obj.v; | |
25 t = obj.t; | |
26 end | |
27 | |
28 function obj = step(obj) | |
846
c6fcee3fcf1b
Add generalized RungeKutta and RungeKuttaRV class which extracts its coefficients from a butcher tableau, specified on the scheme.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
280
diff
changeset
|
29 obj.v = time.rk.rungekutta_4(obj.v, obj.t, obj.k, obj.F); |
0 | 30 obj.t = obj.t + obj.k; |
31 obj.n = obj.n + 1; | |
32 end | |
33 end | |
34 | |
35 | |
36 methods (Static) | |
37 function k = getTimeStep(lambda) | |
38 k = rk4.get_rk4_time_step(lambda); | |
39 end | |
40 end | |
41 | |
42 end |