annotate +time/+rk/rungekutta_4RV.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 +time/+rk4/rungekutta_4RV.m@f63b99f0729d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
835
008496ca38f3 Compute the residual in between each runge-kutta stage.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
1 % Takes one time step of size k using the rungekutta method
008496ca38f3 Compute the residual in between each runge-kutta stage.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
2 % starting from v_0 and where the function F(v,t) gives the
008496ca38f3 Compute the residual in between each runge-kutta stage.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
3 % time derivatives.
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: 843
diff changeset
4 function v = rungekutta_4RV(v, t , k, F, RV)
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: 843
diff changeset
5 k1 = F(v, t, RV.getViscosity());
842
619561e9ec0e Reformulate the RK4 time stages in order to easier see how the residual should be updated.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 835
diff changeset
6
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: 843
diff changeset
7 RV.update(v+0.5*k*k1, v, 0.5*k);
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: 843
diff changeset
8 k2 = F(v+0.5*k*k1, t+0.5*k, RV.getViscosity());
843
f63b99f0729d Minor rewrite of RK4RV
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 842
diff changeset
9
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: 843
diff changeset
10 RV.update(v+0.5*k*k2, v, 0.5*k);
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: 843
diff changeset
11 k3 = F(v+0.5*k*k2, t+0.5*k, RV.getViscosity());
842
619561e9ec0e Reformulate the RK4 time stages in order to easier see how the residual should be updated.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 835
diff changeset
12
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: 843
diff changeset
13 RV.update(v+k*k3, v, k);
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: 843
diff changeset
14 k4 = F(v+k*k3,t+k, RV.getViscosity());
842
619561e9ec0e Reformulate the RK4 time stages in order to easier see how the residual should be updated.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents: 835
diff changeset
15
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: 843
diff changeset
16 RV.update(v + (1/6)*(k1+2*(k2+k3)+k4)*k, v, k);
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: 843
diff changeset
17 v = v + (1/6)*(k1+2*(k2+k3)+k4)*k;
835
008496ca38f3 Compute the residual in between each runge-kutta stage.
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff changeset
18 end