comparison +rv/+time/BDFDerivative.m @ 1013:eb441fbdf379 feature/advectionRV

Draft implementation of RungeKutta with exterior RV updates - Draft class RungeKuttaExteriorRV which updates the residual using a BDF approximation of the derivtive outside of the RK stages. - Draft class for BDF derivative
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 05 Dec 2018 15:04:44 +0100
parents
children e547794a9407
comparison
equal deleted inserted replaced
1012:1e437c9e5132 1013:eb441fbdf379
1 class BDFDerivative < handle
2 properties
3 dt
4 coefficents
5 end
6 methods
7 function obj = BDFDerivative(order, dt)
8 obj.coefficents = obj.getBDFCoefficients(order);
9 obj.dt = dt;
10 end
11
12 function DvDt = evaluate(v, v_prev)
13 DvDt = (obj.coefficients(1)*v - sum(obj.coefficients(2:end).*v_prev),2)/obj.dt;
14 end
15
16 function c = getBDFCoefficients(obj, order)
17 switch order
18 case 1
19 c(1,1) = 1; c(1,2) = 1;
20 case 2
21 c(1,1) = 3/2; c(1,2) = 4/2; c(1,3) = -1/2;
22 case 3
23 c(1,1) = 11/6; c(1,2) = 18/6; c(1,3) = -9/6; c(1,4) = 2/6;
24 case 4
25 c(1,1) = 25/12; c(1,2) = 48/12; c(1,3) = -36/12; c(1,4) = 16/12; c(1,5) = -3/12;
26 case 5
27 c(1,1) = 137/60; c(1,2) = 300/60; c(1,3) = -300/60; c(1,4) = 200/60; c(1,5) = -75/60; c(1,6) = 12/60;
28 case 6
29 c(1,1) = 147/60; c(1,2) = 360/60; c(1,3) = -450/60; c(1,4) = 400/60; c(1,5) = -225/60; c(1,6) = 72/60; c(1,7) = -10/60;
30 assert(length(c) == (order+1));
31 end
32 end
33 end