view +time/+rk/butcherTableau.m @ 1009:87809b4762c9 feature/advectionRV

Draft implementation of scheme for advection with RV - Implement standard advection scheme. No working support for RV
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 31 Oct 2018 09:31:34 -0700
parents c6fcee3fcf1b
children e0560bc4fb7d
line wrap: on
line source

function [s,a,b,c] = butcherTableau(order)

switch order
  
    case 3
        % TVD (Total Variational Diminishing)
        s = 3;
        a = zeros(s,s-1);
        a(2,1) = 1;
        a(3,1) = 1/4; a(3,2) = 1/4;
        b = [1/6, 1/6, 2/3];
        c = [0 1 1/2];
    case 4
        % Standard RK4
        s = 4;
        a = zeros(s,s-1);
        a(2,1) = 1/2; 
        a(3,1) = 0; a(3,2) = 1/2;
        a(4,1) = 0; a(4,2) = 0; a(4,3) = 1;
        b = [1/6 1/3 1/3 1/6];
        c = [0, 1/2, 1/2, 1];
    case 6
        % Runge-Kutta 6 from Alshina07 
        s = 7;
        a = zeros(s,s-1);
        a(2,1) = 4/7; 
        a(3,1) = 115/112; a(3,2) = -5/16;
        a(4,1) = 589/630; a(4,2) = 5/18; a(4,3) = -16/45;
        a(5,1) = 229/1200 - 29/6000*sqrt(5); a(5,2) = 119/240 - 187/1200*sqrt(5); a(5,3) = -14/75 + 34/375*sqrt(5); a(5,4) = -3/100*sqrt(5);
        a(6,1) = 71/2400 - 587/12000*sqrt(5); a(6,2) = 187/480 - 391/2400*sqrt(5); a(6,3) = -38/75 + 26/375*sqrt(5); a(6,4) = 27/80 - 3/400*sqrt(5); a(6,5) = (1+sqrt(5))/4;
        a(7,1) = -49/480 + 43/160*sqrt(5); a(7,2) = -425/96 + 51/32*sqrt(5); a(7,3) = 52/15 - 4/5*sqrt(5); a(7,4) = -27/16 + 3/16*sqrt(5); a(7,5) = 5/4 - 3/4*sqrt(5); a(7,6) = 5/2 - 1/2*sqrt(5);
        b = [1/12 0 0 0 5/12 5/12 1/12];
        c = [0, 4/7, 5/7, 6/7, (5-sqrt(5))/10, (5+sqrt(5))/10, 1];
    otherwise
        error('That Runge-Kutta order is not implemented', order)
        
end