Mercurial > repos > public > sbplib
annotate +time/+rk/rungekutta_6RV.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_6RV.m@1e057b0f2fed |
children |
rev | line source |
---|---|
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
1 % Takes one time step of size dt using the rungekutta method |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
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 |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
3 % time derivatives. |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
4 function v = rungekutta_6RV(v, t , dt, F, RV) |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
5 s = 7; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
6 k = zeros(length(v),s); |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
7 a = zeros(7,6); |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
8 c = [0, 4/7, 5/7, 6/7, (5-sqrt(5))/10, (5+sqrt(5))/10, 1]; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
9 b = [1/12, 0, 0, 0, 5/12, 5/12, 1/12]; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
10 a = [ |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
11 0, 0, 0, 0, 0, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
12 4/7, 0, 0, 0, 0, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
13 115/112, -5/16, 0, 0, 0, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
14 589/630, 5/18, -16/45, 0, 0, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
15 229/1200 - 29/6000*sqrt(5), 119/240 - 187/1200*sqrt(5), -14/75 + 34/375*sqrt(5), -3/100*sqrt(5), 0, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
16 71/2400 - 587/12000*sqrt(5), 187/480 - 391/2400*sqrt(5), -38/75 + 26/375*sqrt(5), 27/80 - 3/400*sqrt(5), (1+sqrt(5))/4, 0; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
17 -49/480 + 43/160*sqrt(5), -425/96 + 51/32*sqrt(5), 52/15 - 4/5*sqrt(5), -27/16 + 3/16*sqrt(5), 5/4 - 3/4*sqrt(5), 5/2 - 1/2*sqrt(5); |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
18 ]; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
19 |
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:
845
diff
changeset
|
20 k(:,1) = F(v,t,RV.getViscosity()); |
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:
845
diff
changeset
|
21 |
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:
845
diff
changeset
|
22 for i = 2:s |
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
23 u = v; |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
24 for j = 1:i-1 |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
25 u = u + dt*a(i,j)*k(:,j); |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
26 end |
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:
845
diff
changeset
|
27 RV.update(u,v,c(i)*dt); |
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
28 k(:,i) = F(u,t+c(i)*dt,RV.getViscosity()); |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
29 end |
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
30 |
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:
845
diff
changeset
|
31 u = v; |
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
32 for i = 1:s |
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:
845
diff
changeset
|
33 u = u + dt*b(i)*k(:,i); |
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
34 end |
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:
845
diff
changeset
|
35 RV.update(u,v,dt); |
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:
845
diff
changeset
|
36 v = u; |
845
1e057b0f2fed
Add RK6 with residual viscosity update and reduce computational effort of spatial scheme
Vidar Stiernström <vidar.stiernstrom@it.uu.se>
parents:
diff
changeset
|
37 end |